Merge branch 'nightly' into ragemp

This commit is contained in:
Vortrex
2022-05-31 08:35:59 -05:00
17 changed files with 207 additions and 66 deletions

View File

@@ -1169,28 +1169,41 @@ function savePlayerToDatabase(client) {
// ===========================================================================
function initClient(client) {
logToConsole(LOG_DEBUG, `[VRR.Account] Initializing client ${getPlayerDisplayForConsole(client)} ...`);
if(isConsole(client)) {
logToConsole(LOG_DEBUG|LOG_ERROR, `[VRR.Account] Client initialization failed for ${getPlayerDisplayForConsole(client)}! (is console client)`);
return false;
}
if(doesEntityDataExist(client, "vrr.isInitialized") || getEntityData(client, "vrr.isInitialized") == true) {
logToConsole(LOG_DEBUG, `[VRR.Account] Initializing client ${getPlayerDisplayForConsole(client)} ...`);
if(playerInitialized[client.index] == true) {
logToConsole(LOG_DEBUG|LOG_ERROR, `[VRR.Account] Client initialization failed for ${getPlayerDisplayForConsole(client)}! (already initialized)`);
return false;
}
setEntityData(client, "vrr.isInitialized", true, false);
sendPlayerGUIColours(client);
logToConsole(LOG_DEBUG, `[VRR.Account] Initializing GUI for ${getPlayerDisplayForConsole(client)} ...`);
sendPlayerGUIInit(client);
updatePlayerSnowState(client);
logToConsole(LOG_DEBUG, `[VRR.Account] Showing connect camera to ${getPlayerDisplayForConsole(client)} ...`);
showConnectCameraToPlayer(client);
messageClient(`Please wait ...`, client, getColourByName("softGreen"));
logToConsole(LOG_DEBUG, `[VRR.Account] Waiting for 2.5 seconds to prevent race attack ...`);
setTimeout(function() {
if(client != null) {
clearChatBox(client);
logToConsole(LOG_DEBUG, `[VRR.Account] Loading account for ${getPlayerDisplayForConsole(client)}`);
let tempAccountData = loadAccountFromName(getPlayerName(client), true);
logToConsole(LOG_DEBUG, `[VRR.Account] Loading subaccounts for ${getPlayerDisplayForConsole(client)}`);
let tempSubAccounts = loadSubAccountsFromAccount(tempAccountData.databaseId);
getServerData().clients[getPlayerId(client)] = new ClientData(client, tempAccountData, tempSubAccounts);

View File

@@ -732,11 +732,12 @@ function getBusinessInfoCommand(command, params, client) {
break;
case VRR_BIZOWNER_NONE:
submitBugReport(client, `[AUTOMATED REPORT] getBusinessInfoCommand() - Invalid ownerType for business ${businessId}/${getBusinessData(businessId).databaseId}`);
ownerName = "INVALID";
//submitBugReport(client, `[AUTOMATED REPORT] getBusinessInfoCommand() - Invalid ownerType for business ${businessId}/${getBusinessData(businessId).databaseId}`);
ownerName = "None";
break;
default:
submitBugReport(client, `[AUTOMATED REPORT] getBusinessInfoCommand() - Invalid ownerType ${businessData.ownerType} for business ${businessId}/${getBusinessData(businessId).databaseId}`);
ownerName = "None";
break;
}

View File

@@ -18,22 +18,22 @@ function initChatScript() {
function processPlayerChat(client, messageText) {
if(!isConsole(client)) {
if(!getPlayerData(client)) {
messagePlayerError(client, "You need to login before you can chat!");
messagePlayerError(client, getLocaleString(client, "MustBeLoggedInAndSpawnedToChat"));
return false;
}
if(!isPlayerLoggedIn(client)) {
messagePlayerError(client, "You need to login before you can chat!");
messagePlayerError(client, getLocaleString(client, "MustBeLoggedInAndSpawnedToChat"));
return false;
}
if(!isPlayerSpawned(client)) {
messagePlayerError(client, "You need to spawn before you can chat!");
messagePlayerError(client, getLocaleString(client, "MustBeLoggedInAndSpawnedToChat"));
return false;
}
if(isPlayerMuted(client)) {
messagePlayerError(client, "You are muted and can't chat!");
messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
return false;
}
@@ -74,7 +74,7 @@ function meActionCommand(command, params, client) {
function doActionCommand(command, params, client) {
if(isPlayerMuted(client)) {
messagePlayerError(client, "You are muted and can't chat!");
messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
return false;
}
@@ -91,7 +91,7 @@ function doActionCommand(command, params, client) {
function shoutCommand(command, params, client) {
if(isPlayerMuted(client)) {
messagePlayerError(client, "You are muted and can't chat!");
messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
return false;
}
@@ -108,7 +108,7 @@ function shoutCommand(command, params, client) {
function megaphoneChatCommand(command, params, client) {
if(isPlayerMuted(client)) {
messagePlayerError(client, "You are muted and can't chat!");
messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
return false;
}
@@ -118,7 +118,7 @@ function megaphoneChatCommand(command, params, client) {
}
if(!canPlayerUseMegaphone(client)) {
messagePlayerError(client, "You must have a megaphone item or be in an emergency vehicle!");
messagePlayerError(client, getLocaleString(client, "CantUseMegaphone"));
return false;
}
@@ -130,7 +130,7 @@ function megaphoneChatCommand(command, params, client) {
function talkCommand(command, params, client) {
if(isPlayerMuted(client)) {
messagePlayerError(client, "You are muted and can't chat!");
messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
return false;
}
@@ -147,7 +147,7 @@ function talkCommand(command, params, client) {
function whisperCommand(command, params, client) {
if(isPlayerMuted(client)) {
messagePlayerError(client, "You are muted and can't chat!");
messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
return false;
}
@@ -164,7 +164,7 @@ function whisperCommand(command, params, client) {
function adminChatCommand(command, params, client) {
if(isPlayerMuted(client)) {
messagePlayerError(client, "You are muted and can't chat!");
messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
return false;
}
@@ -180,7 +180,7 @@ function adminChatCommand(command, params, client) {
function clanChatCommand(command, params, client) {
if(isPlayerMuted(client)) {
messagePlayerError(client, "You are muted and can't chat!");
messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
return false;
}

View File

@@ -107,9 +107,9 @@ function updatePlayerPing(client) {
// ===========================================================================
function playerClientReady(client) {
setEntityData(client, "vrr.isReady", true, false);
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s client resources are downloaded and ready!`);
if(getEntityData(client, "vrr.isStarted") == true) {
playerResourceReady[client.index] = true;
logToConsole(LOG_DEBUG, `[VRR.Client] ${getPlayerDisplayForConsole(client)}'s client resources are downloaded and ready! Started: ${getYesNoFromBool(playerResourceStarted[client.index])}`);
if(playerResourceStarted[client.index] == true) {
initClient(client);
}
}
@@ -117,16 +117,16 @@ function playerClientReady(client) {
// ===========================================================================
function playerGUIReady(client) {
setEntityData(client, "vrr.guiReady", true, false);
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s client GUI is initialized and ready!`);
playerGUI[client.index] = true;
logToConsole(LOG_DEBUG, `[VRR.Client] ${getPlayerDisplayForConsole(client)}'s client GUI is initialized and ready!`);
}
// ===========================================================================
function playerClientStarted(client) {
setEntityData(client, "vrr.isStarted", true, false);
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s client resources are started and running!`);
if(getEntityData(client, "vrr.isReady") == true) {
playerResourceStarted[client.index] = true;
logToConsole(LOG_DEBUG, `[VRR.Client] ${getPlayerDisplayForConsole(client)}'s client resources are started and running! Ready: ${getYesNoFromBool(playerResourceReady[client.index])}`);
if(playerResourceReady[client.index] == true) {
initClient(client);
}
}
@@ -134,7 +134,7 @@ function playerClientStarted(client) {
// ===========================================================================
function playerClientStopped(client) {
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s client resources have stopped (possibly error?). Kicking them from the server ...`);
logToConsole(LOG_DEBUG, `[VRR.Client] ${getPlayerDisplayForConsole(client)}'s client resources have stopped (possibly error?). Kicking them from the server ...`);
disconnectPlayer(client);
}
@@ -1100,6 +1100,18 @@ function sendHouseToPlayer(client, houseId, description, entrancePosition, blipM
// ==========================================================================
function sendJobToPlayer(client, jobId, jobLocationId, name, position) {
sendNetworkEventToPlayer("vrr.job", client, jobId, jobLocationId, name, position);
}
// ==========================================================================
function sendVehicleToPlayer(client, vehicleId, model, position, heading, colour1, colour2, colour3, colour4) {
sendNetworkEventToPlayer("vrr.vehicle", client, vehicleId, model, position, heading, colour1, colour2, colour3, colour4);
}
// ==========================================================================
function sendAllBusinessesToPlayer(client) {
let businesses = getServerData().businesses;
for(let i in businesses) {
@@ -1119,12 +1131,21 @@ function sendAllHousesToPlayer(client) {
// ==========================================================================
function sendAllJobsToPlayer(client) {
//let jobs = getServerData().jobs;
//for(let i in jobs) {
// for(let j in jobs[i].locations) {
// sendJobToPlayer(client, jobs[i].index, jobs[i].name, jobs[i].locations[j].position, jobs[i].blipModel);
// }
//}
let jobs = getServerData().jobs;
for(let i in jobs) {
for(let j in jobs[i].locations) {
sendJobToPlayer(client, jobs[i].index, jobs[i].locations[j].index, jobs[i].name, jobs[i].locations[j].position, jobs[i].blipModel);
}
}
}
// ==========================================================================
function sendAllVehiclesToPlayer(client) {
let vehicles = getServerData().vehicles;
for(let i in vehicles) {
sendVehicleToPlayer(client, vehicles[i].index, vehicles[i].model, vehicles[i].syncPosition, vehicles[i].syncHeading, vehicles[i].colour1, vehicles[i].colour2, vehicles[i].colour3, vehicles[i].colour4);
}
}
// ==========================================================================

View File

@@ -11,6 +11,11 @@ let scriptVersion = "1.1";
let serverStartTime = 0;
let logLevel = LOG_INFO|LOG_DEBUG|LOG_VERBOSE; // LOG_ERROR|LOG_WARN;
let playerResourceReady = new Array(server.maxClients).fill(false);
let playerResourceStarted = new Array(server.maxClients).fill(false);
let playerInitialized = new Array(server.maxClients).fill(false);
let playerGUI = new Array(server.maxClients).fill(false);
// ===========================================================================
/**

View File

@@ -126,6 +126,11 @@ function onPlayerQuit(event, client, quitReasonId) {
resetClientStuff(client);
getServerData().clients[getPlayerId(client)] = null;
}
playerResourceReady[client.index] = false;
playerResourceStarted[client.index] = false;
playerInitialized[client.index] = false;
playerGUIReady[client.index] = false;
}
// ===========================================================================
@@ -623,7 +628,7 @@ function onPlayerSpawn(client) {
if(!areServerElementsSupported()) {
sendAllBusinessesToPlayer(client);
sendAllHousesToPlayer(client);
sendAllJobsToPlayer(client);
//sendAllJobsToPlayer(client);
//sendAllVehiclesToPlayer(client);
requestPlayerPedNetworkId(client);
}

View File

@@ -659,20 +659,22 @@ function getClosestHouseExit(position, dimension) {
// ===========================================================================
function getPlayerHouse(client) {
if(getPlayerDimension(client) == getGameConfig().mainWorldDimension[getGame()]) {
let closestEntrance = getClosestHouseEntrance(getPlayerPosition(client), getPlayerDimension(client));
if(getDistance(getPlayerPosition(client), getHouseData(closestEntrance).entrancePosition) <= getGlobalConfig().enterPropertyDistance) {
return getHouseData(closestEntrance).index;
}
} else {
let closestEntrance = getClosestHouseEntrance(getPlayerPosition(client), getPlayerDimension(client));
if(getDistance(getPlayerPosition(client), getHouseData(closestEntrance).entrancePosition) <= getGlobalConfig().enterPropertyDistance) {
return getHouseData(closestEntrance).index;
}
if(getServerData().houses.length > 0) {
if(getPlayerDimension(client) == getGameConfig().mainWorldDimension[getGame()]) {
let closestEntrance = getClosestHouseEntrance(getPlayerPosition(client), getPlayerDimension(client));
if(getDistance(getPlayerPosition(client), getHouseData(closestEntrance).entrancePosition) <= getGlobalConfig().enterPropertyDistance) {
return getHouseData(closestEntrance).index;
}
} else {
let closestEntrance = getClosestHouseEntrance(getPlayerPosition(client), getPlayerDimension(client));
if(getDistance(getPlayerPosition(client), getHouseData(closestEntrance).entrancePosition) <= getGlobalConfig().enterPropertyDistance) {
return getHouseData(closestEntrance).index;
}
for(let i in getServerData().houses) {
if(getServerData().houses[i].hasInterior && getServerData().houses[i].exitDimension == getPlayerDimension(client)) {
return i;
for(let i in getServerData().houses) {
if(getServerData().houses[i].hasInterior && getServerData().houses[i].exitDimension == getPlayerDimension(client)) {
return i;
}
}
}
}

View File

@@ -1008,7 +1008,7 @@ function playerUseItem(client, hotBarSlot) {
let clients = getClients();
for(let i in clients) {
if(getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= 7) {
makeChatBoxSectionHeader(clients[i], getLocaleString(client, "Badge", getCharacterFullName(client)));
makeChatBoxSectionHeader(clients[i], getLocaleString(client, "HeaderBadgeInfo", getCharacterFullName(client)));
messagePlayerNormal(client, `{clanOrange}Type:{MAINCOLOUR} ${getJobData(getPlayerJob(client)).name}`);
messagePlayerNormal(client, `{clanOrange}ID:{MAINCOLOUR} ${addPrefixNumberFill(getPlayerCurrentSubAccount(client).databaseId, 5)}`);
messagePlayerNormal(client, `{clanOrange}Rank:{MAINCOLOUR} ${getJobRankName(getPlayerJob(client), getPlayerJobRank(client))}`);

View File

@@ -641,9 +641,10 @@ function stopWorking(client) {
restorePlayerJobLockerItems(client);
respawnJobVehicle(client);
sendPlayerStopJobRoute(client);
messageDiscordEventChannel(`💼 ${getPlayerName(client)} has stopped working as a ${getJobData(jobId).name}`);
let jobId = getPlayerJob(client);
messageDiscordEventChannel(`💼 ${getPlayerName(client)} has stopped working as a ${getJobData(jobId).name}`);
switch(getJobType(jobId)) {
case VRR_JOB_POLICE:
messagePlayerInfo(client, "Your uniform, equipment, and vehicle have been returned to the police station");

View File

@@ -46,8 +46,6 @@ function addKeyBindCommand(command, params, client) {
// ===========================================================================
function removeKeyBindCommand(command, params, client) {
let splitParams = params.split(" ");
let keyId = getKeyIdFromParams(getParam(params, " ", 1));
if(!keyId) {

View File

@@ -61,12 +61,30 @@ function getGroupedLocaleString(client, stringName, index, ...args) {
function getRawLocaleString(stringName, localeId) {
return getLocaleStrings()[localeId][stringName];
//if(findResourceByName("agrp_locale").exports.doesLocaleStringExist(localeId, stringName) == false) {
// return "";
//}
//let tempString = findResourceByName("agrp_locale").exports.getRawLocaleString(localeId, stringName);
//if(tempString == "" || tempString == null || tempString == undefined) {
// return "";
//}
}
// ===========================================================================
function getRawGroupedLocaleString(stringName, localeId, index) {
return getLocaleStrings()[localeId][stringName][index];
//if(findResourceByName("agrp_locale").exports.doesLocaleStringExist(localeId, stringName) == false) {
// return "";
//}
//let tempString = findResourceByName("agrp_locale").exports.getRawLocaleString(localeId, stringName);
//if(tempString == "" || tempString == null || tempString == undefined) {
// return "";
//}
}
// ===========================================================================

View File

@@ -461,9 +461,13 @@ function getNPCInfoCommand(command, params, client) {
function getClosestNPC(position) {
let npcs = getServerData().npcs;
let interior = getPlayerInterior(client);
let dimension = getPlayerDimension(client);
let closest = 0;
for(let i in npcs) {
if(getDistance(npcs[i].ped.position, position) < getDistance(npcs[closest].ped.position, position)) {
if(getDistance(npcs[i].ped.position, position) < getDistance(npcs[closest].ped.position, position) && npcs[closest].interior == interior && npcs[closest].dimension == dimension) {
closest = i;
}
}