Rename some utils to align with code style

This commit is contained in:
Vortrex
2022-04-23 15:13:34 -05:00
parent b355c2093f
commit 56bae04e0f
5 changed files with 44 additions and 27 deletions

View File

@@ -868,7 +868,7 @@ function createClan(name) {
// =========================================================================== // ===========================================================================
function deleteClan(clanId) { function deleteClan(clanId) {
saveClansToDatabase(); //saveAllClansToDatabase();
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
if(dbConnection) { if(dbConnection) {
@@ -1081,7 +1081,7 @@ function setClanRankTitle(clanId, rankId, title) {
// =========================================================================== // ===========================================================================
function saveClansToDatabase() { function saveAllClansToDatabase() {
if(getServerConfig().devServer) { if(getServerConfig().devServer) {
return false; return false;
} }

View File

@@ -60,7 +60,13 @@ function onPlayerJoin(event, client) {
fadeCamera(client, true, 1.0); fadeCamera(client, true, 1.0);
} }
messageDiscordEventChannel(`👋 ${getPlayerName(client)} is connecting to the server ...`); let messageText = `👋 ${getPlayerName(client)} is connecting to the server ...`;
messageDiscordEventChannel(messageText);
for(let i in clients) {
messagePlayerNormal(clients[i], getLocaleString(clients[i], "PlayerConnecting"));
}
//messageDiscordEventChannel(`👋 ${getPlayerDisplayForConsole(client)} has joined the server.`); //messageDiscordEventChannel(`👋 ${getPlayerDisplayForConsole(client)} has joined the server.`);
} }
@@ -97,19 +103,18 @@ function onPlayerQuit(event, client, quitReasonId) {
logToConsole(LOG_INFO, `👋 Client ${getPlayerDisplayForConsole(client)} disconnected (${disconnectReasons[quitReasonId]}[${quitReasonId}])`); logToConsole(LOG_INFO, `👋 Client ${getPlayerDisplayForConsole(client)} disconnected (${disconnectReasons[quitReasonId]}[${quitReasonId}])`);
updateConnectionLogOnQuit(client, quitReasonId); updateConnectionLogOnQuit(client, quitReasonId);
let reasonText = disconnectReasons[quitReasonId];
if(getPlayerData(client).customDisconnectReason != "") {
reasonText = getPlayerData(client).customDisconnectReason;
}
messageDiscordEventChannel(`👋 ${getPlayerName(client)} has left the server (${reasonText})`);
messagePlayerNormal(null, `👋 ${getPlayerName(client)} has left the server (${reasonText})`, getColourByName("softYellow"));
if(isPlayerLoggedIn(client)) { if(isPlayerLoggedIn(client)) {
let reasonText = disconnectReasons[quitReasonId];
if(getPlayerData(client).customDisconnectReason != "") {
reasonText = getPlayerData(client).customDisconnectReason;
}
messagePlayerNormal(null, `👋 ${getPlayerName(client)} has left the server (${reasonText})`, getColourByName("softYellow"));
messageDiscordEventChannel(`👋 ${getPlayerName(client)} has left the server (${reasonText})`);
savePlayerToDatabase(client); savePlayerToDatabase(client);
resetClientStuff(client); resetClientStuff(client);
getServerData().clients[getPlayerId(client)] = null; getServerData().clients[getPlayerId(client)] = null;
} else {
messageDiscordEventChannel(`👋 ${getPlayerName(client)} has left the server (${disconnectReasons[quitReasonId]}[${quitReasonId}])`);
} }
clearTemporaryVehicles(); clearTemporaryVehicles();

View File

@@ -1676,7 +1676,7 @@ function getItemTypeData(itemTypeId) {
// =========================================================================== // ===========================================================================
function saveItemsToDatabase() { function saveAllItemsToDatabase() {
if(getServerConfig().devServer) { if(getServerConfig().devServer) {
return false; return false;
} }
@@ -1688,7 +1688,7 @@ function saveItemsToDatabase() {
// =========================================================================== // ===========================================================================
function saveItemTypesToDatabase() { function saveAllItemTypesToDatabase() {
if(getServerConfig().devServer) { if(getServerConfig().devServer) {
return false; return false;
} }

View File

@@ -147,7 +147,7 @@ function loadNPCTriggerResponsesFromDatabase(npcTriggerDatabaseId) {
// =========================================================================== // ===========================================================================
function saveNPCsToDatabase() { function saveAllNPCsToDatabase() {
if(getServerConfig().devServer) { if(getServerConfig().devServer) {
return false; return false;
} }
@@ -183,11 +183,11 @@ function saveNPCToDatabase(npcDataId) {
if(tempNPCData.ped != false) { if(tempNPCData.ped != false) {
if(!tempNPCData.spawnLocked) { if(!tempNPCData.spawnLocked) {
if(areServerElementsSupported()) { if(areServerElementsSupported()) {
tempNPCData.spawnPosition = tempNPCData.vehicle.position; tempNPCData.position = tempNPCData.ped.position;
tempNPCData.spawnRotation = tempNPCData.vehicle.heading; tempNPCData.heading = tempNPCData.ped.heading;
} else { } else {
tempNPCData.spawnPosition = tempNPCData.syncPosition; tempNPCData.position = tempNPCData.syncPosition;
tempNPCData.spawnRotation = tempNPCData.syncHeading; tempNPCData.heading = tempNPCData.syncHeading;
} }
} }
} }

View File

@@ -19,53 +19,65 @@ function saveServerDataToDatabase() {
logToConsole(LOG_DEBUG, "[VRR.Utilities]: Saving all server data to database ..."); logToConsole(LOG_DEBUG, "[VRR.Utilities]: Saving all server data to database ...");
try { try {
saveClientsToDatabase(); saveAllPlayersToDatabase();
} catch(error) { } catch(error) {
logToConsole(LOG_ERROR, `Could not save clients to database: ${error}`); logToConsole(LOG_ERROR, `Could not save players to database: ${error}`);
} }
try { try {
saveClansToDatabase(); saveAllClansToDatabase();
} catch(error) { } catch(error) {
logToConsole(LOG_ERROR, `Could not save clans to database: ${error}`); logToConsole(LOG_ERROR, `Could not save clans to database: ${error}`);
} }
try { try {
saveHousesToDatabase(); saveAllHousesToDatabase();
} catch(error) { } catch(error) {
logToConsole(LOG_ERROR, `Could not save houses to database: ${error}`); logToConsole(LOG_ERROR, `Could not save houses to database: ${error}`);
} }
try { try {
saveBusinessesToDatabase(); saveAllBusinessesToDatabase();
} catch(error) { } catch(error) {
logToConsole(LOG_ERROR, `Could not save businesses to database: ${error}`); logToConsole(LOG_ERROR, `Could not save businesses to database: ${error}`);
} }
try { try {
saveVehiclesToDatabase(); saveAllVehiclesToDatabase();
} catch(error) { } catch(error) {
logToConsole(LOG_ERROR, `Could not save vehicles to database: ${error}`); logToConsole(LOG_ERROR, `Could not save vehicles to database: ${error}`);
} }
try { try {
saveItemTypesToDatabase(); saveAllItemTypesToDatabase();
} catch(error) { } catch(error) {
logToConsole(LOG_ERROR, `Could not save item types to database: ${error}`); logToConsole(LOG_ERROR, `Could not save item types to database: ${error}`);
} }
try { try {
saveItemsToDatabase(); saveAllItemsToDatabase();
} catch(error) { } catch(error) {
logToConsole(LOG_ERROR, `Could not save items to database: ${error}`); logToConsole(LOG_ERROR, `Could not save items to database: ${error}`);
} }
try { try {
saveJobsToDatabase(); saveAllJobsToDatabase();
} catch(error) { } catch(error) {
logToConsole(LOG_ERROR, `Could not save jobs to database: ${error}`); logToConsole(LOG_ERROR, `Could not save jobs to database: ${error}`);
} }
try {
saveAllNPCsToDatabase();
} catch(error) {
logToConsole(LOG_ERROR, `Could not save NPCs to database: ${error}`);
}
try {
saveAllGatesToDatabase();
} catch(error) {
logToConsole(LOG_ERROR, `Could not save gates to database: ${error}`);
}
try { try {
saveServerConfigToDatabase(); saveServerConfigToDatabase();
} catch(error) { } catch(error) {