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) {
saveClansToDatabase();
//saveAllClansToDatabase();
let dbConnection = connectToDatabase();
if(dbConnection) {
@@ -1081,7 +1081,7 @@ function setClanRankTitle(clanId, rankId, title) {
// ===========================================================================
function saveClansToDatabase() {
function saveAllClansToDatabase() {
if(getServerConfig().devServer) {
return false;
}

View File

@@ -60,7 +60,13 @@ function onPlayerJoin(event, client) {
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.`);
}
@@ -97,19 +103,18 @@ function onPlayerQuit(event, client, quitReasonId) {
logToConsole(LOG_INFO, `👋 Client ${getPlayerDisplayForConsole(client)} disconnected (${disconnectReasons[quitReasonId]}[${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)) {
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);
resetClientStuff(client);
getServerData().clients[getPlayerId(client)] = null;
} else {
messageDiscordEventChannel(`👋 ${getPlayerName(client)} has left the server (${disconnectReasons[quitReasonId]}[${quitReasonId}])`);
}
clearTemporaryVehicles();

View File

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

View File

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

View File

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