Spawn ped for char select

This commit is contained in:
Vortrex
2021-04-18 19:14:12 -05:00
parent d595c7ab77
commit 2309b3c678

View File

@@ -193,6 +193,11 @@ function showCharacterSelectToClient(client) {
let clanName = (tempSubAccount.clan != 0) ? getClanData(tempSubAccount.clan).name : "None"; let clanName = (tempSubAccount.clan != 0) ? getClanData(tempSubAccount.clan).name : "None";
let lastPlayedText = (tempSubAccount.lastLogin != 0) ? `${getTimeDifferenceDisplay(tempSubAccount.lastLogin, getCurrentUnixTimestamp())} ago` : "Never"; let lastPlayedText = (tempSubAccount.lastLogin != 0) ? `${getTimeDifferenceDisplay(tempSubAccount.lastLogin, getCurrentUnixTimestamp())} ago` : "Never";
showPlayerCharacterSelectGUI(client, tempSubAccount.firstName, tempSubAccount.lastName, tempSubAccount.cash, clanName, lastPlayedText, tempSubAccount.skin); showPlayerCharacterSelectGUI(client, tempSubAccount.firstName, tempSubAccount.lastName, tempSubAccount.cash, clanName, lastPlayedText, tempSubAccount.skin);
spawnPlayer(client, getServerConfig().characterSelectPedPosition, getServerConfig().characterSelectPedHeading, getPlayerCurrentSubAccount(client).skin, getServerConfig().characterSelectInterior, getServerConfig().characterSelectDimension);
setTimeout(function() {
showCharacterSelectCameraToPlayer(client);
}, 500);
logToConsole(LOG_DEBUG, `[Asshat.SubAccount] ${getPlayerDisplayForConsole(client)} is being shown the character select GUI`); logToConsole(LOG_DEBUG, `[Asshat.SubAccount] ${getPlayerDisplayForConsole(client)} is being shown the character select GUI`);
} else { } else {
//let emojiNumbers = ["➊", "➋", "➌", "➍", "➎", "➏", "➐", "➑", "➒"]; //let emojiNumbers = ["➊", "➋", "➌", "➍", "➎", "➏", "➐", "➑", "➒"];
@@ -210,7 +215,7 @@ function showCharacterSelectToClient(client) {
// =========================================================================== // ===========================================================================
function checkNewCharacter(client, firstName, lastName, skinId) { function checkNewCharacter(client, firstName, lastName) {
if(areParamsEmpty(firstName)) { if(areParamsEmpty(firstName)) {
showPlayerNewCharacterFailedGUI(client, "First name cannot be blank!"); showPlayerNewCharacterFailedGUI(client, "First name cannot be blank!");
return false; return false;
@@ -223,7 +228,8 @@ function checkNewCharacter(client, firstName, lastName, skinId) {
} }
lastName = lastName.trim(); lastName = lastName.trim();
if(!skinId) { let skinId = getPlayerData(client).creatingCharacterSkin;
if(skinId == -1) {
skinId = getServerConfig().newCharacter.skin; skinId = getServerConfig().newCharacter.skin;
} }
@@ -240,6 +246,7 @@ function checkNewCharacter(client, firstName, lastName, skinId) {
getPlayerData(client).subAccounts = loadSubAccountsFromAccount(getPlayerData(client).accountData.databaseId); getPlayerData(client).subAccounts = loadSubAccountsFromAccount(getPlayerData(client).accountData.databaseId);
getPlayerData(client).currentSubAccount = 0; getPlayerData(client).currentSubAccount = 0;
getPlayerData(client).creatingCharacter = false;
let tempSubAccount = getPlayerData(client).subAccounts[0]; let tempSubAccount = getPlayerData(client).subAccounts[0];
showCharacterSelectToClient(client); showCharacterSelectToClient(client);
} }
@@ -303,6 +310,8 @@ function selectCharacter(client, characterId = -1) {
let spawnDimension = getPlayerCurrentSubAccount(client).dimension; let spawnDimension = getPlayerCurrentSubAccount(client).dimension;
let skin = getPlayerCurrentSubAccount(client).skin; let skin = getPlayerCurrentSubAccount(client).skin;
getPlayerData(client).switchingCharacter = false;
logToConsole(LOG_DEBUG, `[Asshat.SubAccount] Spawning ${getPlayerDisplayForConsole(client)} as character ID ${getPlayerData(client).currentSubAccount} with skin ${skin} (${spawnPosition.x}, ${spawnPosition.y}, ${spawnPosition.z})`); logToConsole(LOG_DEBUG, `[Asshat.SubAccount] Spawning ${getPlayerDisplayForConsole(client)} as character ID ${getPlayerData(client).currentSubAccount} with skin ${skin} (${spawnPosition.x}, ${spawnPosition.y}, ${spawnPosition.z})`);
//setPlayerCameraLookAt(client, getPosBehindPos(spawnPosition, spawnHeading, 5), spawnPosition); //setPlayerCameraLookAt(client, getPosBehindPos(spawnPosition, spawnHeading, 5), spawnPosition);
getPlayerData(client).pedState = AG_PEDSTATE_SPAWNING; getPlayerData(client).pedState = AG_PEDSTATE_SPAWNING;
@@ -348,8 +357,9 @@ function switchCharacterCommand(command, params, client) {
resetClientStuff(client); resetClientStuff(client);
client.despawnPlayer(); client.despawnPlayer();
getPlayerData(client).switchingCharacter = true;
showConnectCameraToPlayer(client); spawnPlayer(client, getServerConfig().characterSelectPedPosition, getServerConfig().characterSelectPedHeading, getPlayerCurrentSubAccount(client).skin, getServerConfig().characterSelectInterior, getServerConfig().characterSelectDimension);
showCharacterSelectCameraToPlayer(client);
showCharacterSelectToClient(client); showCharacterSelectToClient(client);
} }
@@ -419,6 +429,12 @@ function isPlayerSwitchingCharacter(client) {
// =========================================================================== // ===========================================================================
function isPlayerCreatingCharacter(client) {
return getPlayerData(client).creatingCharacter;
}
// ===========================================================================
function getPlayerCurrentSubAccount(client) { function getPlayerCurrentSubAccount(client) {
if(!getPlayerData(client)) { if(!getPlayerData(client)) {
return false; return false;