Log deaths + wait for player ped
This commit is contained in:
@@ -56,7 +56,7 @@ function onPlayerConnect(event, ipAddress, port) {
|
|||||||
function onPlayerJoin(event, client) {
|
function onPlayerJoin(event, client) {
|
||||||
logToConsole(LOG_INFO, `[VRR.Event] Client ${getPlayerName(client)}[${getPlayerId(client)}] joining from ${getPlayerIP(client)}`);
|
logToConsole(LOG_INFO, `[VRR.Event] Client ${getPlayerName(client)}[${getPlayerId(client)}] joining from ${getPlayerIP(client)}`);
|
||||||
|
|
||||||
if(isFadeCameraSupported()) {
|
if (isFadeCameraSupported()) {
|
||||||
fadeCamera(client, true, 1.0);
|
fadeCamera(client, true, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ function onPlayerJoin(event, client) {
|
|||||||
messageDiscordEventChannel(messageText);
|
messageDiscordEventChannel(messageText);
|
||||||
|
|
||||||
let clients = getClients();
|
let clients = getClients();
|
||||||
for(let i in clients) {
|
for (let i in clients) {
|
||||||
messagePlayerNormal(clients[i], getLocaleString(clients[i], "PlayerConnecting", getPlayerName(client)));
|
messagePlayerNormal(clients[i], getLocaleString(clients[i], "PlayerConnecting", getPlayerName(client)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,8 +88,8 @@ function onElementStreamIn(event, element, client) {
|
|||||||
// event.preventDefault();
|
// event.preventDefault();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
if(getPlayerData(getClientFromIndex(element.owner)) != false ) {
|
if (getPlayerData(getClientFromIndex(element.owner)) != false) {
|
||||||
if(hasBitFlag(getPlayerData(getClientFromIndex(element.owner)).accountData.flags.moderation, getModerationFlagValue("DontSyncClientElements"))) {
|
if (hasBitFlag(getPlayerData(getClientFromIndex(element.owner)).accountData.flags.moderation, getModerationFlagValue("DontSyncClientElements"))) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
destroyGameElement(element);
|
destroyGameElement(element);
|
||||||
}
|
}
|
||||||
@@ -109,7 +109,7 @@ function onPlayerQuit(event, client, quitReasonId) {
|
|||||||
updateConnectionLogOnQuit(client, quitReasonId);
|
updateConnectionLogOnQuit(client, quitReasonId);
|
||||||
|
|
||||||
let reasonText = disconnectReasons[quitReasonId];
|
let reasonText = disconnectReasons[quitReasonId];
|
||||||
if(getPlayerData(client).customDisconnectReason != "" && getPlayerData(client).customDisconnectReason != undefined && getPlayerData(client).customDisconnectReason != false && getPlayerData(client).customDisconnectReason != null) {
|
if (getPlayerData(client).customDisconnectReason != "" && getPlayerData(client).customDisconnectReason != undefined && getPlayerData(client).customDisconnectReason != false && getPlayerData(client).customDisconnectReason != null) {
|
||||||
reasonText = getPlayerData(client).customDisconnectReason;
|
reasonText = getPlayerData(client).customDisconnectReason;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ function onPlayerQuit(event, client, quitReasonId) {
|
|||||||
});
|
});
|
||||||
//messagePlayerNormal(null, `👋 ${getPlayerName(client)} has left the server (${reasonText})`, getColourByName("softYellow"));
|
//messagePlayerNormal(null, `👋 ${getPlayerName(client)} has left the server (${reasonText})`, getColourByName("softYellow"));
|
||||||
|
|
||||||
if(isPlayerLoggedIn(client)) {
|
if (isPlayerLoggedIn(client)) {
|
||||||
savePlayerToDatabase(client);
|
savePlayerToDatabase(client);
|
||||||
resetClientStuff(client);
|
resetClientStuff(client);
|
||||||
getServerData().clients[getPlayerId(client)] = null;
|
getServerData().clients[getPlayerId(client)] = null;
|
||||||
@@ -159,17 +159,17 @@ function onEntityProcess(event, entity) {
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function onPedEnteringVehicle(event, ped, vehicle, seat) {
|
function onPedEnteringVehicle(event, ped, vehicle, seat) {
|
||||||
if(ped.isType(ELEMENT_PLAYER)) {
|
if (ped.isType(ELEMENT_PLAYER)) {
|
||||||
let client = getClientFromPlayerElement(ped);
|
let client = getClientFromPlayerElement(ped);
|
||||||
getPlayerData(client).pedState = VRR_PEDSTATE_ENTERINGVEHICLE;
|
getPlayerData(client).pedState = VRR_PEDSTATE_ENTERINGVEHICLE;
|
||||||
|
|
||||||
if(!getVehicleData(vehicle)) {
|
if (!getVehicleData(vehicle)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getVehicleData(vehicle).locked) {
|
if (getVehicleData(vehicle).locked) {
|
||||||
if(doesPlayerHaveVehicleKeys(client, vehicle)) {
|
if (doesPlayerHaveVehicleKeys(client, vehicle)) {
|
||||||
if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "lock")) {
|
if (!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "lock")) {
|
||||||
messagePlayerTip(client, `🔒 This ${getVehicleName(vehicle)} is locked. Press {ALTCOLOUR}${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "lock").key))} {MAINCOLOUR}to unlock it.`);
|
messagePlayerTip(client, `🔒 This ${getVehicleName(vehicle)} is locked. Press {ALTCOLOUR}${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "lock").key))} {MAINCOLOUR}to unlock it.`);
|
||||||
} else {
|
} else {
|
||||||
messagePlayerNormal(client, `🔒 This ${getVehicleName(vehicle)} is locked. Use /lock to unlock it`);
|
messagePlayerNormal(client, `🔒 This ${getVehicleName(vehicle)} is locked. Use /lock to unlock it`);
|
||||||
@@ -190,16 +190,16 @@ function onPedEnteringVehicle(event, ped, vehicle, seat) {
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function onPedExitingVehicle(event, ped, vehicle) {
|
function onPedExitingVehicle(event, ped, vehicle) {
|
||||||
if(!getVehicleData(vehicle)) {
|
if (!getVehicleData(vehicle)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ped.isType(ELEMENT_PLAYER)) {
|
if (ped.isType(ELEMENT_PLAYER)) {
|
||||||
let client = getClientFromPlayerElement(ped);
|
let client = getClientFromPlayerElement(ped);
|
||||||
getPlayerData(client).pedState = VRR_PEDSTATE_EXITINGVEHICLE;
|
getPlayerData(client).pedState = VRR_PEDSTATE_EXITINGVEHICLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!getVehicleData(vehicle).spawnLocked) {
|
if (!getVehicleData(vehicle).spawnLocked) {
|
||||||
getVehicleData(vehicle).spawnPosition = getVehiclePosition(vehicle);
|
getVehicleData(vehicle).spawnPosition = getVehiclePosition(vehicle);
|
||||||
getVehicleData(vehicle).spawnRotation = getVehicleHeading(vehicle);
|
getVehicleData(vehicle).spawnRotation = getVehicleHeading(vehicle);
|
||||||
getVehicleData(vehicle).needsSaved = true;
|
getVehicleData(vehicle).needsSaved = true;
|
||||||
@@ -225,7 +225,7 @@ function onResourceStop(event, resource) {
|
|||||||
// messageAdmins(`{MAINCOLOUR}Resource {ALTCOLOUR}${resource.name}{MAINCOLOUR} stopped!`);
|
// messageAdmins(`{MAINCOLOUR}Resource {ALTCOLOUR}${resource.name}{MAINCOLOUR} stopped!`);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
if(resource == thisResource) {
|
if (resource == thisResource) {
|
||||||
kickAllClients();
|
kickAllClients();
|
||||||
saveServerDataToDatabase();
|
saveServerDataToDatabase();
|
||||||
collectAllGarbage();
|
collectAllGarbage();
|
||||||
@@ -247,16 +247,16 @@ function onPlayerExitedSphere(client, sphere) {
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
async function onPlayerEnteredVehicle(client, clientVehicle, seat) {
|
async function onPlayerEnteredVehicle(client, clientVehicle, seat) {
|
||||||
if(client == null) {
|
if (client == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let vehicle = null;
|
let vehicle = null;
|
||||||
|
|
||||||
if(getGame() == VRR_GAME_GTA_IV) {
|
if (getGame() == VRR_GAME_GTA_IV) {
|
||||||
vehicle = getVehicleFromIVNetworkId(clientVehicle);
|
vehicle = getVehicleFromIVNetworkId(clientVehicle);
|
||||||
} else {
|
} else {
|
||||||
if(getPlayerPed(client) == null) {
|
if (getPlayerPed(client) == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,7 +265,7 @@ async function onPlayerEnteredVehicle(client, clientVehicle, seat) {
|
|||||||
vehicle = getPlayerVehicle(client);
|
vehicle = getPlayerVehicle(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!getVehicleData(vehicle)) {
|
if (!getVehicleData(vehicle)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,14 +274,14 @@ async function onPlayerEnteredVehicle(client, clientVehicle, seat) {
|
|||||||
getPlayerData(client).lastVehicle = vehicle;
|
getPlayerData(client).lastVehicle = vehicle;
|
||||||
getVehicleData(vehicle).lastActiveTime = getCurrentUnixTimestamp();
|
getVehicleData(vehicle).lastActiveTime = getCurrentUnixTimestamp();
|
||||||
|
|
||||||
if(getPlayerVehicleSeat(client) == VRR_VEHSEAT_DRIVER) {
|
if (getPlayerVehicleSeat(client) == VRR_VEHSEAT_DRIVER) {
|
||||||
vehicle.engine = getVehicleData(vehicle).engine;
|
vehicle.engine = getVehicleData(vehicle).engine;
|
||||||
|
|
||||||
if(getVehicleData(vehicle).buyPrice > 0) {
|
if (getVehicleData(vehicle).buyPrice > 0) {
|
||||||
messagePlayerAlert(client, getLocaleString(client, "VehicleForSale", getVehicleName(vehicle), `{ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).buyPrice)}{MAINCOLOUR}`, `{ALTCOLOUR}/vehbuy{MAINCOLOUR}`));
|
messagePlayerAlert(client, getLocaleString(client, "VehicleForSale", getVehicleName(vehicle), `{ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).buyPrice)}{MAINCOLOUR}`, `{ALTCOLOUR}/vehbuy{MAINCOLOUR}`));
|
||||||
resetVehiclePosition(vehicle);
|
resetVehiclePosition(vehicle);
|
||||||
} else if(getVehicleData(vehicle).rentPrice > 0) {
|
} else if (getVehicleData(vehicle).rentPrice > 0) {
|
||||||
if(getVehicleData(vehicle).rentedBy != client) {
|
if (getVehicleData(vehicle).rentedBy != client) {
|
||||||
messagePlayerAlert(client, getLocaleString(client, "VehicleForRent", getVehicleName(vehicle), `{ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).rentPrice)}{MAINCOLOUR}`, `{ALTCOLOUR}/vehrent{MAINCOLOUR}`));
|
messagePlayerAlert(client, getLocaleString(client, "VehicleForRent", getVehicleName(vehicle), `{ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).rentPrice)}{MAINCOLOUR}`, `{ALTCOLOUR}/vehrent{MAINCOLOUR}`));
|
||||||
resetVehiclePosition(vehicle);
|
resetVehiclePosition(vehicle);
|
||||||
} else {
|
} else {
|
||||||
@@ -291,7 +291,7 @@ async function onPlayerEnteredVehicle(client, clientVehicle, seat) {
|
|||||||
let ownerName = "Nobody";
|
let ownerName = "Nobody";
|
||||||
let ownerType = "None";
|
let ownerType = "None";
|
||||||
ownerType = toLowerCase(getVehicleOwnerTypeText(getVehicleData(vehicle).ownerType));
|
ownerType = toLowerCase(getVehicleOwnerTypeText(getVehicleData(vehicle).ownerType));
|
||||||
switch(getVehicleData(vehicle).ownerType) {
|
switch (getVehicleData(vehicle).ownerType) {
|
||||||
case VRR_VEHOWNER_CLAN:
|
case VRR_VEHOWNER_CLAN:
|
||||||
ownerName = getClanData(getClanIdFromDatabaseId(getVehicleData(vehicle).ownerId)).name;
|
ownerName = getClanData(getClanIdFromDatabaseId(getVehicleData(vehicle).ownerId)).name;
|
||||||
ownerType = "clan";
|
ownerType = "clan";
|
||||||
@@ -319,10 +319,10 @@ async function onPlayerEnteredVehicle(client, clientVehicle, seat) {
|
|||||||
messagePlayerAlert(client, `This ${getVehicleName(vehicle)} belongs to {ALTCOLOUR}${ownerName} (${ownerType})`);
|
messagePlayerAlert(client, `This ${getVehicleName(vehicle)} belongs to {ALTCOLOUR}${ownerName} (${ownerType})`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!getVehicleData(vehicle).engine) {
|
if (!getVehicleData(vehicle).engine) {
|
||||||
if(getVehicleData(vehicle).buyPrice == 0 && getVehicleData(vehicle).rentPrice == 0) {
|
if (getVehicleData(vehicle).buyPrice == 0 && getVehicleData(vehicle).rentPrice == 0) {
|
||||||
if(doesPlayerHaveVehicleKeys(client, vehicle)) {
|
if (doesPlayerHaveVehicleKeys(client, vehicle)) {
|
||||||
if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "engine")) {
|
if (!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "engine")) {
|
||||||
messagePlayerTip(client, `This ${getVehicleName(vehicle)}'s engine is off. Press {ALTCOLOUR}${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "engine").key))} {MAINCOLOUR}to start it.`);
|
messagePlayerTip(client, `This ${getVehicleName(vehicle)}'s engine is off. Press {ALTCOLOUR}${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "engine").key))} {MAINCOLOUR}to start it.`);
|
||||||
} else {
|
} else {
|
||||||
messagePlayerAlert(client, `This ${getVehicleName(vehicle)}'s engine is off. Use /engine to start it`);
|
messagePlayerAlert(client, `This ${getVehicleName(vehicle)}'s engine is off. Use /engine to start it`);
|
||||||
@@ -337,26 +337,26 @@ async function onPlayerEnteredVehicle(client, clientVehicle, seat) {
|
|||||||
|
|
||||||
let currentSubAccount = getPlayerCurrentSubAccount(client);
|
let currentSubAccount = getPlayerCurrentSubAccount(client);
|
||||||
|
|
||||||
if(isPlayerWorking(client)) {
|
if (isPlayerWorking(client)) {
|
||||||
if(getVehicleData(vehicle).ownerType == VRR_VEHOWNER_JOB) {
|
if (getVehicleData(vehicle).ownerType == VRR_VEHOWNER_JOB) {
|
||||||
if(getVehicleData(vehicle).ownerId == getPlayerCurrentSubAccount(client).job) {
|
if (getVehicleData(vehicle).ownerId == getPlayerCurrentSubAccount(client).job) {
|
||||||
getPlayerCurrentSubAccount(client).lastJobVehicle = vehicle;
|
getPlayerCurrentSubAccount(client).lastJobVehicle = vehicle;
|
||||||
messagePlayerInfo(client, `Use /startroute to start working in this vehicle`);
|
messagePlayerInfo(client, `Use /startroute to start working in this vehicle`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isPlayerWorking(client)) {
|
if (isPlayerWorking(client)) {
|
||||||
if(isPlayerOnJobRoute(client)) {
|
if (isPlayerOnJobRoute(client)) {
|
||||||
if(vehicle == getPlayerJobRouteVehicle(client)) {
|
if (vehicle == getPlayerJobRouteVehicle(client)) {
|
||||||
stopReturnToJobVehicleCountdown(client);
|
stopReturnToJobVehicleCountdown(client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getVehicleData(vehicle).streamingRadioStation != -1) {
|
if (getVehicleData(vehicle).streamingRadioStation != -1) {
|
||||||
if(getPlayerData(client).streamingRadioStation != getVehicleData(vehicle).streamingRadioStation) {
|
if (getPlayerData(client).streamingRadioStation != getVehicleData(vehicle).streamingRadioStation) {
|
||||||
playRadioStreamForPlayer(client, getServerData().radioStations[getVehicleData(vehicle).streamingRadioStation].url, true, getPlayerStreamingRadioVolume(client));
|
playRadioStreamForPlayer(client, getServerData().radioStations[getVehicleData(vehicle).streamingRadioStation].url, true, getPlayerStreamingRadioVolume(client));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -369,13 +369,13 @@ function onPlayerExitedVehicle(client, vehicle) {
|
|||||||
|
|
||||||
stopRadioStreamForPlayer(client);
|
stopRadioStreamForPlayer(client);
|
||||||
|
|
||||||
if(!getVehicleData(vehicle)) {
|
if (!getVehicleData(vehicle)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isPlayerWorking(client)) {
|
if (isPlayerWorking(client)) {
|
||||||
if(isPlayerOnJobRoute(client)) {
|
if (isPlayerOnJobRoute(client)) {
|
||||||
if(vehicle == getPlayerJobRouteVehicle(client)) {
|
if (vehicle == getPlayerJobRouteVehicle(client)) {
|
||||||
startReturnToJobVehicleCountdown(client);
|
startReturnToJobVehicleCountdown(client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -393,56 +393,58 @@ function onPlayerDeath(client, position) {
|
|||||||
getPlayerData(client).pedState = VRR_PEDSTATE_DEAD;
|
getPlayerData(client).pedState = VRR_PEDSTATE_DEAD;
|
||||||
updatePlayerSpawnedState(client, false);
|
updatePlayerSpawnedState(client, false);
|
||||||
setPlayerControlState(client, false);
|
setPlayerControlState(client, false);
|
||||||
setTimeout(function() {
|
setTimeout(function () {
|
||||||
if(isFadeCameraSupported()) {
|
if (isFadeCameraSupported()) {
|
||||||
fadeCamera(client, false, 1.0);
|
fadeCamera(client, false, 1.0);
|
||||||
}
|
}
|
||||||
setTimeout(function() {
|
setTimeout(function () {
|
||||||
if(getPlayerCurrentSubAccount(client).inJail) {
|
if (getPlayerCurrentSubAccount(client).inJail) {
|
||||||
let closestJail = getClosestPoliceStation(getPlayerPosition(client));
|
let closestJail = getClosestPoliceStation(getPlayerPosition(client));
|
||||||
despawnPlayer(client);
|
despawnPlayer(client);
|
||||||
getPlayerCurrentSubAccount(client).interior = closestJail.interior;
|
getPlayerCurrentSubAccount(client).interior = closestJail.interior;
|
||||||
getPlayerCurrentSubAccount(client).dimension = closestJail.dimension;
|
getPlayerCurrentSubAccount(client).dimension = closestJail.dimension;
|
||||||
|
|
||||||
if(isPlayerWorking(client)) {
|
if (isPlayerWorking(client)) {
|
||||||
stopWorking(client);
|
stopWorking(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getGame() == VRR_GAME_MAFIA_ONE) {
|
if (getGame() == VRR_GAME_MAFIA_ONE) {
|
||||||
spawnPlayer(client, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0], closestJail.position, closestJail.heading);
|
spawnPlayer(client, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0], closestJail.position, closestJail.heading);
|
||||||
} else {
|
} else {
|
||||||
spawnPlayer(client, closestJail.position, closestJail.heading, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]);
|
spawnPlayer(client, closestJail.position, closestJail.heading, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isFadeCameraSupported()) {
|
if (isFadeCameraSupported()) {
|
||||||
fadeCamera(client, true, 1.0);
|
fadeCamera(client, true, 1.0);
|
||||||
}
|
}
|
||||||
updatePlayerSpawnedState(client, true);
|
updatePlayerSpawnedState(client, true);
|
||||||
makePlayerStopAnimation(client);
|
makePlayerStopAnimation(client);
|
||||||
setPlayerControlState(client, true);
|
setPlayerControlState(client, true);
|
||||||
|
resetPlayerBlip(client);
|
||||||
} else {
|
} else {
|
||||||
let closestHospital = getClosestHospital(getPlayerPosition(client));
|
let closestHospital = getClosestHospital(getPlayerPosition(client));
|
||||||
despawnPlayer(client);
|
despawnPlayer(client);
|
||||||
getPlayerCurrentSubAccount(client).interior = closestHospital.interior;
|
getPlayerCurrentSubAccount(client).interior = closestHospital.interior;
|
||||||
getPlayerCurrentSubAccount(client).dimension = closestHospital.dimension;
|
getPlayerCurrentSubAccount(client).dimension = closestHospital.dimension;
|
||||||
|
|
||||||
if(isPlayerWorking(client)) {
|
if (isPlayerWorking(client)) {
|
||||||
stopWorking(client);
|
stopWorking(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getGame() == VRR_GAME_MAFIA_ONE) {
|
if (getGame() == VRR_GAME_MAFIA_ONE) {
|
||||||
spawnPlayer(client, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0], closestHospital.position, closestHospital.heading);
|
spawnPlayer(client, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0], closestHospital.position, closestHospital.heading);
|
||||||
} else {
|
} else {
|
||||||
spawnPlayer(client, closestHospital.position, closestHospital.heading, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]);
|
spawnPlayer(client, closestHospital.position, closestHospital.heading, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isFadeCameraSupported()) {
|
if (isFadeCameraSupported()) {
|
||||||
fadeCamera(client, true, 1.0);
|
fadeCamera(client, true, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePlayerSpawnedState(client, true);
|
updatePlayerSpawnedState(client, true);
|
||||||
makePlayerStopAnimation(client);
|
makePlayerStopAnimation(client);
|
||||||
setPlayerControlState(client, true);
|
setPlayerControlState(client, true);
|
||||||
|
resetPlayerBlip(client);
|
||||||
}
|
}
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
@@ -455,14 +457,14 @@ function onPlayerDeath(client, position) {
|
|||||||
["log_death_pos_y", position.y],
|
["log_death_pos_y", position.y],
|
||||||
["log_death_pos_z", position.x],
|
["log_death_pos_z", position.x],
|
||||||
];
|
];
|
||||||
let queryString = createDatabaseInsertQuery("log_death", data);
|
let queryString = createDatabaseInsertQuery("log_death", queryData);
|
||||||
addToQueryQueue(queryString);
|
addToQueryQueue(queryString);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function onPedSpawn(ped) {
|
function onPedSpawn(ped) {
|
||||||
if(ped.type == ELEMENT_PLAYER) {
|
if (ped.type == ELEMENT_PLAYER) {
|
||||||
//setTimeout(onPlayerSpawn, 250, ped);
|
//setTimeout(onPlayerSpawn, 250, ped);
|
||||||
onPlayerSpawn();
|
onPlayerSpawn();
|
||||||
}
|
}
|
||||||
@@ -470,32 +472,35 @@ function onPedSpawn(ped) {
|
|||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function onPlayerSpawn(client) {
|
async function onPlayerSpawn(client) {
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Event] Checking for ${getPlayerDisplayForConsole(client)}'s player ped`);
|
//logToConsole(LOG_DEBUG, `[VRR.Event] Checking for ${getPlayerDisplayForConsole(client)}'s player ped`);
|
||||||
//if(getPlayerPed(client) == null) {
|
//if(getPlayerPed(client) == null) {
|
||||||
// logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player element not set yet. Rechecking ...`);
|
// logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player element not set yet. Rechecking ...`);
|
||||||
// setTimeout(onPlayerSpawn, 500, client);
|
// setTimeout(onPlayerSpawn, 500, client);
|
||||||
// return false;
|
// 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`);
|
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.`);
|
||||||
disconnectPlayer(client);
|
disconnectPlayer(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.`);
|
||||||
disconnectPlayer(client);
|
disconnectPlayer(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.`);
|
||||||
disconnectPlayer(client);
|
disconnectPlayer(client);
|
||||||
return false;
|
return false;
|
||||||
@@ -503,7 +508,7 @@ 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(getGame() == VRR_GAME_GTA_IV) {
|
if (getGame() == VRR_GAME_GTA_IV) {
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped body parts and props`);
|
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped body parts and props`);
|
||||||
setEntityData(getPlayerPed(client), "vrr.bodyParts", getPlayerCurrentSubAccount(client).bodyParts, true);
|
setEntityData(getPlayerPed(client), "vrr.bodyParts", getPlayerCurrentSubAccount(client).bodyParts, true);
|
||||||
setEntityData(getPlayerPed(client), "vrr.bodyProps", getPlayerCurrentSubAccount(client).bodyProps, true);
|
setEntityData(getPlayerPed(client), "vrr.bodyProps", getPlayerCurrentSubAccount(client).bodyProps, true);
|
||||||
@@ -512,17 +517,17 @@ function onPlayerSpawn(client) {
|
|||||||
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), "vrr.scale", getPlayerCurrentSubAccount(client).pedScale, true);
|
setEntityData(getPlayerPed(client), "vrr.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'`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isCustomCameraSupported()) {
|
if (isCustomCameraSupported()) {
|
||||||
restorePlayerCamera(client);
|
restorePlayerCamera(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Event] Storing ${getPlayerDisplayForConsole(client)} ped in client data `);
|
logToConsole(LOG_DEBUG, `[VRR.Event] Storing ${getPlayerDisplayForConsole(client)} ped in client data `);
|
||||||
if(areServerElementsSupported()) {
|
if (areServerElementsSupported()) {
|
||||||
getPlayerData(client).ped = getPlayerPed(client);
|
getPlayerData(client).ped = getPlayerPed(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, "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() == 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}`);
|
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);
|
||||||
|
|
||||||
@@ -554,11 +565,11 @@ function onPlayerSpawn(client) {
|
|||||||
setPlayer2DRendering(client, true, true, true, true, true, true);
|
setPlayer2DRendering(client, true, true, true, true, true, true);
|
||||||
|
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Event] Sending snow states to ${getPlayerDisplayForConsole(client)}`);
|
logToConsole(LOG_DEBUG, `[VRR.Event] Sending snow states to ${getPlayerDisplayForConsole(client)}`);
|
||||||
if(isSnowSupported()) {
|
if (isSnowSupported()) {
|
||||||
updatePlayerSnowState(client);
|
updatePlayerSnowState(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(areServerElementsSupported() && getGame() == VRR_GAME_GTA_SA) {
|
if (areServerElementsSupported() && getGame() == VRR_GAME_GTA_SA) {
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player walk and fightstyle for ${getPlayerDisplayForConsole(client)}`);
|
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player walk and fightstyle for ${getPlayerDisplayForConsole(client)}`);
|
||||||
setEntityData(getPlayerPed(client), "vrr.walkStyle", getPlayerCurrentSubAccount(client).walkStyle, true);
|
setEntityData(getPlayerPed(client), "vrr.walkStyle", getPlayerCurrentSubAccount(client).walkStyle, true);
|
||||||
|
|
||||||
@@ -566,7 +577,7 @@ function onPlayerSpawn(client) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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)) {
|
if (getServerConfig().showLogo && doesPlayerHaveLogoEnabled(client)) {
|
||||||
updatePlayerShowLogoState(client, true);
|
updatePlayerShowLogoState(client, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -579,7 +590,7 @@ function onPlayerSpawn(client) {
|
|||||||
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s switchchar state to false`);
|
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s switchchar state to false`);
|
||||||
getPlayerData(client).switchingCharacter = false;
|
getPlayerData(client).switchingCharacter = false;
|
||||||
|
|
||||||
if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "enter")) {
|
if (!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "enter")) {
|
||||||
let keyId = getPlayerKeyBindForCommand(client, "enter");
|
let keyId = getPlayerKeyBindForCommand(client, "enter");
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Event] Sending custom enter property key ID (${keyId.key}, ${toUpperCase(getKeyNameFromId(keyId.key))}) to ${getPlayerDisplayForConsole(client)}`);
|
logToConsole(LOG_DEBUG, `[VRR.Event] Sending custom enter property key ID (${keyId.key}, ${toUpperCase(getKeyNameFromId(keyId.key))}) to ${getPlayerDisplayForConsole(client)}`);
|
||||||
sendPlayerEnterPropertyKey(client, keyId.key);
|
sendPlayerEnterPropertyKey(client, keyId.key);
|
||||||
@@ -602,14 +613,14 @@ function onPlayerSpawn(client) {
|
|||||||
// setEntityData(getPlayerPed(client), "vrr.bodyPartRightFoot", getPlayerCurrentSubAccount(client).bodyProps.rightFoot, true);
|
// setEntityData(getPlayerPed(client), "vrr.bodyPartRightFoot", getPlayerCurrentSubAccount(client).bodyProps.rightFoot, true);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
if(isGTAIV()) {
|
if (isGTAIV()) {
|
||||||
//sendPlayerPedPartsAndProps(client);
|
//sendPlayerPedPartsAndProps(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped state to ready`);
|
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped state to ready`);
|
||||||
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
|
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
|
||||||
|
|
||||||
if(areServerElementsSupported()) {
|
if (areServerElementsSupported()) {
|
||||||
syncPlayerProperties(client);
|
syncPlayerProperties(client);
|
||||||
//setTimeout(function() {
|
//setTimeout(function() {
|
||||||
// syncPlayerProperties(client);
|
// syncPlayerProperties(client);
|
||||||
@@ -625,7 +636,7 @@ function onPlayerSpawn(client) {
|
|||||||
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);
|
||||||
sendAllHousesToPlayer(client);
|
sendAllHousesToPlayer(client);
|
||||||
//sendAllJobsToPlayer(client);
|
//sendAllJobsToPlayer(client);
|
||||||
@@ -638,29 +649,33 @@ function onPlayerSpawn(client) {
|
|||||||
|
|
||||||
getPlayerData(client).payDayTickStart = sdl.ticks;
|
getPlayerData(client).payDayTickStart = sdl.ticks;
|
||||||
|
|
||||||
|
sendPlayerLocaleStrings(client);
|
||||||
|
|
||||||
// Stop playing intro music and any other radio
|
// Stop playing intro music and any other radio
|
||||||
stopRadioStreamForPlayer(client);
|
stopRadioStreamForPlayer(client);
|
||||||
|
|
||||||
// Start playing business/house radio if in one
|
// Start playing business/house radio if in one
|
||||||
let businessId = getPlayerBusiness(client);
|
let businessId = getPlayerBusiness(client);
|
||||||
let houseId = getPlayerHouse(client);
|
let houseId = getPlayerHouse(client);
|
||||||
if(businessId != -1) {
|
if (businessId != -1) {
|
||||||
if(getBusinessData(businessId).streamingRadioStation != -1) {
|
if (getBusinessData(businessId).streamingRadioStation != -1) {
|
||||||
playRadioStreamForPlayer(client, getRadioStationData(getBusinessData(businessId).streamingRadioStation).url, true, getPlayerStreamingRadioVolume(client), null);
|
playRadioStreamForPlayer(client, getRadioStationData(getBusinessData(businessId).streamingRadioStation).url, true, getPlayerStreamingRadioVolume(client), null);
|
||||||
}
|
}
|
||||||
} else if(houseId != -1) {
|
} else if (houseId != -1) {
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resetPlayerBlip(client)
|
||||||
|
|
||||||
messageDiscordEventChannel(`🧍 ${getPlayerName(client)} spawned as ${getCharacterFullName(client)}`);
|
messageDiscordEventChannel(`🧍 ${getPlayerName(client)} spawned as ${getCharacterFullName(client)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function onPlayerCommand(event, client, command, params) {
|
function onPlayerCommand(event, client, command, params) {
|
||||||
if(!doesCommandExist(command)) {
|
if (!doesCommandExist(command)) {
|
||||||
processPlayerCommand(command, params, client);
|
processPlayerCommand(command, params, client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user