Use new logging util

This commit is contained in:
Vortrex
2021-01-08 00:15:10 -06:00
parent 3ef9e554cc
commit e3f5e5ea02
23 changed files with 251 additions and 236 deletions

View File

@@ -9,8 +9,8 @@
// ===========================================================================
function initAccountScript() {
console.log("[Asshat.Account]: Initializing account script ...");
console.log("[Asshat.Account]: Account script initialized!");
logToConsole(LOG_DEBUG, "[Asshat.Account]: Initializing account script ...");
logToConsole(LOG_DEBUG, "[Asshat.Account]: Account script initialized!");
}
// ---------------------------------------------------------------------------
@@ -68,29 +68,29 @@ function toggleAccountGUICommand(command, params, client) {
if(!doesPlayerHaveGUIEnabled(client)) {
getPlayerData(client).accountData.settings = getPlayerData(client).accountData.settings & ~flagValue;
messagePlayerNormal(client, `⚙️ You will now be shown GUI (if enabled on current server)`);
console.log(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} has toggled GUI for their account ON.`);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} has toggled GUI for their account ON.`);
} else {
getPlayerData(client).accountData.settings = getPlayerData(client).accountData.settings | flagValue;
messagePlayerNormal(client, `⚙️ You will not be shown GUI anymore. Any GUI stuff will be shown as messages in the chatbox instead.`);
console.log(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} has toggled GUI for their account OFF.`);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} has toggled GUI for their account OFF.`);
}
if(!isPlayerLoggedIn(client)) {
if(getPlayerData().accountData.databaseId != 0) {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
showPlayerLoginGUI(client);
console.log(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI`);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI`);
} else {
messageClient(`👋 Welcome back to Asshat Gaming RP, ${client.name}! Please /login to continue.`, client, getColourByName("softGreen"));
console.log(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled)`);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled)`);
}
} else {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
showPlayerRegistrationGUI(client);
console.log(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the register GUI`);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the register GUI`);
} else {
messageClient(`👋 Welcome to Asshat Gaming RP, ${client.name}! Please /register to continue.`, client, getColourByName("softGreen"));
console.log(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the register message (GUI disabled)`);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the register message (GUI disabled)`);
}
}
}
@@ -105,13 +105,13 @@ function toggleAccountServerLogoCommand(command, params, client) {
if(!doesPlayerHaveLogoEnabled(client)) {
getPlayerData(client).accountData.settings = getPlayerData(client).accountData.settings & ~flagValue;
messagePlayerNormal(client, `⚙️ You will ${getBoolRedGreenInlineColour(true)}now [#FFFFFF]be shown the server logo (if enabled on current server)`);
console.log(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} has toggled the server logo ON for their account`);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} has toggled the server logo ON for their account`);
updatePlayerShowLogoState(client);
updatePlayerShowLogoState(client, false);
} else {
getPlayerData(client).accountData.settings = getPlayerData(client).accountData.settings | flagValue;
messagePlayerNormal(client, `⚙️ You will ${getBoolRedGreenInlineColour(false)}not [#FFFFFF]be shown the server logo.`);
console.log(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} has toggled the server logo OFF for their account`);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} has toggled the server logo OFF for their account`);
updatePlayerShowLogoState(client, false);
}
@@ -140,11 +140,11 @@ function toggleAccountTwoFactorAuthCommand(command, params, client) {
if(!doesPlayerHaveTwoFactorAuthEnabled(client)) {
getPlayerData(client).accountData.settings = getPlayerData(client).accountData.settings & ~flagValue;
messagePlayerSuccess(client, `[#FFFFFF]Use this code to add your account into your authenticator app: [#AAAAAA]${addtoAuthenticatorCode}`);
console.log(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} has toggled two-factor authentication ON for their account`);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} has toggled two-factor authentication ON for their account`);
} else {
getPlayerData(client).accountData.settings = getPlayerData(client).accountData.settings | flagValue;
messagePlayerSuccess(client, `You have turned ${getBoolRedGreenInlineColour(false)}OFF [#FFFFFF]two-factor authentication for login.`);
console.log(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} has toggled two-factor authentication OFF for their account`);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} has toggled two-factor authentication OFF for their account`);
}
return true;
}
@@ -411,7 +411,7 @@ function saltAccountInfo(name, password) {
// ---------------------------------------------------------------------------
function loginSuccess(client) {
console.log(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} successfully logged in.`);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} successfully logged in.`);
getPlayerData(client).loggedIn = true;
if(doesPlayerHaveStaffPermission(client, "developer") || doesPlayerHaveStaffPermission(client, "manageServer")) {
@@ -423,10 +423,10 @@ function loginSuccess(client) {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
triggerNetworkEvent("ag.showPrompt", client, "You have no characters. Would you like to make one?", "No characters");
setEntityData(client, "ag.prompt", AG_PROMPT_CREATEFIRSTCHAR, false);
console.log(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the no characters prompt GUI`);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the no characters prompt GUI`);
} else {
messagePlayerAlert(client, `You have no characters. Use /newchar to make one.`);
console.log(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the no characters message (GUI disabled)`);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the no characters message (GUI disabled)`);
}
} else {
showCharacterSelectToClient(client);
@@ -559,10 +559,10 @@ function checkLogin(client, password) {
console.warn(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} attempted to login but is not registered`);
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
triggerNetworkEvent("ag.showRegistration", client);
console.log(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the register GUI`);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the register GUI`);
} else {
messagePlayerError(client, "Your name is not registered! Use /register to make an account.");
console.log(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the register message (GUI disabled)`);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the register message (GUI disabled)`);
}
return false;
}
@@ -571,10 +571,10 @@ function checkLogin(client, password) {
console.warn(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} attempted to login but failed (empty password). ${loginAttemptsRemaining} login attempts remaining`);
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
triggerNetworkEvent("ag.loginFailed", client, `Invalid password! ${loginAttemptsRemaining} tries remaining.`);
console.log(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI with ${loginAttemptsRemaining} login attempts remaining alert.`);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI with ${loginAttemptsRemaining} login attempts remaining alert.`);
} else {
messagePlayerError(client, `You must enter a password! ${loginAttemptsRemaining} tries remaining.`);
console.log(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled) with ${loginAttemptsRemaining} login attempts remaining alert.`);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled) with ${loginAttemptsRemaining} login attempts remaining alert.`);
}
return false;
}
@@ -583,10 +583,10 @@ function checkLogin(client, password) {
console.warn(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} attempted to login but failed (wrong password). ${loginAttemptsRemaining} login attempts remaining`);
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
triggerNetworkEvent("ag.loginFailed", client, `Invalid password! ${loginAttemptsRemaining} tries remaining.`);
console.log(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI with ${loginAttemptsRemaining} login attempts remaining alert.`);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI with ${loginAttemptsRemaining} login attempts remaining alert.`);
} else {
messagePlayerError(client, `Invalid password! ${loginAttemptsRemaining} tries remaining.`);
console.log(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled) with ${loginAttemptsRemaining} login attempts remaining alert.`);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled) with ${loginAttemptsRemaining} login attempts remaining alert.`);
}
return false;
}
@@ -602,7 +602,7 @@ addNetworkHandler("ag.checkLogin", checkLogin);
// ---------------------------------------------------------------------------
function checkRegistration(client, password, confirmPassword = "", emailAddress = "") {
console.log("[Asshat.Account]: Checking registration for " + toString(client.name));
logToConsole(LOG_DEBUG, "[Asshat.Account]: Checking registration for " + toString(client.name));
if(isPlayerRegistered(client)) {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
@@ -706,11 +706,11 @@ function isValidEmailAddress(emailAddress) {
// ---------------------------------------------------------------------------
function saveAllClientsToDatabase() {
console.log("[Asshat.Account]: Saving all clients to database ...");
logToConsole(LOG_DEBUG, "[Asshat.Account]: Saving all clients to database ...");
getClients().forEach(function(client) {
savePlayerToDatabase(client);
});
console.log("[Asshat.Account]: All clients saved to database successfully!");
logToConsole(LOG_DEBUG, "[Asshat.Account]: All clients saved to database successfully!");
}
// ---------------------------------------------------------------------------
@@ -724,7 +724,7 @@ function savePlayerToDatabase(client) {
return false;
}
console.log(`[Asshat.Account]: Saving client ${client.name} to database ...`);
logToConsole(LOG_DEBUG, `[Asshat.Account]: Saving client ${client.name} to database ...`);
saveAccountToDatabase(getPlayerData(client).accountData);
if(getPlayerData(client).currentSubAccount != -1) {
@@ -739,7 +739,7 @@ function savePlayerToDatabase(client) {
saveSubAccountToDatabase(subAccountData);
}
console.log(`[Asshat.Account]: Saved client ${getPlayerDisplayForConsole(client)} to database successfully!`);
logToConsole(LOG_DEBUG, `[Asshat.Account]: Saved client ${getPlayerDisplayForConsole(client)} to database successfully!`);
return true;
}
@@ -776,19 +776,19 @@ function initClient(client) {
loginSuccess(client);
} else {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
console.log(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI.`);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI.`);
triggerNetworkEvent("ag.showLogin", client);
} else {
console.log(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled).`);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled).`);
messageClient(`Welcome back to Asshat Gaming RP, ${client.name}! Please /login to continue.`, client, getColourByName("softGreen"));
}
}
} else {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
console.log(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the register GUI.`);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the register GUI.`);
triggerNetworkEvent("ag.showRegistration", client);
} else {
console.log(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the register message (GUI disabled).`);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the register message (GUI disabled).`);
messageClient(`Welcome to Asshat Gaming RP, ${client.name}! Please /register to continue.`, client, getColourByName("softGreen"));
}
}
@@ -815,7 +815,7 @@ function createDefaultKeybindsForAccount(accountDatabaseId) {
// ---------------------------------------------------------------------------
function loadAccountKeybindsFromDatabase(accountDatabaseID) {
console.log(`[Asshat.Account]: Loading account keybinds for account ${accountDatabaseID} from database ...`);
logToConsole(LOG_DEBUG, `[Asshat.Account]: Loading account keybinds for account ${accountDatabaseID} from database ...`);
let tempAccountKeybinds = [];
let dbConnection = connectToDatabase();
@@ -829,7 +829,7 @@ function loadAccountKeybindsFromDatabase(accountDatabaseID) {
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
let tempAccountKeyBindData = new serverClasses.keyBindData(dbAssoc);
tempAccountKeybinds.push(tempAccountKeyBindData);
console.log(`[Asshat.Account]: Account keybind '${tempAccountKeyBindData.databaseId}' (Key ${tempAccountKeyBindData.key} '${sdl.getKeyName(tempAccountKeyBindData.key)}') loaded from database successfully!`);
logToConsole(LOG_DEBUG, `[Asshat.Account]: Account keybind '${tempAccountKeyBindData.databaseId}' (Key ${tempAccountKeyBindData.key} '${sdl.getKeyName(tempAccountKeyBindData.key)}') loaded from database successfully!`);
}
}
freeDatabaseQuery(dbQuery);
@@ -837,14 +837,14 @@ function loadAccountKeybindsFromDatabase(accountDatabaseID) {
disconnectFromDatabase(dbConnection);
}
console.log(`[Asshat.Account]: ${tempAccountKeybinds.length} account keybinds for account ${accountDatabaseID} loaded from database successfully!`);
logToConsole(LOG_DEBUG, `[Asshat.Account]: ${tempAccountKeybinds.length} account keybinds for account ${accountDatabaseID} loaded from database successfully!`);
return tempAccountKeybinds;
}
// ---------------------------------------------------------------------------
function loadAccountStaffNotesFromDatabase(accountDatabaseID) {
console.log(`[Asshat.Account]: Loading account staff notes for account ${accountDatabaseID} from database ...`);
logToConsole(LOG_DEBUG, `[Asshat.Account]: Loading account staff notes for account ${accountDatabaseID} from database ...`);
let tempAccountStaffNotes = [];
let dbConnection = connectToDatabase();
@@ -858,7 +858,7 @@ function loadAccountStaffNotesFromDatabase(accountDatabaseID) {
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
let tempAccountStaffNoteData = new serverClasses.accountStaffNoteData(dbAssoc);
tempAccountStaffNotes.push(tempAccountStaffNoteData);
console.log(`[Asshat.Account]: Account staff note '${tempAccountStaffNoteData.databaseId}' loaded from database successfully!`);
logToConsole(LOG_DEBUG, `[Asshat.Account]: Account staff note '${tempAccountStaffNoteData.databaseId}' loaded from database successfully!`);
}
}
freeDatabaseQuery(dbQuery);
@@ -866,14 +866,14 @@ function loadAccountStaffNotesFromDatabase(accountDatabaseID) {
disconnectFromDatabase(dbConnection);
}
console.log(`[Asshat.Account]: ${tempAccountStaffNotes.length} account staff notes for account ${accountDatabaseID} loaded from database successfully!`);
logToConsole(LOG_DEBUG, `[Asshat.Account]: ${tempAccountStaffNotes.length} account staff notes for account ${accountDatabaseID} loaded from database successfully!`);
return tempAccountStaffNotes;
}
// ---------------------------------------------------------------------------
function loadAccountContactsFromDatabase(accountDatabaseID) {
console.log(`[Asshat.Account]: Loading account contacts for account ${accountDatabaseID} from database ...`);
logToConsole(LOG_DEBUG, `[Asshat.Account]: Loading account contacts for account ${accountDatabaseID} from database ...`);
let tempAccountContacts = [];
let dbConnection = connectToDatabase();
@@ -887,7 +887,7 @@ function loadAccountContactsFromDatabase(accountDatabaseID) {
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
let tempAccountContactData = new serverClasses.accountContactData(dbAssoc);
tempAccountContacts.push(tempAccountContactData);
console.log(`[Asshat.Account]: Account contact '${tempAccountContactData.databaseId}' loaded from database successfully!`);
logToConsole(LOG_DEBUG, `[Asshat.Account]: Account contact '${tempAccountContactData.databaseId}' loaded from database successfully!`);
}
}
freeDatabaseQuery(dbQuery);
@@ -895,14 +895,14 @@ function loadAccountContactsFromDatabase(accountDatabaseID) {
disconnectFromDatabase(dbConnection);
}
console.log(`[Asshat.Account]: ${tempAccountContacts.length} account contacts for account ${accountDatabaseID} loaded from database successfully!`);
logToConsole(LOG_DEBUG, `[Asshat.Account]: ${tempAccountContacts.length} account contacts for account ${accountDatabaseID} loaded from database successfully!`);
return tempAccountContacts;
}
// ---------------------------------------------------------------------------
function loadAccountMessagesFromDatabase(accountDatabaseID) {
console.log(`[Asshat.Account]: Loading account messages for account ${accountDatabaseID} from database ...`);
logToConsole(LOG_DEBUG, `[Asshat.Account]: Loading account messages for account ${accountDatabaseID} from database ...`);
let tempAccountMessages = [];
let dbConnection = connectToDatabase();
@@ -916,7 +916,7 @@ function loadAccountMessagesFromDatabase(accountDatabaseID) {
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
let tempAccountMessageData = new serverClasses.accountContactData(dbAssoc);
tempAccountMessages.push(tempAccountMessageData);
console.log(`[Asshat.Account]: Account contact '${tempAccountMessageData.databaseId}' loaded from database successfully!`);
logToConsole(LOG_DEBUG, `[Asshat.Account]: Account contact '${tempAccountMessageData.databaseId}' loaded from database successfully!`);
}
}
freeDatabaseQuery(dbQuery);
@@ -924,7 +924,7 @@ function loadAccountMessagesFromDatabase(accountDatabaseID) {
disconnectFromDatabase(dbConnection);
}
console.log(`[Asshat.Account]: ${tempAccountMessages.length} account messages for account ${accountDatabaseID} loaded from database successfully!`);
logToConsole(LOG_DEBUG, `[Asshat.Account]: ${tempAccountMessages.length} account messages for account ${accountDatabaseID} loaded from database successfully!`);
return tempAccountMessages;
}

View File

@@ -9,15 +9,15 @@
// ===========================================================================
function initAntiCheatScript() {
console.log("[Asshat.AntiCheat]: Initializing anticheat script ...");
logToConsole(LOG_DEBUG, "[Asshat.AntiCheat]: Initializing anticheat script ...");
getServerData().antiCheat.whiteListedGameScripts = loadAntiCheatGameScriptWhiteListFromDatabase();
getServerData().antiCheat.blackListedGameScripts = loadAntiCheatGameScriptBlackListFromDatabase();
console.log("[Asshat.AntiCheat]: Anticheat script initialized!");
logToConsole(LOG_DEBUG, "[Asshat.AntiCheat]: Anticheat script initialized!");
}
// ---------------------------------------------------------------------------
function loadAntiCheatGameScriptWhiteListFromDatabase() {
console.log(`[Asshat.AntiCheat] Loading whitelisted game scripts ...`);
logToConsole(LOG_DEBUG, `[Asshat.AntiCheat] Loading whitelisted game scripts ...`);
let dbConnection = connectToDatabase();
let tempWhiteListedGameScripts = [];
@@ -29,19 +29,19 @@ function loadAntiCheatGameScriptWhiteListFromDatabase() {
let dbAssoc = fetchQueryAssoc(dbQuery);
let tempWhiteListedGameScriptData = new serverClasses.whiteListedGameScriptData(dbAssoc);
tempWhiteListedGameScripts.push(tempWhiteListedGameScriptData);
console.log(`[Asshat.AntiCheat] Whitelisted game script '${tempWhiteListedGameScriptData.scriptName}' loaded successfully!`);
logToConsole(LOG_DEBUG, `[Asshat.AntiCheat] Whitelisted game script '${tempWhiteListedGameScriptData.scriptName}' loaded successfully!`);
}
}
disconnectFromDatabase(dbConnection);
}
console.log(`[Asshat.AntiCheat] ${tempWhiteListedGameScripts.length} whitelisted game scripts loaded!`);
logToConsole(LOG_DEBUG, `[Asshat.AntiCheat] ${tempWhiteListedGameScripts.length} whitelisted game scripts loaded!`);
return tempWhiteListedGameScripts;
}
// ---------------------------------------------------------------------------
function loadAntiCheatGameScriptBlackListFromDatabase() {
console.log(`[Asshat.AntiCheat] Loading blacklisted game scripts ...`);
logToConsole(LOG_DEBUG, `[Asshat.AntiCheat] Loading blacklisted game scripts ...`);
let dbConnection = connectToDatabase();
let tempBlackListedGameScripts = [];
@@ -53,12 +53,12 @@ function loadAntiCheatGameScriptBlackListFromDatabase() {
let dbAssoc = fetchQueryAssoc(dbQuery);
let tempBlackListedGameScriptData = new serverClasses.blackListedGameScriptData(dbAssoc);
tempBlackListedGameScripts.push(tempBlackListedGameScriptData);
console.log(`[Asshat.AntiCheat] Blacklisted game script '${tempBlackListedGameScriptData.scriptName}' loaded successfully!`);
logToConsole(LOG_DEBUG, `[Asshat.AntiCheat] Blacklisted game script '${tempBlackListedGameScriptData.scriptName}' loaded successfully!`);
}
}
disconnectFromDatabase(dbConnection);
}
console.log(`[Asshat.AntiCheat] ${tempBlackListedGameScripts.length} blacklisted game scripts loaded!`);
logToConsole(LOG_DEBUG, `[Asshat.AntiCheat] ${tempBlackListedGameScripts.length} blacklisted game scripts loaded!`);
return tempBlackListedGameScripts;
}

View File

@@ -19,13 +19,13 @@ const banType = {
// ---------------------------------------------------------------------------
function initBanScript() {
console.log("[Asshat.Ban]: Initializing ban script ...");
console.log("[Asshat.Ban]: Ban script initialized!");
logToConsole(LOG_DEBUG, "[Asshat.Ban]: Initializing ban script ...");
logToConsole(LOG_DEBUG, "[Asshat.Ban]: Ban script initialized!");
}
// ---------------------------------------------------------------------------
function accountBanCommand(command, params, client, fromDiscord) {
function accountBanCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
@@ -39,7 +39,7 @@ function accountBanCommand(command, params, client, fromDiscord) {
messageAdminAction(`${getPlayerData(targetClient).accountData.name} has been banned from the server (account ban).`);
banAccount(getPlayerData(targetClient).accountData.databaseId, getPlayerData(client).accountData.databaseId, "");
targetClient.disconnect();
disconnectPlayer(client);
}
// ---------------------------------------------------------------------------
@@ -62,7 +62,7 @@ function subAccountBanCommand(command, params, client, fromDiscord) {
messageAdminAction(`${getPlayerData(targetClient).currentSubAccountData.name} has been banned from the server (character ban).`);
banSubAccount(getPlayerData(targetClient).currentSubAccountData.databaseId, getPlayerData(client).accountData.databaseId, reason);
targetClient.disconnect();
disconnectPlayer(client);
}
// ---------------------------------------------------------------------------

View File

@@ -9,12 +9,12 @@
// ===========================================================================
function initBusinessScript() {
console.log("[Asshat.Business]: Initializing business script ...");
logToConsole(LOG_DEBUG, "[Asshat.Business]: Initializing business script ...");
getServerData().businesses = loadBusinessesFromDatabase();
createAllBusinessPickups();
createAllBusinessBlips();
setAllBusinessIndexes();
console.log("[Asshat.Business]: Business script initialized successfully!");
logToConsole(LOG_DEBUG, "[Asshat.Business]: Business script initialized successfully!");
return true;
}
@@ -39,7 +39,7 @@ function loadBusinessFromId(businessId) {
// ---------------------------------------------------------------------------
function loadBusinessesFromDatabase() {
console.log("[Asshat.Business]: Loading businesses from database ...");
logToConsole(LOG_DEBUG, "[Asshat.Business]: Loading businesses from database ...");
let tempBusinesses = [];
let dbConnection = connectToDatabase();
@@ -54,7 +54,7 @@ function loadBusinessesFromDatabase() {
let tempBusinessData = new serverClasses.businessData(dbAssoc);
tempBusinessData.locations = loadBusinessLocationsFromDatabase(tempBusinessData.databaseId);
tempBusinesses.push(tempBusinessData);
console.log(`[Asshat.Business]: Business '${tempBusinessData.name}' (ID ${tempBusinessData.databaseId}) loaded from database successfully!`);
logToConsole(LOG_DEBUG, `[Asshat.Business]: Business '${tempBusinessData.name}' (ID ${tempBusinessData.databaseId}) loaded from database successfully!`);
}
}
freeDatabaseQuery(dbQuery);
@@ -62,14 +62,14 @@ function loadBusinessesFromDatabase() {
disconnectFromDatabase(dbConnection);
}
console.log(`[Asshat.Business]: ${tempBusinesses.length} businesses loaded from database successfully!`);
logToConsole(LOG_DEBUG, `[Asshat.Business]: ${tempBusinesses.length} businesses loaded from database successfully!`);
return tempBusinesses;
}
// ---------------------------------------------------------------------------
function loadBusinessLocationsFromDatabase(businessId) {
//console.log("[Asshat.Business]: Loading locations from database ...");
//logToConsole(LOG_DEBUG, "[Asshat.Business]: Loading locations from database ...");
let tempBusinessLocations = [];
let dbConnection = connectToDatabase();
@@ -83,7 +83,7 @@ function loadBusinessLocationsFromDatabase(businessId) {
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
let tempBusinessLocationData = new serverClasses.businessLocationData(dbAssoc);
tempBusinessLocations.push(tempBusinessLocationData);
//console.log(`[Asshat.Business]: Location '${tempBusinessLocationData.name}' loaded from database successfully!`);
//logToConsole(LOG_DEBUG, `[Asshat.Business]: Location '${tempBusinessLocationData.name}' loaded from database successfully!`);
}
}
freeDatabaseQuery(dbQuery);
@@ -91,7 +91,7 @@ function loadBusinessLocationsFromDatabase(businessId) {
disconnectFromDatabase(dbConnection);
}
//console.log(`[Asshat.Business]: ${tempBusinessLocations.length} location for business ${businessId} loaded from database successfully!`);
//logToConsole(LOG_DEBUG, `[Asshat.Business]: ${tempBusinessLocations.length} location for business ${businessId} loaded from database successfully!`);
return tempBusinessLocations;
}
@@ -666,7 +666,7 @@ function buySkinFromBusinessCommand(command, params, client) {
return false;
}
if(getBusinessData(businessId).type == AG_BIZTYPE_CLOTHES) {
if(getBusinessData(businessId).type == getGlobalConfig().buySkinPrice) {
messagePlayerError(client, `This business doesn't sell clothes (skins)!`);
return false;
}
@@ -734,7 +734,7 @@ function saveAllBusinessesToDatabase() {
function saveBusinessToDatabase(businessId) {
let tempBusinessData = getServerData().businesses[businessId]
console.log(`[Asshat.Business]: Saving business '${tempBusinessData.name}' to database ...`);
logToConsole(LOG_DEBUG, `[Asshat.Business]: Saving business '${tempBusinessData.name}' to database ...`);
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeBusinessName = escapeDatabaseString(dbConnection, tempBusinessData.name);
@@ -749,7 +749,7 @@ function saveBusinessToDatabase(businessId) {
disconnectFromDatabase(dbConnection);
return true;
}
console.log(`[Asshat.Business]: Saved business '${tempBusinessData.name}' to database!`);
logToConsole(LOG_DEBUG, `[Asshat.Business]: Saved business '${tempBusinessData.name}' to database!`);
return false;
}
@@ -1053,4 +1053,10 @@ function addToBusinessInventory(businessId, itemType, amount, buyPrice) {
getServerData().items[index].index = index;
}
// ---------------------------------------------------------------------------
function buyFromBusinessCommand(command, params, client) {
}
// ---------------------------------------------------------------------------

View File

@@ -9,8 +9,8 @@
// ===========================================================================
function initChatScript() {
console.log("[Asshat.Chat]: Initializing chat script ...");
console.log("[Asshat.Chat]: Chat script initialized successfully!");
logToConsole(LOG_DEBUG, "[Asshat.Chat]: Initializing chat script ...");
logToConsole(LOG_DEBUG, "[Asshat.Chat]: Chat script initialized successfully!");
return true;
}

View File

@@ -9,17 +9,17 @@
// ===========================================================================
function initClanScript() {
console.log("[Asshat.Clan]: Initializing clans script ...");
logToConsole(LOG_DEBUG, "[Asshat.Clan]: Initializing clans script ...");
getServerData().clans = loadClansFromDatabase();
setAllClanDataIndexes();
console.log("[Asshat.Clan]: Clan script initialized successfully!");
logToConsole(LOG_DEBUG, "[Asshat.Clan]: Clan script initialized successfully!");
return true;
}
// ---------------------------------------------------------------------------
function loadClansFromDatabase() {
console.log("[Asshat.Clan]: Loading clans from database ...");
logToConsole(LOG_DEBUG, "[Asshat.Clan]: Loading clans from database ...");
let tempClans = [];
let dbConnection = connectToDatabase();
@@ -34,7 +34,7 @@ function loadClansFromDatabase() {
tempClanData.members = loadClanMembersFromDatabase(tempClanData.databaseId);
tempClanData.ranks = loadClanRanksFromDatabase(tempClanData.databaseId);
tempClans.push(tempClanData);
console.log(`[Asshat.Clan]: Clan '${tempClanData.name}' loaded from database successfully!`);
logToConsole(LOG_DEBUG, `[Asshat.Clan]: Clan '${tempClanData.name}' loaded from database successfully!`);
}
}
freeDatabaseQuery(dbQuery);
@@ -42,7 +42,7 @@ function loadClansFromDatabase() {
disconnectFromDatabase(dbConnection);
}
console.log(`[Asshat.Clan]: ${tempClans.length} clans loaded from database successfully!`);
logToConsole(LOG_DEBUG, `[Asshat.Clan]: ${tempClans.length} clans loaded from database successfully!`);
return tempClans;
}

