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

@@ -1081,9 +1081,9 @@ let currentCharacter = 0;
app.init = function() app.init = function()
{ {
console.log(`[Asshat.GUI] Initializing GUI ...`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Initializing GUI ...`);
console.log(`[Asshat.GUI] Creating login GUI ...`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Creating login GUI ...`);
login.window = mexui.window(game.width/2-150, game.height/2-129, 300, 258, 'LOGIN', { login.window = mexui.window(game.width/2-150, game.height/2-129, 300, 258, 'LOGIN', {
main: { main: {
backgroundColour: toColour(0, 0, 0, windowAlpha), backgroundColour: toColour(0, 0, 0, windowAlpha),
@@ -1158,11 +1158,11 @@ app.init = function()
}, },
}, checkLogin); }, checkLogin);
console.log(`[Asshat.GUI] Created login GUI`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Created login GUI`);
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
console.log(`[Asshat.GUI] Creating two factor auth GUI ...`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Creating two factor auth GUI ...`);
twoFactorAuth.window = mexui.window(game.width/2-150, game.height/2-129, 300, 258, 'LOGIN', { twoFactorAuth.window = mexui.window(game.width/2-150, game.height/2-129, 300, 258, 'LOGIN', {
main: { main: {
backgroundColour: toColour(0, 0, 0, windowAlpha), backgroundColour: toColour(0, 0, 0, windowAlpha),
@@ -1236,11 +1236,11 @@ app.init = function()
}, },
}, checkTwoFactorAuth); }, checkTwoFactorAuth);
console.log(`[Asshat.GUI] Created two factor auth GUI`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Created two factor auth GUI`);
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
console.log(`[Asshat.GUI] Creating new character GUI ...`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Creating new character GUI ...`);
newCharacter.window = mexui.window(game.width/2-215, game.height/2-83, 430, 166, 'New Character', { newCharacter.window = mexui.window(game.width/2-215, game.height/2-83, 430, 166, 'New Character', {
main: { main: {
@@ -1442,13 +1442,11 @@ app.init = function()
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha), borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
}, },
}, checkNewCharacter); }, checkNewCharacter);
logToConsole(LOG_DEBUG, `[Asshat.GUI] Created new character GUI`);
console.log(`[Asshat.GUI] Created new character GUI`);
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
console.log(`[Asshat.GUI] Creating register GUI ...`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Creating register GUI ...`);
register.window = mexui.window(game.width/2-130, game.height/2-115, 300, 230, 'Register', { register.window = mexui.window(game.width/2-130, game.height/2-115, 300, 230, 'Register', {
main: { main: {
backgroundColour: toColour(0, 0, 0, windowAlpha), backgroundColour: toColour(0, 0, 0, windowAlpha),
@@ -1557,13 +1555,11 @@ app.init = function()
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha), borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
}, },
}, checkRegistration); }, checkRegistration);
logToConsole(LOG_DEBUG, `[Asshat.GUI] Created register GUI`);
console.log(`[Asshat.GUI] Created register GUI`);
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
console.log(`[Asshat.GUI] Creating error GUI ...`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Creating error GUI ...`);
errorDialog.window = mexui.window(game.width/2-200, game.height/2-70, 400, 140, 'ERROR', { errorDialog.window = mexui.window(game.width/2-200, game.height/2-70, 400, 140, 'ERROR', {
main: { main: {
backgroundColour: toColour(0, 0, 0, windowAlpha), backgroundColour: toColour(0, 0, 0, windowAlpha),
@@ -1599,13 +1595,11 @@ app.init = function()
textAlign: 0.5, textAlign: 0.5,
}, },
}, closeErrorDialog); }, closeErrorDialog);
logToConsole(LOG_DEBUG, `[Asshat.GUI] Created error GUI ...`);
console.log(`[Asshat.GUI] Created error GUI ...`);
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
console.log(`[Asshat.GUI] Created prompt GUI ...`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Created prompt GUI ...`);
yesNoDialog.window = mexui.window(game.width/2-200, game.height/2-70, 400, 140, 'Question', { yesNoDialog.window = mexui.window(game.width/2-200, game.height/2-70, 400, 140, 'Question', {
main: { main: {
backgroundColour: toColour(0, 0, 0, windowAlpha), backgroundColour: toColour(0, 0, 0, windowAlpha),
@@ -1651,13 +1645,11 @@ app.init = function()
textAlign: 0.5, textAlign: 0.5,
}, },
}, yesNoDialogAnswerNo); }, yesNoDialogAnswerNo);
logToConsole(LOG_DEBUG, `[Asshat.GUI] Created prompt GUI`);
console.log(`[Asshat.GUI] Created prompt GUI`);
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
console.log(`[Asshat.GUI] Creating info dialog GUI ...`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Creating info dialog GUI ...`);
infoDialog.window = mexui.window(game.width/2-200, game.height/2-70, 400, 140, 'Information', { infoDialog.window = mexui.window(game.width/2-200, game.height/2-70, 400, 140, 'Information', {
main: { main: {
backgroundColour: toColour(0, 0, 0, windowAlpha), backgroundColour: toColour(0, 0, 0, windowAlpha),
@@ -1692,13 +1684,11 @@ app.init = function()
textAlign: 0.5, textAlign: 0.5,
}, },
}, closeInfoDialog); }, closeInfoDialog);
logToConsole(LOG_DEBUG, `[Asshat.GUI] Created info dialog GUI`);
console.log(`[Asshat.GUI] Created info dialog GUI`);
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
console.log(`[Asshat.GUI] Creating character select GUI ...`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Creating character select GUI ...`);
characterSelect.window = mexui.window(game.width/2-215, game.height/2-83, 430, 166, 'Select Character', { characterSelect.window = mexui.window(game.width/2-215, game.height/2-83, 430, 166, 'Select Character', {
main: { main: {
backgroundColour: toColour(0, 0, 0, windowAlpha), backgroundColour: toColour(0, 0, 0, windowAlpha),
@@ -1808,26 +1798,25 @@ app.init = function()
borderColour: toColour(0, 0, 0, 0), borderColour: toColour(0, 0, 0, 0),
} }
}); });
logToConsole(LOG_DEBUG, `[Asshat.GUI] Created character select GUI`);
console.log(`[Asshat.GUI] Created character select GUI`);
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
console.log(`[Asshat.GUI] All GUI created successfully!`); logToConsole(LOG_DEBUG, `[Asshat.GUI] All GUI created successfully!`);
closeAllWindows(); closeAllWindows();
}; };
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let checkLogin = function() { let checkLogin = function() {
console.log(`[Asshat.GUI] Checking login with server ...`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Checking login with server ...`);
triggerNetworkEvent("ag.checkLogin", login.passwordInput.lines[0]); triggerNetworkEvent("ag.checkLogin", login.passwordInput.lines[0]);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let loginFailed = function(errorMessage) { let loginFailed = function(errorMessage) {
console.log(`[Asshat.GUI] Server reports login failed`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Server reports login failed`);
login.messageLabel.text = errorMessage; login.messageLabel.text = errorMessage;
login.messageLabel.styles.main.textColour = toColour(180, 32, 32, 255); login.messageLabel.styles.main.textColour = toColour(180, 32, 32, 255);
login.passwordInput.text = ""; login.passwordInput.text = "";
@@ -1836,21 +1825,21 @@ let loginFailed = function(errorMessage) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let loginSuccess = function() { let loginSuccess = function() {
console.log(`[Asshat.GUI] Server reports login was successful`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Server reports login was successful`);
closeAllWindows(); closeAllWindows();
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let checkRegistration = function() { let checkRegistration = function() {
console.log(`[Asshat.GUI] Checking registration with server ...`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Checking registration with server ...`);
triggerNetworkEvent("ag.checkRegistration", register.passwordInput.lines[0], register.confirmPasswordInput.lines[0], register.emailInput.lines[0]); triggerNetworkEvent("ag.checkRegistration", register.passwordInput.lines[0], register.confirmPasswordInput.lines[0], register.emailInput.lines[0]);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let checkNewCharacter = function() { let checkNewCharacter = function() {
console.log(`[Asshat.GUI] Checking new character with server ...`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Checking new character with server ...`);
let skinId = false; let skinId = false;
if(newCharacter.firstNameInput.lines[0].length < 2) { if(newCharacter.firstNameInput.lines[0].length < 2) {
@@ -1881,7 +1870,7 @@ let checkNewCharacter = function() {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let registrationFailed = function(errorMessage) { let registrationFailed = function(errorMessage) {
console.log(`[Asshat.GUI] Server reports registration failed. Reason: ${errorMessage}`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Server reports registration failed. Reason: ${errorMessage}`);
register.messageLabel.text = errorMessage; register.messageLabel.text = errorMessage;
register.messageLabel.styles.main.textColour = toColour(180, 32, 32, 255); register.messageLabel.styles.main.textColour = toColour(180, 32, 32, 255);
register.passwordInput.text = ""; register.passwordInput.text = "";
@@ -1892,14 +1881,14 @@ let registrationFailed = function(errorMessage) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let registrationSuccess = function() { let registrationSuccess = function() {
console.log(`[Asshat.GUI] Server reports registration was successful`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Server reports registration was successful`);
closeAllWindows(); closeAllWindows();
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let twoFactorAuthFailed = function(errorMessage) { let twoFactorAuthFailed = function(errorMessage) {
console.log(`[Asshat.GUI] Server reports two-factor authentication failed. Reason: ${errorMessage}`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Server reports two-factor authentication failed. Reason: ${errorMessage}`);
login.messageLabel.text = errorMessage; login.messageLabel.text = errorMessage;
login.messageLabel.styles.main.textColour = toColour(180, 32, 32, 255); login.messageLabel.styles.main.textColour = toColour(180, 32, 32, 255);
login.passwordInput.text = ""; login.passwordInput.text = "";
@@ -1908,28 +1897,28 @@ let twoFactorAuthFailed = function(errorMessage) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let twoFactorAuthSuccess = function() { let twoFactorAuthSuccess = function() {
console.log(`[Asshat.GUI] Server reports two-factor authentication was successful`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Server reports two-factor authentication was successful`);
closeAllWindows(); closeAllWindows();
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let checkTwoFactorAuth = function() { let checkTwoFactorAuth = function() {
console.log(`[Asshat.GUI] Checking two-factor authentication with server ...`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Checking two-factor authentication with server ...`);
triggerNetworkEvent("ag.checkTwoFactorAuth", twoFactorAuth.codeInput.lines[0]); triggerNetworkEvent("ag.checkTwoFactorAuth", twoFactorAuth.codeInput.lines[0]);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let characterSelectSuccess = function() { let characterSelectSuccess = function() {
console.log(`[Asshat.GUI] Server reports character selection was successful`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Server reports character selection was successful`);
closeAllWindows(); closeAllWindows();
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let closeErrorDialog = function() { let closeErrorDialog = function() {
console.log(`[Asshat.GUI] Closing error dialog`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Closing error dialog`);
errorDialog.window.shown = false; errorDialog.window.shown = false;
mexui.setInput(false); mexui.setInput(false);
} }
@@ -1937,7 +1926,7 @@ let closeErrorDialog = function() {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let closeInfoDialog = function() { let closeInfoDialog = function() {
console.log(`[Asshat.GUI] Closing info dialog`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Closing info dialog`);
infoDialog.window.shown = false; infoDialog.window.shown = false;
mexui.setInput(false); mexui.setInput(false);
} }
@@ -1945,7 +1934,7 @@ let closeInfoDialog = function() {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let closeAllWindows = function() { let closeAllWindows = function() {
console.log(`[Asshat.GUI] Closing all GUI windows`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Closing all GUI windows`);
infoDialog.window.shown = false; infoDialog.window.shown = false;
errorDialog.window.shown = false; errorDialog.window.shown = false;
yesNoDialog.window.shown = false; yesNoDialog.window.shown = false;
@@ -1961,21 +1950,21 @@ let closeAllWindows = function() {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let yesNoDialogAnswerNo = function() { let yesNoDialogAnswerNo = function() {
console.log(`[Asshat.GUI] Responding with answer NO to server prompt`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Responding with answer NO to server prompt`);
triggerNetworkEvent("ag.promptAnswerNo"); triggerNetworkEvent("ag.promptAnswerNo");
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let yesNoDialogAnswerYes = function() { let yesNoDialogAnswerYes = function() {
console.log(`[Asshat.GUI] Responding with answer YES to server prompt`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Responding with answer YES to server prompt`);
triggerNetworkEvent("ag.promptAnswerYes"); triggerNetworkEvent("ag.promptAnswerYes");
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let showRegistration = function() { let showRegistration = function() {
console.log(`[Asshat.GUI] Showing registration window`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Showing registration window`);
closeAllWindows(); closeAllWindows();
setChatWindowEnabled(false); setChatWindowEnabled(false);
mexui.setInput(true); mexui.setInput(true);
@@ -1986,7 +1975,7 @@ let showRegistration = function() {
let showLogin = function() { let showLogin = function() {
closeAllWindows(); closeAllWindows();
console.log(`[Asshat.GUI] Showing login window`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Showing login window`);
setChatWindowEnabled(false); setChatWindowEnabled(false);
mexui.setInput(true); mexui.setInput(true);
login.window.shown = true; login.window.shown = true;
@@ -1996,7 +1985,7 @@ let showLogin = function() {
let showTwoFactorAuth = function() { let showTwoFactorAuth = function() {
closeAllWindows(); closeAllWindows();
console.log(`[Asshat.GUI] Showing two-factor authentication window`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Showing two-factor authentication window`);
setChatWindowEnabled(false); setChatWindowEnabled(false);
mexui.setInput(true); mexui.setInput(true);
twoFactorAuth.window.shown = true; twoFactorAuth.window.shown = true;
@@ -2006,7 +1995,7 @@ let showTwoFactorAuth = function() {
let showCharacterSelect = function(firstName, lastName, placeOfOrigin, dateOfBirth, skinId) { let showCharacterSelect = function(firstName, lastName, placeOfOrigin, dateOfBirth, skinId) {
closeAllWindows(); closeAllWindows();
console.log(`[Asshat.GUI] Showing character selection window`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Showing character selection window`);
setChatWindowEnabled(false); setChatWindowEnabled(false);
mexui.setInput(true); mexui.setInput(true);
characterSelect.nameText.text = lastName + ", " + firstName; characterSelect.nameText.text = lastName + ", " + firstName;
@@ -2020,7 +2009,7 @@ let showCharacterSelect = function(firstName, lastName, placeOfOrigin, dateOfBir
let showError = function(errorMessage, errorTitle) { let showError = function(errorMessage, errorTitle) {
closeAllWindows(); closeAllWindows();
console.log(`[Asshat.GUI] Showing error window. Error: ${errorTitle} - ${errorMessage}`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Showing error window. Error: ${errorTitle} - ${errorMessage}`);
setChatWindowEnabled(false); setChatWindowEnabled(false);
mexui.setInput(true); mexui.setInput(true);
errorDialog.messageLabel.text = errorMessage; errorDialog.messageLabel.text = errorMessage;
@@ -2031,7 +2020,7 @@ let showError = function(errorMessage, errorTitle) {
let showYesNo = function(promptMessage, promptTitle) { let showYesNo = function(promptMessage, promptTitle) {
closeAllWindows(); closeAllWindows();
console.log(`[Asshat.GUI] Showing prompt window. Prompt: ${promptTitle} - ${promptMessage}`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Showing prompt window. Prompt: ${promptTitle} - ${promptMessage}`);
mexui.setInput(true); mexui.setInput(true);
yesNoDialog.messageLabel.text = promptMessage; yesNoDialog.messageLabel.text = promptMessage;
yesNoDialog.window.shown = true; yesNoDialog.window.shown = true;
@@ -2041,7 +2030,7 @@ let showYesNo = function(promptMessage, promptTitle) {
let showInfo = function(infoMessage, infoTitle) { let showInfo = function(infoMessage, infoTitle) {
closeAllWindows(); closeAllWindows();
console.log(`[Asshat.GUI] Showing info dialog window. Info: ${infoTitle} - ${infoMessage}`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Showing info dialog window. Info: ${infoTitle} - ${infoMessage}`);
mexui.setInput(true); mexui.setInput(true);
infoDialog.messageLabel.text = infoMessage; infoDialog.messageLabel.text = infoMessage;
infoDialog.window.shown = true; infoDialog.window.shown = true;
@@ -2051,7 +2040,7 @@ let showInfo = function(infoMessage, infoTitle) {
let showNewCharacter = function() { let showNewCharacter = function() {
closeAllWindows(); closeAllWindows();
console.log(`[Asshat.GUI] Showing info dialog window`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Showing info dialog window`);
setChatWindowEnabled(false); setChatWindowEnabled(false);
mexui.setInput(true); mexui.setInput(true);
newCharacter.window.shown = true; newCharacter.window.shown = true;
@@ -2060,28 +2049,28 @@ let showNewCharacter = function() {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let selectNextCharacter = function() { let selectNextCharacter = function() {
console.log(`[Asshat.GUI] Requesting next character info from server for character select window`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Requesting next character info from server for character select window`);
triggerNetworkEvent("ag.nextCharacter"); triggerNetworkEvent("ag.nextCharacter");
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let selectPreviousCharacter = function() { let selectPreviousCharacter = function() {
console.log(`[Asshat.GUI] Requesting previous character info from server for character select window`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Requesting previous character info from server for character select window`);
triggerNetworkEvent("ag.previousCharacter"); triggerNetworkEvent("ag.previousCharacter");
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let selectThisCharacter = function() { let selectThisCharacter = function() {
console.log(`[Asshat.GUI] Tell server the current shown character was selected in character select window`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Tell server the current shown character was selected in character select window`);
triggerNetworkEvent("ag.selectCharacter"); triggerNetworkEvent("ag.selectCharacter");
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let switchCharacterSelect = function(firstName, lastName, placeOfOrigin, dateOfBirth, skinId) { let switchCharacterSelect = function(firstName, lastName, placeOfOrigin, dateOfBirth, skinId) {
console.log(`[Asshat.GUI] Updating character info with data from server`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Updating character info with data from server`);
setChatWindowEnabled(false); setChatWindowEnabled(false);
characterSelect.window.shown = false; characterSelect.window.shown = false;
characterSelect.nameText.text = lastName + ", " + firstName; characterSelect.nameText.text = lastName + ", " + firstName;
@@ -2094,70 +2083,70 @@ let switchCharacterSelect = function(firstName, lastName, placeOfOrigin, dateOfB
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.showLogin", function() { addNetworkHandler("ag.showLogin", function() {
console.log(`[Asshat.GUI] Received request from server to show login window`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Received request from server to show login window`);
showLogin(); showLogin();
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.showRegistration", function() { addNetworkHandler("ag.showRegistration", function() {
console.log(`[Asshat.GUI] Received request from server to show registration window`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Received request from server to show registration window`);
showRegistration(); showRegistration();
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.showNewCharacter", function() { addNetworkHandler("ag.showNewCharacter", function() {
console.log(`[Asshat.GUI] Received request from server to show new character window`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Received request from server to show new character window`);
showNewCharacter(); showNewCharacter();
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.showCharacterSelect", function(firstName, lastName, placeOfOrigin, dateOfBirth, skinId) { addNetworkHandler("ag.showCharacterSelect", function(firstName, lastName, placeOfOrigin, dateOfBirth, skinId) {
console.log(`[Asshat.GUI] Received request from server to show character selection window`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Received request from server to show character selection window`);
showCharacterSelect(firstName, lastName, placeOfOrigin, dateOfBirth, skinId); showCharacterSelect(firstName, lastName, placeOfOrigin, dateOfBirth, skinId);
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.switchCharacterSelect", function(firstName, lastName, placeOfOrigin, dateOfBirth, skinId) { addNetworkHandler("ag.switchCharacterSelect", function(firstName, lastName, placeOfOrigin, dateOfBirth, skinId) {
console.log(`[Asshat.GUI] Received request from server to update character selection window with new info`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Received request from server to update character selection window with new info`);
switchCharacterSelect(firstName, lastName, placeOfOrigin, dateOfBirth, skinId); switchCharacterSelect(firstName, lastName, placeOfOrigin, dateOfBirth, skinId);
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.showError", function(errorMessage, errorTitle) { addNetworkHandler("ag.showError", function(errorMessage, errorTitle) {
console.log(`[Asshat.GUI] Received request from server to show error window`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Received request from server to show error window`);
showError(errorMessage, errorTitle); showError(errorMessage, errorTitle);
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.showPrompt", function(promptMessage, promptTitle) { addNetworkHandler("ag.showPrompt", function(promptMessage, promptTitle) {
console.log(`[Asshat.GUI] Received request from server to show prompt window`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Received request from server to show prompt window`);
showYesNo(promptMessage, promptTitle); showYesNo(promptMessage, promptTitle);
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.showInfo", function(infoMessage) { addNetworkHandler("ag.showInfo", function(infoMessage) {
console.log(`[Asshat.GUI] Received request from server to show info dialog`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Received request from server to show info dialog`);
showInfo(infoMessage); showInfo(infoMessage);
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.loginSuccess", function() { addNetworkHandler("ag.loginSuccess", function() {
console.log(`[Asshat.GUI] Received signal of successful login from server`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Received signal of successful login from server`);
loginSuccess(); loginSuccess();
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.characterSelectSuccess", function() { addNetworkHandler("ag.characterSelectSuccess", function() {
console.log(`[Asshat.GUI] Received signal of successful character selection from server`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Received signal of successful character selection from server`);
characterSelectSuccess(); characterSelectSuccess();
setChatWindowEnabled(true); setChatWindowEnabled(true);
}); });
@@ -2165,32 +2154,32 @@ addNetworkHandler("ag.characterSelectSuccess", function() {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.loginFailed", function(remainingAttempts) { addNetworkHandler("ag.loginFailed", function(remainingAttempts) {
console.log(`[Asshat.GUI] Received signal of failed login from server`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Received signal of failed login from server`);
loginFailed(remainingAttempts); loginFailed(remainingAttempts);
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.registrationSuccess", function() { addNetworkHandler("ag.registrationSuccess", function() {
console.log(`[Asshat.GUI] Received signal of successful registration from server`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Received signal of successful registration from server`);
registrationSuccess(); registrationSuccess();
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.registrationFailed", function(errorMessage) { addNetworkHandler("ag.registrationFailed", function(errorMessage) {
console.log(`[Asshat.GUI] Received signal of failed registration from server`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Received signal of failed registration from server`);
registrationFailed(errorMessage); registrationFailed(errorMessage);
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.guiColour", function(red, green, blue) { addNetworkHandler("ag.guiColour", function(red, green, blue) {
console.log(`[Asshat.GUI] Received new GUI colours from server`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Received new GUI colours from server`);
primaryColour = [red, green, blue]; primaryColour = [red, green, blue];
focusedColour = [red+focusedColourOffset, green+focusedColourOffset, blue+focusedColourOffset]; focusedColour = [red+focusedColourOffset, green+focusedColourOffset, blue+focusedColourOffset];
console.log(`[Asshat.GUI] Initializing MexUI app`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Initializing MexUI app`);
app.init(); app.init();
triggerNetworkEvent("ag.guiReady", true); triggerNetworkEvent("ag.guiReady", true);
}); });

View File

@@ -45,6 +45,8 @@ let renderLogo = false;
let renderSmallGameMessage = false; let renderSmallGameMessage = false;
let renderScoreboard = false; let renderScoreboard = false;
let logLevel = LOG_DEBUG | LOG_INFO | LOG_ERROR | LOG_WARN | LOG_VERBOSE;
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addEvent("OnLocalPlayerEnterSphere", 1); addEvent("OnLocalPlayerEnterSphere", 1);
@@ -99,29 +101,29 @@ addNetworkHandler("ag.connectCamera", function(cameraPosition, cameraLookat) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.restoreCamera", function() { addNetworkHandler("ag.restoreCamera", function() {
console.log(`[Asshat.Main] Camera restored`); logToConsole(LOG_DEBUG, `[Asshat.Main] Camera restored`);
gta.restoreCamera(true); gta.restoreCamera(true);
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.clearPeds", function() { addNetworkHandler("ag.clearPeds", function() {
console.log(`[Asshat.Main] Clearing all self-owned peds ...`); logToConsole(LOG_DEBUG, `[Asshat.Main] Clearing all self-owned peds ...`);
clearSelfOwnedPeds(); clearSelfOwnedPeds();
console.log(`[Asshat.Main] All self-owned peds cleared`); logToConsole(LOG_DEBUG, `[Asshat.Main] All self-owned peds cleared`);
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.logo", function(state) { addNetworkHandler("ag.logo", function(state) {
console.log(`[Asshat.Main] Server logo ${(state) ? "enabled" : "disabled"}`); logToConsole(LOG_DEBUG, `[Asshat.Main] Server logo ${(state) ? "enabled" : "disabled"}`);
renderLogo = state; renderLogo = state;
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.ambience", function(state) { addNetworkHandler("ag.ambience", function(state) {
console.log(`[Asshat.Main] Ambient civilians and traffic ${(state) ? "enabled" : "disabled"}`); logToConsole(LOG_DEBUG, `[Asshat.Main] Ambient civilians and traffic ${(state) ? "enabled" : "disabled"}`);
gta.setTrafficEnabled(state); gta.setTrafficEnabled(state);
gta.setGenerateCarsAroundCamera(state); gta.setGenerateCarsAroundCamera(state);
if(gta.game != GAME_GTA_SA) { if(gta.game != GAME_GTA_SA) {
@@ -163,14 +165,14 @@ function getClosestVehicle(pos) {
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
addNetworkHandler("ag.clearWeapons", function() { addNetworkHandler("ag.clearWeapons", function() {
console.log(`[Asshat.Main] Clearing weapons`); logToConsole(LOG_DEBUG, `[Asshat.Main] Clearing weapons`);
localPlayer.clearWeapons(); localPlayer.clearWeapons();
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.giveWeapon", function(weaponId, ammo, active) { addNetworkHandler("ag.giveWeapon", function(weaponId, ammo, active) {
console.log(`[Asshat.Main] Giving weapon ${weaponId} with ${ammo} ammo`); logToConsole(LOG_DEBUG, `[Asshat.Main] Giving weapon ${weaponId} with ${ammo} ammo`);
localPlayer.giveWeapon(weaponId, ammo, active); localPlayer.giveWeapon(weaponId, ammo, active);
}); });
@@ -515,7 +517,7 @@ addNetworkHandler("ag.money", function(amount) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.removeWorldObject", function(model, position, range) { addNetworkHandler("ag.removeWorldObject", function(model, position, range) {
console.log(`Removing world object ${model} at X: ${position.x}, Y: ${position.x}, Z: ${position.x} with range of ${range}`); logToConsole(LOG_DEBUG, `Removing world object ${model} at X: ${position.x}, Y: ${position.x}, Z: ${position.x} with range of ${range}`);
gta.removeWorldObject(model, position, range); gta.removeWorldObject(model, position, range);
}); });

View File

@@ -9,8 +9,8 @@
// =========================================================================== // ===========================================================================
function initAccountScript() { function initAccountScript() {
console.log("[Asshat.Account]: Initializing account script ..."); logToConsole(LOG_DEBUG, "[Asshat.Account]: Initializing account script ...");
console.log("[Asshat.Account]: Account script initialized!"); logToConsole(LOG_DEBUG, "[Asshat.Account]: Account script initialized!");
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -68,29 +68,29 @@ function toggleAccountGUICommand(command, params, client) {
if(!doesPlayerHaveGUIEnabled(client)) { if(!doesPlayerHaveGUIEnabled(client)) {
getPlayerData(client).accountData.settings = getPlayerData(client).accountData.settings & ~flagValue; getPlayerData(client).accountData.settings = getPlayerData(client).accountData.settings & ~flagValue;
messagePlayerNormal(client, `⚙️ You will now be shown GUI (if enabled on current server)`); 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 { } else {
getPlayerData(client).accountData.settings = getPlayerData(client).accountData.settings | flagValue; 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.`); 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(!isPlayerLoggedIn(client)) {
if(getPlayerData().accountData.databaseId != 0) { if(getPlayerData().accountData.databaseId != 0) {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
showPlayerLoginGUI(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 { } else {
messageClient(`👋 Welcome back to Asshat Gaming RP, ${client.name}! Please /login to continue.`, client, getColourByName("softGreen")); 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 { } else {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
showPlayerRegistrationGUI(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 { } else {
messageClient(`👋 Welcome to Asshat Gaming RP, ${client.name}! Please /register to continue.`, client, getColourByName("softGreen")); 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)) { if(!doesPlayerHaveLogoEnabled(client)) {
getPlayerData(client).accountData.settings = getPlayerData(client).accountData.settings & ~flagValue; 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)`); 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);
updatePlayerShowLogoState(client, false); updatePlayerShowLogoState(client, false);
} else { } else {
getPlayerData(client).accountData.settings = getPlayerData(client).accountData.settings | flagValue; getPlayerData(client).accountData.settings = getPlayerData(client).accountData.settings | flagValue;
messagePlayerNormal(client, `⚙️ You will ${getBoolRedGreenInlineColour(false)}not [#FFFFFF]be shown the server logo.`); 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); updatePlayerShowLogoState(client, false);
} }
@@ -140,11 +140,11 @@ function toggleAccountTwoFactorAuthCommand(command, params, client) {
if(!doesPlayerHaveTwoFactorAuthEnabled(client)) { if(!doesPlayerHaveTwoFactorAuthEnabled(client)) {
getPlayerData(client).accountData.settings = getPlayerData(client).accountData.settings & ~flagValue; 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}`); 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 { } else {
getPlayerData(client).accountData.settings = getPlayerData(client).accountData.settings | flagValue; getPlayerData(client).accountData.settings = getPlayerData(client).accountData.settings | flagValue;
messagePlayerSuccess(client, `You have turned ${getBoolRedGreenInlineColour(false)}OFF [#FFFFFF]two-factor authentication for login.`); 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; return true;
} }
@@ -411,7 +411,7 @@ function saltAccountInfo(name, password) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function loginSuccess(client) { 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; getPlayerData(client).loggedIn = true;
if(doesPlayerHaveStaffPermission(client, "developer") || doesPlayerHaveStaffPermission(client, "manageServer")) { if(doesPlayerHaveStaffPermission(client, "developer") || doesPlayerHaveStaffPermission(client, "manageServer")) {
@@ -423,10 +423,10 @@ function loginSuccess(client) {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
triggerNetworkEvent("ag.showPrompt", client, "You have no characters. Would you like to make one?", "No characters"); triggerNetworkEvent("ag.showPrompt", client, "You have no characters. Would you like to make one?", "No characters");
setEntityData(client, "ag.prompt", AG_PROMPT_CREATEFIRSTCHAR, false); 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 { } else {
messagePlayerAlert(client, `You have no characters. Use /newchar to make one.`); 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 { } else {
showCharacterSelectToClient(client); showCharacterSelectToClient(client);
@@ -559,10 +559,10 @@ function checkLogin(client, password) {
console.warn(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} attempted to login but is not registered`); console.warn(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} attempted to login but is not registered`);
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
triggerNetworkEvent("ag.showRegistration", 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 { } else {
messagePlayerError(client, "Your name is not registered! Use /register to make an account."); 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; 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`); console.warn(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} attempted to login but failed (empty password). ${loginAttemptsRemaining} login attempts remaining`);
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
triggerNetworkEvent("ag.loginFailed", client, `Invalid password! ${loginAttemptsRemaining} tries remaining.`); 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 { } else {
messagePlayerError(client, `You must enter a password! ${loginAttemptsRemaining} tries remaining.`); 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; 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`); console.warn(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} attempted to login but failed (wrong password). ${loginAttemptsRemaining} login attempts remaining`);
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
triggerNetworkEvent("ag.loginFailed", client, `Invalid password! ${loginAttemptsRemaining} tries remaining.`); 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 { } else {
messagePlayerError(client, `Invalid password! ${loginAttemptsRemaining} tries remaining.`); 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; return false;
} }
@@ -602,7 +602,7 @@ addNetworkHandler("ag.checkLogin", checkLogin);
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function checkRegistration(client, password, confirmPassword = "", emailAddress = "") { 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(isPlayerRegistered(client)) {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
@@ -706,11 +706,11 @@ function isValidEmailAddress(emailAddress) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function saveAllClientsToDatabase() { 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) { getClients().forEach(function(client) {
savePlayerToDatabase(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; 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); saveAccountToDatabase(getPlayerData(client).accountData);
if(getPlayerData(client).currentSubAccount != -1) { if(getPlayerData(client).currentSubAccount != -1) {
@@ -739,7 +739,7 @@ function savePlayerToDatabase(client) {
saveSubAccountToDatabase(subAccountData); 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; return true;
} }
@@ -776,19 +776,19 @@ function initClient(client) {
loginSuccess(client); loginSuccess(client);
} else { } else {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { 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); triggerNetworkEvent("ag.showLogin", client);
} else { } 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")); messageClient(`Welcome back to Asshat Gaming RP, ${client.name}! Please /login to continue.`, client, getColourByName("softGreen"));
} }
} }
} else { } else {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { 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); triggerNetworkEvent("ag.showRegistration", client);
} else { } 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")); 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) { 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 tempAccountKeybinds = [];
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
@@ -829,7 +829,7 @@ function loadAccountKeybindsFromDatabase(accountDatabaseID) {
while(dbAssoc = fetchQueryAssoc(dbQuery)) { while(dbAssoc = fetchQueryAssoc(dbQuery)) {
let tempAccountKeyBindData = new serverClasses.keyBindData(dbAssoc); let tempAccountKeyBindData = new serverClasses.keyBindData(dbAssoc);
tempAccountKeybinds.push(tempAccountKeyBindData); 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); freeDatabaseQuery(dbQuery);
@@ -837,14 +837,14 @@ function loadAccountKeybindsFromDatabase(accountDatabaseID) {
disconnectFromDatabase(dbConnection); 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; return tempAccountKeybinds;
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function loadAccountStaffNotesFromDatabase(accountDatabaseID) { 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 tempAccountStaffNotes = [];
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
@@ -858,7 +858,7 @@ function loadAccountStaffNotesFromDatabase(accountDatabaseID) {
while(dbAssoc = fetchQueryAssoc(dbQuery)) { while(dbAssoc = fetchQueryAssoc(dbQuery)) {
let tempAccountStaffNoteData = new serverClasses.accountStaffNoteData(dbAssoc); let tempAccountStaffNoteData = new serverClasses.accountStaffNoteData(dbAssoc);
tempAccountStaffNotes.push(tempAccountStaffNoteData); 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); freeDatabaseQuery(dbQuery);
@@ -866,14 +866,14 @@ function loadAccountStaffNotesFromDatabase(accountDatabaseID) {
disconnectFromDatabase(dbConnection); 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; return tempAccountStaffNotes;
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function loadAccountContactsFromDatabase(accountDatabaseID) { 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 tempAccountContacts = [];
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
@@ -887,7 +887,7 @@ function loadAccountContactsFromDatabase(accountDatabaseID) {
while(dbAssoc = fetchQueryAssoc(dbQuery)) { while(dbAssoc = fetchQueryAssoc(dbQuery)) {
let tempAccountContactData = new serverClasses.accountContactData(dbAssoc); let tempAccountContactData = new serverClasses.accountContactData(dbAssoc);
tempAccountContacts.push(tempAccountContactData); 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); freeDatabaseQuery(dbQuery);
@@ -895,14 +895,14 @@ function loadAccountContactsFromDatabase(accountDatabaseID) {
disconnectFromDatabase(dbConnection); 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; return tempAccountContacts;
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function loadAccountMessagesFromDatabase(accountDatabaseID) { 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 tempAccountMessages = [];
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
@@ -916,7 +916,7 @@ function loadAccountMessagesFromDatabase(accountDatabaseID) {
while(dbAssoc = fetchQueryAssoc(dbQuery)) { while(dbAssoc = fetchQueryAssoc(dbQuery)) {
let tempAccountMessageData = new serverClasses.accountContactData(dbAssoc); let tempAccountMessageData = new serverClasses.accountContactData(dbAssoc);
tempAccountMessages.push(tempAccountMessageData); 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); freeDatabaseQuery(dbQuery);
@@ -924,7 +924,7 @@ function loadAccountMessagesFromDatabase(accountDatabaseID) {
disconnectFromDatabase(dbConnection); 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; return tempAccountMessages;
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -94,7 +94,7 @@ function updatePlayerPing(client) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.arrivedAtBusStop", function(client) { addNetworkHandler("ag.arrivedAtBusStop", function(client) {
console.log(client); logToConsole(LOG_DEBUG, client);
arrivedAtBusStop(client); arrivedAtBusStop(client);
}); });
@@ -102,7 +102,7 @@ addNetworkHandler("ag.arrivedAtBusStop", function(client) {
addNetworkHandler("ag.clientReady", function(client) { addNetworkHandler("ag.clientReady", function(client) {
client.setData("ag.isReady", true, false); 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) { if(client.getData("ag.isStarted") == true) {
initClient(client); initClient(client);
} }
@@ -112,14 +112,14 @@ addNetworkHandler("ag.clientReady", function(client) {
addNetworkHandler("ag.guiReady", function(client) { addNetworkHandler("ag.guiReady", function(client) {
client.setData("ag.guiReady", true, false); 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) { addNetworkHandler("ag.clientStarted", function(client) {
client.setData("ag.isStarted", true, false); 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) { if(client.getData("ag.isReady") == true) {
initClient(client); initClient(client);
} }
@@ -146,7 +146,7 @@ function disableCityAmbienceForPlayer(client) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function clearPlayerOwnedPeds(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); triggerNetworkEvent("ag.clearPeds", client);
} }

View File

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

View File

@@ -11,16 +11,16 @@
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function initEventScript() { function initEventScript() {
console.log("[Asshat.Event]: Initializing event script ..."); logToConsole(LOG_DEBUG, "[Asshat.Event]: Initializing event script ...");
addNetworkHandler("ag.onPlayerEnterVehicle", playerEnteredVehicle); addNetworkHandler("ag.onPlayerEnterVehicle", playerEnteredVehicle);
addNetworkHandler("ag.onPlayerExitVehicle", playerExitedVehicle); 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) { 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)) { if(isIpAddressBanned(ipAddress)) {
messagePlayerError(client, "You are banned from this server!"); messagePlayerError(client, "You are banned from this server!");
return false; return false;
@@ -42,7 +42,7 @@ addEventHandler("OnPlayerJoined", function(event, client) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addEventHandler("OnPlayerQuit", function(event, client, quitReasonId) { 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); //savePlayerToDatabase(client);
resetClientStuff(client); resetClientStuff(client);
@@ -157,7 +157,7 @@ async function playerEnteredVehicle(client) {
return false; 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; getPlayerData(client).lastVehicle = vehicle;
@@ -213,7 +213,7 @@ function playerExitedVehicle(client) {
return false; 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(isPlayerWorking(client)) {
if(isPlayerOnJobRoute(client)) { if(isPlayerOnJobRoute(client)) {

View File

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

View File

@@ -129,8 +129,8 @@ let bindableKeys = {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function initKeyBindScript() { function initKeyBindScript() {
console.log("[Asshat.KeyBind]: Initializing key bind script ..."); logToConsole(LOG_DEBUG, "[Asshat.KeyBind]: Initializing key bind script ...");
console.log("[Asshat.KeyBind]: Key bind script initialized!"); logToConsole(LOG_DEBUG, "[Asshat.KeyBind]: Key bind script initialized!");
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -265,7 +265,7 @@ function playerUsedKeyBind(client, key) {
return false; 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)) { if(doesPlayerHaveKeyBindForKey(client, key)) {
let keyBindData = getPlayerKeyBindForKey(client, key); let keyBindData = getPlayerKeyBindForKey(client, key);
if(keyBindData.enabled) { if(keyBindData.enabled) {

View File

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

View File

@@ -11,8 +11,8 @@
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function initMiscScript() { function initMiscScript() {
console.log("[Asshat.Misc]: Initializing misc script ..."); logToConsole(LOG_DEBUG, "[Asshat.Misc]: Initializing misc script ...");
console.log("[Asshat.Misc]: Misc script initialized successfully!"); logToConsole(LOG_DEBUG, "[Asshat.Misc]: Misc script initialized successfully!");
return true; return true;
} }
@@ -22,7 +22,7 @@ function getPositionCommand(command, params, client) {
let position = client.player.position; let position = client.player.position;
messagePlayerNormal(client, `Your position is: ${position.x.toFixed(2)}, ${position.y.toFixed(2)}, ${position.z.toFixed(2)}`); 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; return true;
} }
@@ -172,7 +172,7 @@ function enterExitPropertyCommand(command, params, client) {
}, 1000); }, 1000);
}, 1100); }, 1100);
removeEntityData(client, "ag.inBusiness"); 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; return true;
} }
@@ -253,7 +253,7 @@ function enterExitPropertyCommand(command, params, client) {
function sendRemovedWorldObjectsToPlayer(client) { function sendRemovedWorldObjectsToPlayer(client) {
for(let i in getGameConfig().removedWorldObjects[getServerGame()]) { 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); triggerNetworkEvent("ag.removeWorldObject", client, getGameConfig().removedWorldObjects[getServerGame()][i].model, getGameConfig().removedWorldObjects[getServerGame()][i].position, getGameConfig().removedWorldObjects[getServerGame()][i].range);
} }
return true; return true;

View File

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

View File

@@ -9,8 +9,8 @@
// =========================================================================== // ===========================================================================
function initSubAccountScript() { function initSubAccountScript() {
console.log("[Asshat.SubAccount]: Initializing subaccount script ..."); logToConsole(LOG_DEBUG, "[Asshat.SubAccount]: Initializing subaccount script ...");
console.log("[Asshat.SubAccount]: SubAccount script initialized!"); logToConsole(LOG_DEBUG, "[Asshat.SubAccount]: SubAccount script initialized!");
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -91,7 +91,7 @@ function saveSubAccountToDatabase(subAccountData) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function createSubAccount(accountId, firstName, lastName, skinId, dateOfBirth, placeOfOrigin) { 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(); let dbConnection = connectToDatabase();
if(dbConnection) { if(dbConnection) {
@@ -127,7 +127,7 @@ function showCharacterSelectToClient(client) {
getPlayerData(client).currentSubAccount = 0; getPlayerData(client).currentSubAccount = 0;
let tempSubAccount = getPlayerData(client).subAccounts[0]; let tempSubAccount = getPlayerData(client).subAccounts[0];
triggerNetworkEvent("ag.showCharacterSelect", client, tempSubAccount.firstName, tempSubAccount.lastName, tempSubAccount.placeOfOrigin, tempSubAccount.dateOfBirth, tempSubAccount.skin); 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 { } else {
//let emojiNumbers = ["➊", "➋", "➌", "➍", "➎", "➏", "➐", "➑", "➒"]; //let emojiNumbers = ["➊", "➋", "➌", "➍", "➎", "➏", "➐", "➑", "➒"];
//let emojiNumbers = ["①", "②", "③", "④", "⑤", "⑥", "⑦", "⑧", "⑨"]; //let emojiNumbers = ["①", "②", "③", "④", "⑤", "⑥", "⑦", "⑧", "⑨"];
@@ -136,7 +136,7 @@ function showCharacterSelectToClient(client) {
getPlayerData(client).subAccounts.forEach(function(subAccount, index) { getPlayerData(client).subAccounts.forEach(function(subAccount, index) {
messagePlayerNormal(client, `${index+1} • [#AAAAAA]${subAccount.firstName} ${subAccount.lastName}`); 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; 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); spawnPlayer(client, getPlayerCurrentSubAccount(client).spawnPosition, getPlayerCurrentSubAccount(client).spawnHeading, getPlayerCurrentSubAccount(client).skin);
getPlayerCurrentSubAccount(client).lastLogin = new Date().getTime(); getPlayerCurrentSubAccount(client).lastLogin = new Date().getTime();

View File

@@ -19,14 +19,14 @@ function updateTimeRule() {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function saveAllServerDataToDatabase() { function saveAllServerDataToDatabase() {
console.log("[Asshat.Utilities]: Saving all server data to database ..."); logToConsole(LOG_DEBUG, "[Asshat.Utilities]: Saving all server data to database ...");
saveAllClansToDatabase(); saveAllClansToDatabase();
saveAllHousesToDatabase(); saveAllHousesToDatabase();
saveAllBusinessesToDatabase(); saveAllBusinessesToDatabase();
saveServerConfigToDatabase(getServerConfig()); saveServerConfigToDatabase(getServerConfig());
saveAllVehiclesToDatabase(); saveAllVehiclesToDatabase();
saveAllClientsToDatabase(); 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 => { return new Promise(resolve => {
for(let i in translationCache[translateFrom][translateTo]) { for(let i in translationCache[translateFrom][translateTo]) {
if(translationCache[translateFrom][translateTo][0] == messageText) { 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]); resolve(translationCache[translateFrom][translateTo][1]);
} }
} }

View File

@@ -1856,7 +1856,7 @@ async function waitUntil(condition) {
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
function resetClientStuff(client) { 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)) { if(!getPlayerData(client)) {
return false; return false;

View File

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

View File

@@ -115,3 +115,21 @@ function isConsole(client) {
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function logToConsole(tempLogLevel, text) {
if(logLevel & tempLogLevel) {
if(tempLogLevel == LOG_ERROR) {
console.error(text);
} else if(tempLogLevel == LOG_WARN) {
console.warn(text);
} else {
console.log(text);
}
return true;
}
return false;
}
// ---------------------------------------------------------------------------

View File

@@ -6,7 +6,7 @@ mexui.native.loadImage = function(imageFilePath, imageName)
var file = openFile(imageFilePath); var file = openFile(imageFilePath);
if(!file) if(!file)
{ {
console.log('ERROR [IMAGE LOAD] - Opening File: '+imageFilePath); logToConsole(LOG_DEBUG, 'ERROR [IMAGE LOAD] - Opening File: '+imageFilePath);
return false; return false;
} }
@@ -19,14 +19,14 @@ mexui.native.loadImage = function(imageFilePath, imageName)
image = graphics.loadBMP(file); image = graphics.loadBMP(file);
else else
{ {
console.log('ERROR [IMAGE LOAD] - Unsupported image file path extension. Currently only supports PNG or BMP.'); logToConsole(LOG_DEBUG, 'ERROR [IMAGE LOAD] - Unsupported image file path extension. Currently only supports PNG or BMP.');
return false; return false;
} }
if(!image) if(!image)
{ {
file.close(); file.close();
console.log('ERROR [IMAGE LOAD] - Reading File: '+imageFilePath); logToConsole(LOG_DEBUG, 'ERROR [IMAGE LOAD] - Reading File: '+imageFilePath);
return false; return false;
} }