Don't set stuff on spawn that game doesn't support
This commit is contained in:
@@ -545,7 +545,7 @@ async function onPlayerSpawn(client) {
|
|||||||
await waitUntil(() => client != null && getPlayerPed(client) != null);
|
await waitUntil(() => client != null && getPlayerPed(client) != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s player data`);
|
//logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s player data`);
|
||||||
if (!getPlayerData(client)) {
|
if (!getPlayerData(client)) {
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player data is invalid. Kicking them from server.`);
|
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player data is invalid. Kicking them from server.`);
|
||||||
getPlayerData(targetClient).customDisconnectReason = `Kicked - Spawn bug. Data invalid.`;
|
getPlayerData(targetClient).customDisconnectReason = `Kicked - Spawn bug. Data invalid.`;
|
||||||
@@ -553,7 +553,7 @@ async function onPlayerSpawn(client) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s login status`);
|
//logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s login status`);
|
||||||
if (!isPlayerLoggedIn(client)) {
|
if (!isPlayerLoggedIn(client)) {
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} is NOT logged in. Despawning their player.`);
|
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} is NOT logged in. Despawning their player.`);
|
||||||
getPlayerData(targetClient).customDisconnectReason = `Kicked - Tried to force spawn without logging in.`;
|
getPlayerData(targetClient).customDisconnectReason = `Kicked - Tried to force spawn without logging in.`;
|
||||||
@@ -561,7 +561,7 @@ async function onPlayerSpawn(client) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s selected character status`);
|
//logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s selected character status`);
|
||||||
if (getPlayerData(client).currentSubAccount == -1) {
|
if (getPlayerData(client).currentSubAccount == -1) {
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} has NOT selected a character. Despawning their player.`);
|
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} has NOT selected a character. Despawning their player.`);
|
||||||
getPlayerData(targetClient).customDisconnectReason = `Kicked - Tried to force spawn without selecting a character.`;
|
getPlayerData(targetClient).customDisconnectReason = `Kicked - Tried to force spawn without selecting a character.`;
|
||||||
@@ -571,8 +571,10 @@ async function onPlayerSpawn(client) {
|
|||||||
|
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player data is valid. Continuing spawn processing ...`);
|
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player data is valid. Continuing spawn processing ...`);
|
||||||
|
|
||||||
|
if (isGameFeatureSupported("pedScale")) {
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped scale (${getPlayerCurrentSubAccount(client).pedScale})`);
|
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped scale (${getPlayerCurrentSubAccount(client).pedScale})`);
|
||||||
setEntityData(getPlayerPed(client), "agrp.scale", getPlayerCurrentSubAccount(client).pedScale, true);
|
setEntityData(getPlayerPed(client), "agrp.scale", getPlayerCurrentSubAccount(client).pedScale, true);
|
||||||
|
}
|
||||||
|
|
||||||
//if (isPlayerSwitchingCharacter(client) || isPlayerCreatingCharacter(client)) {
|
//if (isPlayerSwitchingCharacter(client) || isPlayerCreatingCharacter(client)) {
|
||||||
// logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s ped is being used for character selection/creation. No further spawn processing needed'`);
|
// logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s ped is being used for character selection/creation. No further spawn processing needed'`);
|
||||||
@@ -580,11 +582,12 @@ async function onPlayerSpawn(client) {
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
if (isCustomCameraSupported() && getGame() != AGRP_GAME_GTA_IV && getGame() != AGRP_GAME_GTA_IV_EFLC) {
|
if (isCustomCameraSupported() && getGame() != AGRP_GAME_GTA_IV && getGame() != AGRP_GAME_GTA_IV_EFLC) {
|
||||||
|
logToConsole(LOG_DEBUG, `[VRR.Event] Restoring ${getPlayerDisplayForConsole(client)}'s camera`);
|
||||||
restorePlayerCamera(client);
|
restorePlayerCamera(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Event] Storing ${getPlayerDisplayForConsole(client)} ped in client data `);
|
|
||||||
if (areServerElementsSupported()) {
|
if (areServerElementsSupported()) {
|
||||||
|
logToConsole(LOG_DEBUG, `[VRR.Event] Storing ${getPlayerDisplayForConsole(client)} ped in client data `);
|
||||||
getPlayerData(client).ped = getPlayerPed(client);
|
getPlayerData(client).ped = getPlayerPed(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -593,14 +596,18 @@ async function onPlayerSpawn(client) {
|
|||||||
//messagePlayerNormal(client, "This server is in early development and may restart at any time for updates.", getColourByName("orange"));
|
//messagePlayerNormal(client, "This server is in early development and may restart at any time for updates.", getColourByName("orange"));
|
||||||
//messagePlayerNormal(client, "Please report any bugs using /bug and suggestions using /idea", getColourByName("yellow"));
|
//messagePlayerNormal(client, "Please report any bugs using /bug and suggestions using /idea", getColourByName("yellow"));
|
||||||
|
|
||||||
if (getGame() == AGRP_GAME_MAFIA_ONE) {
|
// Tried this. Doesn't work for some reason.
|
||||||
setPlayerPosition(client, getPlayerCurrentSubAccount(client).spawnPosition);
|
// Mafia Connected needs fixed to set position on spawn.
|
||||||
setPlayerHeading(client, getPlayerCurrentSubAccount(client).spawnHeading);
|
//if (getGame() == AGRP_GAME_MAFIA_ONE) {
|
||||||
setPlayerDimension(client, getPlayerCurrentSubAccount(client).dimension);
|
// setPlayerPosition(client, getPlayerCurrentSubAccount(client).spawnPosition);
|
||||||
}
|
// setPlayerHeading(client, getPlayerCurrentSubAccount(client).spawnHeading);
|
||||||
|
// setPlayerDimension(client, getPlayerCurrentSubAccount(client).dimension);
|
||||||
|
//}
|
||||||
|
|
||||||
|
if (isGameFeatureSupported("interior")) {
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player interior for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).interior}`);
|
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player interior for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).interior}`);
|
||||||
setPlayerInterior(client, getPlayerCurrentSubAccount(client).interior);
|
setPlayerInterior(client, getPlayerCurrentSubAccount(client).interior);
|
||||||
|
}
|
||||||
|
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player dimension for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).dimension}`);
|
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player dimension for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).dimension}`);
|
||||||
setPlayerDimension(client, getPlayerCurrentSubAccount(client).dimension);
|
setPlayerDimension(client, getPlayerCurrentSubAccount(client).dimension);
|
||||||
@@ -612,30 +619,37 @@ async function onPlayerSpawn(client) {
|
|||||||
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player health for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).health}`);
|
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player health for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).health}`);
|
||||||
setPlayerHealth(client, getPlayerCurrentSubAccount(client).health);
|
setPlayerHealth(client, getPlayerCurrentSubAccount(client).health);
|
||||||
|
|
||||||
|
if (isGameFeatureSupported("pedArmour")) {
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player armour for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).armour}`);
|
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player armour for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).armour}`);
|
||||||
setPlayerArmour(client, getPlayerCurrentSubAccount(client).armour);
|
setPlayerArmour(client, getPlayerCurrentSubAccount(client).armour);
|
||||||
|
}
|
||||||
|
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Event] Sending ${getPlayerDisplayForConsole(client)}'s job type to their client (${getJobIndexFromDatabaseId(getPlayerCurrentSubAccount(client))})`);
|
logToConsole(LOG_DEBUG, `[VRR.Event] Sending ${getPlayerDisplayForConsole(client)}'s job type to their client (${getJobIndexFromDatabaseId(getPlayerCurrentSubAccount(client))})`);
|
||||||
sendPlayerJobType(client, getPlayerCurrentSubAccount(client).job);
|
sendPlayerJobType(client, getPlayerCurrentSubAccount(client).job);
|
||||||
|
|
||||||
|
if (isGameFeatureSupported("rendering2D")) {
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Event] Enabling all rendering states for ${getPlayerDisplayForConsole(client)}`);
|
logToConsole(LOG_DEBUG, `[VRR.Event] Enabling all rendering states for ${getPlayerDisplayForConsole(client)}`);
|
||||||
setPlayer2DRendering(client, true, true, true, true, true, true);
|
setPlayer2DRendering(client, true, true, true, true, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isGameFeatureSupported("snow")) {
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Event] Sending snow states to ${getPlayerDisplayForConsole(client)}`);
|
logToConsole(LOG_DEBUG, `[VRR.Event] Sending snow states to ${getPlayerDisplayForConsole(client)}`);
|
||||||
if (isSnowSupported()) {
|
|
||||||
updatePlayerSnowState(client);
|
updatePlayerSnowState(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (areServerElementsSupported() && getGame() == AGRP_GAME_GTA_SA) {
|
if (areServerElementsSupported() && isGameFeatureSupported("walkingStyle")) {
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player walk and fightstyle for ${getPlayerDisplayForConsole(client)}`);
|
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player walking style for ${getPlayerDisplayForConsole(client)}`);
|
||||||
setEntityData(getPlayerPed(client), "agrp.walkStyle", getPlayerCurrentSubAccount(client).walkStyle, true);
|
setEntityData(getPlayerPed(client), "agrp.walkStyle", getPlayerCurrentSubAccount(client).walkStyle, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isGameFeatureSupported("fightingStyle")) {
|
||||||
|
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player fighting style for ${getPlayerDisplayForConsole(client)}`);
|
||||||
setPlayerFightStyle(client, getPlayerCurrentSubAccount(client).fightStyle);
|
setPlayerFightStyle(client, getPlayerCurrentSubAccount(client).fightStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isGameFeatureSupported("rendering2D")) {
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Event] Updating logo state for ${getPlayerDisplayForConsole(client)}`);
|
logToConsole(LOG_DEBUG, `[VRR.Event] Updating logo state for ${getPlayerDisplayForConsole(client)}`);
|
||||||
if (getServerConfig().showLogo && doesPlayerHaveLogoEnabled(client)) {
|
updatePlayerShowLogoState(client, (getServerConfig().showLogo && doesPlayerHaveLogoEnabled(client)));
|
||||||
updatePlayerShowLogoState(client, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Event] Caching ${getPlayerDisplayForConsole(client)}'s hotbar items`);
|
logToConsole(LOG_DEBUG, `[VRR.Event] Caching ${getPlayerDisplayForConsole(client)}'s hotbar items`);
|
||||||
@@ -687,8 +701,10 @@ async function onPlayerSpawn(client) {
|
|||||||
logToConsole(LOG_DEBUG, `[VRR.Event] Syncing ${getPlayerDisplayForConsole(client)}'s cash ${getPlayerCurrentSubAccount(client).cash}`);
|
logToConsole(LOG_DEBUG, `[VRR.Event] Syncing ${getPlayerDisplayForConsole(client)}'s cash ${getPlayerCurrentSubAccount(client).cash}`);
|
||||||
updatePlayerCash(client);
|
updatePlayerCash(client);
|
||||||
|
|
||||||
|
if (isGameFeatureSupported("customNametag")) {
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Event] Sending player nametag distance to ${getPlayerDisplayForConsole(client)}`);
|
logToConsole(LOG_DEBUG, `[VRR.Event] Sending player nametag distance to ${getPlayerDisplayForConsole(client)}`);
|
||||||
sendNameTagDistanceToClient(client, getServerConfig().nameTagDistance);
|
sendNameTagDistanceToClient(client, getServerConfig().nameTagDistance);
|
||||||
|
}
|
||||||
|
|
||||||
if (!areServerElementsSupported()) {
|
if (!areServerElementsSupported()) {
|
||||||
sendAllBusinessesToPlayer(client);
|
sendAllBusinessesToPlayer(client);
|
||||||
@@ -703,11 +719,24 @@ async function onPlayerSpawn(client) {
|
|||||||
|
|
||||||
getPlayerData(client).payDayTickStart = sdl.ticks;
|
getPlayerData(client).payDayTickStart = sdl.ticks;
|
||||||
|
|
||||||
|
// Locales are handled via resource files now. No need to send anymore, but kept in case revert is needed.
|
||||||
//sendPlayerLocaleStrings(client);
|
//sendPlayerLocaleStrings(client);
|
||||||
|
|
||||||
// Stop playing intro music and any other radio
|
logToConsole(LOG_DEBUG, `[VRR.Event] Updating all player name tags`);
|
||||||
stopRadioStreamForPlayer(client);
|
updateAllPlayerNameTags();
|
||||||
|
|
||||||
|
setPlayerWeaponDamageEvent(client, AGRP_WEAPON_DAMAGE_EVENT_NORMAL);
|
||||||
|
|
||||||
|
if (getGlobalConfig().playerStreamInDistance == -1 || getGlobalConfig().playerStreamOutDistance == -1) {
|
||||||
|
getPlayerPed(client).netFlags.distanceStreaming = false;
|
||||||
|
} else {
|
||||||
|
setElementStreamInDistance(getPlayerPed(client), getServerConfig().playerStreamInDistance);
|
||||||
|
setElementStreamOutDistance(getPlayerPed(client), getServerConfig().playerStreamOutDistance);
|
||||||
|
}
|
||||||
|
|
||||||
|
resetPlayerBlip(client);
|
||||||
|
|
||||||
|
// Radio stuff must be last thing sent to client because it hangs the client for a second, which blocks processing of other incoming packets
|
||||||
// Start playing business/house radio if in one
|
// Start playing business/house radio if in one
|
||||||
if (getPlayerCurrentSubAccount(client).interior != getGameConfig().mainWorldInterior || getPlayerCurrentSubAccount(client).dimension != getGameConfig().mainWorldDimension) {
|
if (getPlayerCurrentSubAccount(client).interior != getGameConfig().mainWorldInterior || getPlayerCurrentSubAccount(client).dimension != getGameConfig().mainWorldDimension) {
|
||||||
let businessId = getPlayerBusiness(client);
|
let businessId = getPlayerBusiness(client);
|
||||||
@@ -720,17 +749,13 @@ async function onPlayerSpawn(client) {
|
|||||||
if (getHouseData(houseId).streamingRadioStation != -1) {
|
if (getHouseData(houseId).streamingRadioStation != -1) {
|
||||||
playRadioStreamForPlayer(client, getRadioStationData(getHouseData(houseId).streamingRadioStation).url, true, getPlayerStreamingRadioVolume(client), null);
|
playRadioStreamForPlayer(client, getRadioStationData(getHouseData(houseId).streamingRadioStation).url, true, getPlayerStreamingRadioVolume(client), null);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
stopRadioStreamForPlayer(client);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
stopRadioStreamForPlayer(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
setPlayerWeaponDamageEvent(client, AGRP_WEAPON_DAMAGE_EVENT_NORMAL);
|
|
||||||
|
|
||||||
|
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Event] Updating all player name tags`);
|
|
||||||
updateAllPlayerNameTags();
|
|
||||||
|
|
||||||
resetPlayerBlip(client);
|
|
||||||
|
|
||||||
messageDiscordEventChannel(`🧍 ${getPlayerName(client)} spawned as ${getCharacterFullName(client)}`);
|
messageDiscordEventChannel(`🧍 ${getPlayerName(client)} spawned as ${getCharacterFullName(client)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user