Log deaths + wait for player ped

This commit is contained in:
Vortrex
2022-06-07 10:23:25 -05:00
parent 1c9dd51645
commit 0e05b8de8b

View File

@@ -420,6 +420,7 @@ function onPlayerDeath(client, position) {
updatePlayerSpawnedState(client, true);
makePlayerStopAnimation(client);
setPlayerControlState(client, true);
resetPlayerBlip(client);
} else {
let closestHospital = getClosestHospital(getPlayerPosition(client));
despawnPlayer(client);
@@ -443,6 +444,7 @@ function onPlayerDeath(client, position) {
updatePlayerSpawnedState(client, true);
makePlayerStopAnimation(client);
setPlayerControlState(client, true);
resetPlayerBlip(client);
}
}, 2000);
}, 1000);
@@ -455,7 +457,7 @@ function onPlayerDeath(client, position) {
["log_death_pos_y", position.y],
["log_death_pos_z", position.x],
];
let queryString = createDatabaseInsertQuery("log_death", data);
let queryString = createDatabaseInsertQuery("log_death", queryData);
addToQueryQueue(queryString);
}
@@ -470,15 +472,18 @@ function onPedSpawn(ped) {
// ===========================================================================
function onPlayerSpawn(client) {
logToConsole(LOG_DEBUG, `[VRR.Event] Checking for ${getPlayerDisplayForConsole(client)}'s player ped`);
async function onPlayerSpawn(client) {
//logToConsole(LOG_DEBUG, `[VRR.Event] Checking for ${getPlayerDisplayForConsole(client)}'s player ped`);
//if(getPlayerPed(client) == null) {
// logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player element not set yet. Rechecking ...`);
// setTimeout(onPlayerSpawn, 500, client);
// return false;
//}
//logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player ped is valid. Continuing spawn processing ...`);
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player ped is valid. Continuing spawn processing ...`);
if (areServerElementsSupported()) {
await waitUntil(() => client != null && getPlayerPed(client) != null);
}
logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s player data`);
if (!getPlayerData(client)) {
@@ -531,6 +536,12 @@ function onPlayerSpawn(client) {
//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"));
if (getGame() == VRR_GAME_MAFIA_ONE) {
setPlayerPosition(client, getPlayerCurrentSubAccount(client).spawnPosition);
setPlayerHeading(client, getPlayerCurrentSubAccount(client).spawnHeading);
setPlayerDimension(client, getPlayerCurrentSubAccount(client).dimension);
}
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player interior for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).interior}`);
setPlayerInterior(client, getPlayerCurrentSubAccount(client).interior);
@@ -638,6 +649,8 @@ function onPlayerSpawn(client) {
getPlayerData(client).payDayTickStart = sdl.ticks;
sendPlayerLocaleStrings(client);
// Stop playing intro music and any other radio
stopRadioStreamForPlayer(client);
@@ -654,6 +667,8 @@ function onPlayerSpawn(client) {
}
}
resetPlayerBlip(client)
messageDiscordEventChannel(`🧍 ${getPlayerName(client)} spawned as ${getCharacterFullName(client)}`);
}