View File

@@ -94,7 +94,7 @@ function updatePlayerPing(client) {
// ---------------------------------------------------------------------------
addNetworkHandler("ag.arrivedAtBusStop", function(client) {
console.log(client);
logToConsole(LOG_DEBUG, client);
arrivedAtBusStop(client);
});
@@ -102,7 +102,7 @@ addNetworkHandler("ag.arrivedAtBusStop", function(client) {
addNetworkHandler("ag.clientReady", function(client) {
client.setData("ag.isReady", true, false);
console.log(`${getPlayerDisplayForConsole(client)}'s client resources are downloaded and ready!`);
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s client resources are downloaded and ready!`);
if(client.getData("ag.isStarted") == true) {
initClient(client);
}
@@ -112,14 +112,14 @@ addNetworkHandler("ag.clientReady", function(client) {
addNetworkHandler("ag.guiReady", function(client) {
client.setData("ag.guiReady", true, false);
console.log(`${getPlayerDisplayForConsole(client)}'s client GUI is initialized and ready!`);
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s client GUI is initialized and ready!`);
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.clientStarted", function(client) {
client.setData("ag.isStarted", true, false);
console.log(`${getPlayerDisplayForConsole(client)}'s client resources are started and running!`);
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s client resources are started and running!`);
if(client.getData("ag.isReady") == true) {
initClient(client);
}
@@ -146,7 +146,7 @@ function disableCityAmbienceForPlayer(client) {
// ---------------------------------------------------------------------------
function clearPlayerOwnedPeds(client) {
console.log(`[Asshat.Utilities] Clearing peds owned by ${getPlayerDisplayForConsole(client)}`);
logToConsole(LOG_DEBUG, `[Asshat.Utilities] Clearing peds owned by ${getPlayerDisplayForConsole(client)}`);
triggerNetworkEvent("ag.clearPeds", client);
}

View File

@@ -9,7 +9,7 @@
// ===========================================================================
function initDeveloperScript() {
console.log("[Asshat.Developer]: Initializing developer script ...");
logToConsole(LOG_DEBUG, "[Asshat.Developer]: Initializing developer script ...");
// Use GTAC command handlers for these since they need to be available on console
addCommandHandler("sc", executeServerCodeCommand);
@@ -17,7 +17,7 @@ function initDeveloperScript() {
addCommandHandler("docmd", simulateCommandForPlayer);
addCommandHandler("allcmd", simulateCommandForAllPlayers);
console.log("[Asshat.Developer]: Developer script initialized successfully!");
logToConsole(LOG_DEBUG, "[Asshat.Developer]: Developer script initialized successfully!");
return true;
}

View File

@@ -11,16 +11,16 @@
// ---------------------------------------------------------------------------
function initEventScript() {
console.log("[Asshat.Event]: Initializing event script ...");
logToConsole(LOG_DEBUG, "[Asshat.Event]: Initializing event script ...");
addNetworkHandler("ag.onPlayerEnterVehicle", playerEnteredVehicle);
addNetworkHandler("ag.onPlayerExitVehicle", playerExitedVehicle);
console.log("[Asshat.Event]: Event script initialized!");
logToConsole(LOG_DEBUG, "[Asshat.Event]: Event script initialized!");
}
// ---------------------------------------------------------------------------
addEventHandler("OnPlayerConnect", function(event, ipAddress, port) {
console.log(`[Asshat.Event] Client connecting (IP: ${ipAddress})`);
logToConsole(LOG_DEBUG, `[Asshat.Event] Client connecting (IP: ${ipAddress})`);
if(isIpAddressBanned(ipAddress)) {
messagePlayerError(client, "You are banned from this server!");
return false;
@@ -42,7 +42,7 @@ addEventHandler("OnPlayerJoined", function(event, client) {
// ---------------------------------------------------------------------------
addEventHandler("OnPlayerQuit", function(event, client, quitReasonId) {
console.log(`[Asshat.Event] ${getPlayerDisplayForConsole(client)} disconnected (${disconnectReasons[quitReasonId]}[${quitReasonId}])`);
logToConsole(LOG_DEBUG, `[Asshat.Event] ${getPlayerDisplayForConsole(client)} disconnected (${disconnectReasons[quitReasonId]}[${quitReasonId}])`);
//savePlayerToDatabase(client);
resetClientStuff(client);
@@ -157,7 +157,7 @@ async function playerEnteredVehicle(client) {
return false;
}
console.log(`[Asshat.Event] ${getPlayerDisplayForConsole(client)} entered a ${getVehicleName(vehicle)} (ID: ${vehicle.getData("ag.dataSlot")}, Database ID: ${getVehicleData(vehicle).databaseId})`);
logToConsole(LOG_DEBUG, `[Asshat.Event] ${getPlayerDisplayForConsole(client)} entered a ${getVehicleName(vehicle)} (ID: ${vehicle.getData("ag.dataSlot")}, Database ID: ${getVehicleData(vehicle).databaseId})`);
getPlayerData(client).lastVehicle = vehicle;
@@ -213,7 +213,7 @@ function playerExitedVehicle(client) {
return false;
}
console.log(`[Asshat.Event] ${getPlayerDisplayForConsole(client)} exited a ${getVehicleName(vehicle)} (ID: ${vehicle.getData("ag.dataSlot")}, Database ID: ${getVehicleData(vehicle).databaseId})`);
logToConsole(LOG_DEBUG, `[Asshat.Event] ${getPlayerDisplayForConsole(client)} exited a ${getVehicleName(vehicle)} (ID: ${vehicle.getData("ag.dataSlot")}, Database ID: ${getVehicleData(vehicle).databaseId})`);
if(isPlayerWorking(client)) {
if(isPlayerOnJobRoute(client)) {

View File

@@ -9,19 +9,19 @@
// ===========================================================================
function initHouseScript() {
console.log("[Asshat.House]: Initializing house script ...");
logToConsole(LOG_DEBUG, "[Asshat.House]: Initializing house script ...");
getServerData().houses = loadHousesFromDatabase();
createAllHousePickups();
createAllHouseBlips();
setAllHouseIndexes();
console.log("[Asshat.House]: House script initialized successfully!");
logToConsole(LOG_DEBUG, "[Asshat.House]: House script initialized successfully!");
return true;
}
// ---------------------------------------------------------------------------
function loadHousesFromDatabase() {
console.log("[Asshat.House]: Loading houses from database ...");
logToConsole(LOG_DEBUG, "[Asshat.House]: Loading houses from database ...");
let tempHouses = [];
let dbConnection = connectToDatabase();
let dbAssoc;
@@ -33,14 +33,14 @@ function loadHousesFromDatabase() {
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
let tempHouseData = new serverClasses.houseData(dbAssoc);
tempHouses.push(tempHouseData);
console.log(`[Asshat.House]: House '${tempHouseData.description}' (ID ${tempHouseData.databaseId}) loaded!`);
logToConsole(LOG_DEBUG, `[Asshat.House]: House '${tempHouseData.description}' (ID ${tempHouseData.databaseId}) loaded!`);
}
}
freeDatabaseQuery(dbQuery);
}
disconnectFromDatabase(dbConnection);
}
console.log(`[Asshat.House]: ${tempHouses.length} houses loaded from database successfully!`);
logToConsole(LOG_DEBUG, `[Asshat.House]: ${tempHouses.length} houses loaded from database successfully!`);
return tempHouses;
}
@@ -417,7 +417,7 @@ function saveAllHousesToDatabase() {
function saveHouseToDatabase(houseId) {
let tempHouseData = getServerData().houses[houseId];
console.log(`[Asshat.House]: Saving house '${tempHouseData.databaseId}' to database ...`);
logToConsole(LOG_DEBUG, `[Asshat.House]: Saving house '${tempHouseData.databaseId}' to database ...`);
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeHouseDescription = escapeDatabaseString(dbConnection, tempHouseData.description);
@@ -432,7 +432,7 @@ function saveHouseToDatabase(houseId) {
disconnectFromDatabase(dbConnection);
return true;
}
console.log(`[Asshat.house]: Saved house '${tempHouseData.description}' to database!`);
logToConsole(LOG_DEBUG, `[Asshat.house]: Saved house '${tempHouseData.description}' to database!`);
return false;
}

View File

@@ -129,8 +129,8 @@ let bindableKeys = {
// ---------------------------------------------------------------------------
function initKeyBindScript() {
console.log("[Asshat.KeyBind]: Initializing key bind script ...");
console.log("[Asshat.KeyBind]: Key bind script initialized!");
logToConsole(LOG_DEBUG, "[Asshat.KeyBind]: Initializing key bind script ...");
logToConsole(LOG_DEBUG, "[Asshat.KeyBind]: Key bind script initialized!");
}
// ---------------------------------------------------------------------------
@@ -265,7 +265,7 @@ function playerUsedKeyBind(client, key) {
return false;
}
console.log(`[Asshat.KeyBind] ${getPlayerDisplayForConsole(client)} used keybind ${sdl.getKeyName(key)} (${key})`);
logToConsole(LOG_DEBUG, `[Asshat.KeyBind] ${getPlayerDisplayForConsole(client)} used keybind ${sdl.getKeyName(key)} (${key})`);
if(doesPlayerHaveKeyBindForKey(client, key)) {
let keyBindData = getPlayerKeyBindForKey(client, key);
if(keyBindData.enabled) {

View File

@@ -21,7 +21,7 @@ function messageAdminAction(messageText) {
function messagePlayerNormal(client, messageText, colour = COLOUR_WHITE) {
if(isConsole(client)) {
console.log(`[Asshat.Messaging] ${messageText}`);
logToConsole(LOG_DEBUG, `[Asshat.Messaging] ${messageText}`);
return true;
}
@@ -38,7 +38,7 @@ function messageAdmins(messageText, colour = COLOUR_WHITE) {
let clients = getClients();
for(let i in clients) {
if(clients[i].console) {
console.log(`[Asshat.Messaging] 🛡️ ${messageText}`);
logToConsole(LOG_DEBUG, `[Asshat.Messaging] 🛡️ ${messageText}`);
} else {
if(doesPlayerHaveStaffPermission(clients[i], getStaffFlagValue("basicModeration"))) {
messageClient(`🛡️ ${messageText}`, clients[i], getColourByName("softRed"));
@@ -52,7 +52,7 @@ function messageAdmins(messageText, colour = COLOUR_WHITE) {
function messagePlayerError(client, messageText) {
if(isConsole(client)) {
console.log(`[Asshat.Messaging] ERROR: ${messageText}`);
logToConsole(LOG_DEBUG, `[Asshat.Messaging] ERROR: ${messageText}`);
return true;
}
@@ -67,7 +67,7 @@ function messagePlayerError(client, messageText) {
function messagePlayerSyntax(client, messageText) {
if(isConsole(client)) {
console.log(`[Asshat.Messaging] USAGE: ${messageText}`);
logToConsole(LOG_DEBUG, `[Asshat.Messaging] USAGE: ${messageText}`);
return true;
}
@@ -82,7 +82,7 @@ function messagePlayerSyntax(client, messageText) {
function messagePlayerAlert(client, messageText) {
if(isConsole(client)) {
console.log(`[Asshat.Messaging] ALERT: ${messageText}`);
logToConsole(LOG_DEBUG, `[Asshat.Messaging] ALERT: ${messageText}`);
return true;
}
@@ -97,7 +97,7 @@ function messagePlayerAlert(client, messageText) {
function messagePlayerSuccess(client, messageText) {
if(isConsole(client)) {
console.log(`[Asshat.Messaging] SUCCESS: ${messageText}`);
logToConsole(LOG_DEBUG, `[Asshat.Messaging] SUCCESS: ${messageText}`);
return true;
}
@@ -112,7 +112,7 @@ function messagePlayerSuccess(client, messageText) {
function messagePlayerInfo(client, messageText) {
if(isConsole(client)) {
console.log(`[INFO] ${messageText}`);
logToConsole(LOG_DEBUG, `[INFO] ${messageText}`);
return true;
}
@@ -127,7 +127,7 @@ function messagePlayerInfo(client, messageText) {
function messagePlayerTip(client, messageText) {
if(isConsole(client)) {
console.log(`[TIP] ${messageText}`);
logToConsole(LOG_DEBUG, `[TIP] ${messageText}`);
return true;
}

View File

@@ -11,8 +11,8 @@
// ---------------------------------------------------------------------------
function initMiscScript() {
console.log("[Asshat.Misc]: Initializing misc script ...");
console.log("[Asshat.Misc]: Misc script initialized successfully!");
logToConsole(LOG_DEBUG, "[Asshat.Misc]: Initializing misc script ...");
logToConsole(LOG_DEBUG, "[Asshat.Misc]: Misc script initialized successfully!");
return true;
}
@@ -22,7 +22,7 @@ function getPositionCommand(command, params, client) {
let position = client.player.position;
messagePlayerNormal(client, `Your position is: ${position.x.toFixed(2)}, ${position.y.toFixed(2)}, ${position.z.toFixed(2)}`);
console.log(`${getPlayerDisplayForConsole(client)}'s position is: ${position.x.toFixed(2)}, ${position.y.toFixed(2)}, ${position.z.toFixed(2)}`);
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s position is: ${position.x.toFixed(2)}, ${position.y.toFixed(2)}, ${position.z.toFixed(2)}`);
return true;
}
@@ -172,7 +172,7 @@ function enterExitPropertyCommand(command, params, client) {
}, 1000);
}, 1100);
removeEntityData(client, "ag.inBusiness");
console.log(`[Asshat.Misc] ${getPlayerDisplayForConsole(client)} entered business ${inBusiness.name}[${inBusiness.index}/${inBusiness.databaseId}]`);
logToConsole(LOG_DEBUG, `[Asshat.Misc] ${getPlayerDisplayForConsole(client)} entered business ${inBusiness.name}[${inBusiness.index}/${inBusiness.databaseId}]`);
}
return true;
}
@@ -253,7 +253,7 @@ function enterExitPropertyCommand(command, params, client) {
function sendRemovedWorldObjectsToPlayer(client) {
for(let i in getGameConfig().removedWorldObjects[getServerGame()]) {
console.log(`[Asshat.Misc] Sending removed world object ${i} (${getGameConfig().removedWorldObjects[getServerGame()][i].model}) to ${client.name}`);
logToConsole(LOG_DEBUG, `[Asshat.Misc] Sending removed world object ${i} (${getGameConfig().removedWorldObjects[getServerGame()][i].model}) to ${client.name}`);
triggerNetworkEvent("ag.removeWorldObject", client, getGameConfig().removedWorldObjects[getServerGame()][i].model, getGameConfig().removedWorldObjects[getServerGame()][i].position, getGameConfig().removedWorldObjects[getServerGame()][i].range);
}
return true;

View File

@@ -68,7 +68,7 @@ function checkForMySQLModule() {
// ---------------------------------------------------------------------------
function checkForAllRequiredModules() {
console.log("[Asshat.Startup]: Checking for required modules ...");
logToConsole(LOG_DEBUG, "[Asshat.Startup]: Checking for required modules ...");
if(!checkForHashingModule()) {
console.warn("[Asshat.Startup]: Hashing module is not loaded!");
@@ -82,7 +82,7 @@ function checkForAllRequiredModules() {
thisResource.stop();
}
console.log("[Asshat.Startup]: All required modules loaded!");
logToConsole(LOG_DEBUG, "[Asshat.Startup]: All required modules loaded!");
return true;
}

View File

@@ -9,8 +9,8 @@
// ===========================================================================
function initSubAccountScript() {
console.log("[Asshat.SubAccount]: Initializing subaccount script ...");
console.log("[Asshat.SubAccount]: SubAccount script initialized!");
logToConsole(LOG_DEBUG, "[Asshat.SubAccount]: Initializing subaccount script ...");
logToConsole(LOG_DEBUG, "[Asshat.SubAccount]: SubAccount script initialized!");
}
// ---------------------------------------------------------------------------
@@ -91,7 +91,7 @@ function saveSubAccountToDatabase(subAccountData) {
// ---------------------------------------------------------------------------
function createSubAccount(accountId, firstName, lastName, skinId, dateOfBirth, placeOfOrigin) {
console.log(`[Asshat.Account] Attempting to create subaccount ${firstName} ${lastName} in database`);
logToConsole(LOG_DEBUG, `[Asshat.Account] Attempting to create subaccount ${firstName} ${lastName} in database`);
let dbConnection = connectToDatabase();
if(dbConnection) {
@@ -127,7 +127,7 @@ function showCharacterSelectToClient(client) {
getPlayerData(client).currentSubAccount = 0;
let tempSubAccount = getPlayerData(client).subAccounts[0];
triggerNetworkEvent("ag.showCharacterSelect", client, tempSubAccount.firstName, tempSubAccount.lastName, tempSubAccount.placeOfOrigin, tempSubAccount.dateOfBirth, tempSubAccount.skin);
console.log(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the character select GUI`);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the character select GUI`);
} else {
//let emojiNumbers = ["➊", "➋", "➌", "➍", "➎", "➏", "➐", "➑", "➒"];
//let emojiNumbers = ["①", "②", "③", "④", "⑤", "⑥", "⑦", "⑧", "⑨"];
@@ -136,7 +136,7 @@ function showCharacterSelectToClient(client) {
getPlayerData(client).subAccounts.forEach(function(subAccount, index) {
messagePlayerNormal(client, `${index+1} • [#AAAAAA]${subAccount.firstName} ${subAccount.lastName}`);
});
console.log(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the character select/list message (GUI disabled)`);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the character select/list message (GUI disabled)`);
}
}
@@ -230,7 +230,7 @@ function selectCharacter(client, characterId = -1) {
getPlayerData(client).currentSubAccount = characterId;
}
console.log(`[Asshat.SubAccount] Spawning ${getPlayerDisplayForConsole(client)} with skin ${getPlayerCurrentSubAccount(client).skin}`);
logToConsole(LOG_DEBUG, `[Asshat.SubAccount] Spawning ${getPlayerDisplayForConsole(client)} with skin ${getPlayerCurrentSubAccount(client).skin}`);
spawnPlayer(client, getPlayerCurrentSubAccount(client).spawnPosition, getPlayerCurrentSubAccount(client).spawnHeading, getPlayerCurrentSubAccount(client).skin);
getPlayerCurrentSubAccount(client).lastLogin = new Date().getTime();

View File

@@ -19,14 +19,14 @@ function updateTimeRule() {
// ---------------------------------------------------------------------------
function saveAllServerDataToDatabase() {
console.log("[Asshat.Utilities]: Saving all server data to database ...");
logToConsole(LOG_DEBUG, "[Asshat.Utilities]: Saving all server data to database ...");
saveAllClansToDatabase();
saveAllHousesToDatabase();
saveAllBusinessesToDatabase();
saveServerConfigToDatabase(getServerConfig());
saveAllVehiclesToDatabase();
saveAllClientsToDatabase();
console.log("[Asshat.Utilities]: Saved all server data to database!");
logToConsole(LOG_DEBUG, "[Asshat.Utilities]: Saved all server data to database!");
}
// ---------------------------------------------------------------------------

View File

@@ -161,7 +161,7 @@ async function translateMessage(messageText, translateFrom = defaultLanguageId,
return new Promise(resolve => {
for(let i in translationCache[translateFrom][translateTo]) {
if(translationCache[translateFrom][translateTo][0] == messageText) {
console.log(`[Translate]: Using existing translation for ${translationLanguages[translateFrom][0]} to ${translationLanguages[translateTo][0]} - (${messageText}), (${translationCache[translateFrom][translateTo][1]})`);
logToConsole(LOG_DEBUG, `[Translate]: Using existing translation for ${translationLanguages[translateFrom][0]} to ${translationLanguages[translateTo][0]} - (${messageText}), (${translationCache[translateFrom][translateTo][1]})`);
resolve(translationCache[translateFrom][translateTo][1]);
}
}

View File

@@ -1856,7 +1856,7 @@ async function waitUntil(condition) {
// -------------------------------------------------------------------------
function resetClientStuff(client) {
console.log(`[Asshat.Utilities] Resetting client data for ${getPlayerDisplayForConsole(client)}`);
logToConsole(LOG_DEBUG, `[Asshat.Utilities] Resetting client data for ${getPlayerDisplayForConsole(client)}`);
if(!getPlayerData(client)) {
return false;
@@ -1873,4 +1873,4 @@ function resetClientStuff(client) {
getPlayerData(client).lastVehicle = null;
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------

View File

@@ -9,17 +9,17 @@
// ===========================================================================
function initVehicleScript() {
console.log("[Asshat.Vehicle]: Initializing vehicle script ...");
logToConsole(LOG_DEBUG, "[Asshat.Vehicle]: Initializing vehicle script ...");
getServerData().vehicles = loadVehiclesFromDatabase();
spawnAllVehicles();
console.log("[Asshat.Vehicle]: Vehicle script initialized successfully!");
logToConsole(LOG_DEBUG, "[Asshat.Vehicle]: Vehicle script initialized successfully!");
return true;
}
// ---------------------------------------------------------------------------
function loadVehiclesFromDatabase() {
console.log("[Asshat.Vehicle]: Loading vehicles from database ...");
logToConsole(LOG_DEBUG, "[Asshat.Vehicle]: Loading vehicles from database ...");
let dbConnection = connectToDatabase();
let tempVehicles = [];
let dbAssoc;
@@ -36,19 +36,19 @@ function loadVehiclesFromDatabase() {
disconnectFromDatabase(dbConnection);
}
console.log(`[Asshat.Vehicle]: ${tempVehicles.length} vehicles loaded from database successfully!`);
logToConsole(LOG_DEBUG, `[Asshat.Vehicle]: ${tempVehicles.length} vehicles loaded from database successfully!`);
return tempVehicles;
}
// ---------------------------------------------------------------------------
function saveAllVehiclesToDatabase() {
console.log("[Asshat.Vehicle]: Saving all vehicles to database ...");
logToConsole(LOG_DEBUG, "[Asshat.Vehicle]: Saving all vehicles to database ...");
let vehicles = getServerData().vehicles;
for(let i in vehicles) {
saveVehicleToDatabase(vehicles[i]);
}
console.log("[Asshat.Vehicle]: Saved all vehicles to database!");
logToConsole(LOG_DEBUG, "[Asshat.Vehicle]: Saved all vehicles to database!");
return true;
}
@@ -66,7 +66,7 @@ function saveVehicleToDatabase(vehicleData) {
return false;
}
console.log(`[Asshat.Vehicle]: Saving vehicle ${vehicleData.databaseId} to database ...`);
logToConsole(LOG_DEBUG, `[Asshat.Vehicle]: Saving vehicle ${vehicleData.databaseId} to database ...`);
let dbConnection = connectToDatabase();
if(dbConnection) {
if(!vehicleData.spawnLocked) {
@@ -91,7 +91,7 @@ function saveVehicleToDatabase(vehicleData) {
disconnectFromDatabase(dbConnection);
return true;
}
console.log(`[Asshat.Vehicle]: Saved vehicle ${vehicleData.vehicle.id} to database!`);
logToConsole(LOG_DEBUG, `[Asshat.Vehicle]: Saved vehicle ${vehicleData.vehicle.id} to database!`);
return false;
}