Prevent usechar unless in char select mode

This commit is contained in:
Vortrex
2020-12-29 00:21:03 -06:00
parent 74759b020a
commit 25928a1bcf

View File

@@ -112,6 +112,8 @@ function createSubAccount(accountId, firstName, lastName, skinId, dateOfBirth, p
// ---------------------------------------------------------------------------
function showCharacterSelectToClient(client) {
getPlayerData(client).switchingCharacter = true;
if(doesPlayerHaveAutoSelectLastCharacterEnabled(client)) {
if(getPlayerData().subAccounts != null) {
if(getPlayerData().subAccounts.length > 0) {
@@ -254,6 +256,9 @@ async function selectCharacter(client, characterId = -1) {
}, client.ping+1000);
updateAllPlayerNameTags();
getPlayerData(client).switchingCharacter = false;
triggerNetworkEvent("ag.jobType", client, tempSubAccount.job);
}
addNetworkHandler("ag.selectCharacter", selectCharacter);
@@ -292,6 +297,11 @@ function newCharacterCommand(command, params, client) {
// ---------------------------------------------------------------------------
function useCharacterCommand(command, params, client) {
if(!getPlayerData(client).switchingCharacter) {
messagePlayerError(client, "Use /switchchar to save this character and return to the characters screen first!");
return false;
}
if(areParamsEmpty(params)) {
messageClientSyntax(client, getCommandSyntaxText(command));
return false;