diff --git a/scripts/client/afk.js b/scripts/client/afk.js index a30c2083..dfc088fd 100644 --- a/scripts/client/afk.js +++ b/scripts/client/afk.js @@ -28,7 +28,7 @@ addEventHandler("OnFocus", function(event) { if(gta.game != GAME_GTA_SA) { gta.setCiviliansEnabled(true); } - gta.setTrafficEnabled(true); + gta.setTrafficEnabled(true); } }); diff --git a/scripts/client/gui.js b/scripts/client/gui.js index 76da7c1d..dda84891 100644 --- a/scripts/client/gui.js +++ b/scripts/client/gui.js @@ -12,11 +12,18 @@ var app = {}; let robotoFont = "Roboto"; +let mainLogoPath = "files/images/main-logo.png"; + let primaryColour = [200, 200, 200]; +let focusedColour = [200, 200, 200]; +let invalidValueColour = [200, 200, 200]; + +let focusedColourOffset = 50; let windowAlpha = 185; let windowTitleAlpha = 200; let buttonAlpha = 200; +let textInputAlpha = 200; let login = { window: null, @@ -532,7 +539,7 @@ let skinNames = [ [146, "Crack Maker", false], [147, "Businessman", false], [148, "Businesswoman", false], - [149, "INVALID", false], + //[149, "INVALID", false], [150, "Businesswoman", false], [151, "Normal Ped", false], [152, "Prostitute", false], @@ -694,16 +701,16 @@ let skinNames = [ [311, "Melvin Big Smoke Harris (Vest)", false], //[312, "Army Guy", false], [313, "Barry Big Bear Thorne (Fat)", false], - ], + ], [ // Underground - - ], + + ], [ // GTA IV - [-2020305438,"Male Multiplayer",false], - [-641875910,"Female Multiplayer",false], - [-1370810922,"MODEL_SUPERLOD",false], + //[-2020305438,"Male Multiplayer",false], + //[-641875910,"Female Multiplayer",false], + //[-1370810922,"MODEL_SUPERLOD",false], [1853617247,"Anna",false], [-1646893330,"Anthony",false], [1495769888,"Badman",false], @@ -1045,8 +1052,8 @@ let skinNames = [ [-1927496394,"Street Punk 2,",false], [1374242512,"Street Punk 3,",false], [-1139941790,"Tough Guy",false], - [809067472,"Male Tourist",false], - ] + [809067472,"Male Tourist",false], + ] ]; let placesOfOrigin = [ @@ -1059,70 +1066,78 @@ let placesOfOrigin = [ "Blaine County", "Red County", "Bone County", - "Other", + "Other", ]; let characterData = []; let currentCharacter = 0; app.init = function() -{ - //let fontStream = openFile("RoleplayApp/Fonts/Roboto-Regular.ttf"); - //if(fontStream != null) { - // robotoFont = lucasFont.createFont(fontStream, 10.0); - // fontStream.close(); - //} - //robotoFont = lucasFont.createDefaultFont(10.0, "Roboto", "Regular"); +{ console.log(`[Asshat.GUI] Initializing GUI ...`); console.log(`[Asshat.GUI] Creating login GUI ...`); - login.window = mexui.window(game.width/2-150, game.height/2-115, 300, 280, 'LOGIN', { + login.window = mexui.window(game.width/2-150, game.height/2-125, 300, 250, 'LOGIN', { main: { backgroundColour: toColour(0, 0, 0, windowAlpha), + transitionTime: 500, }, title: { textSize: 0.0, textColour: toColour(0, 0, 0, 0), - }, + }, icon: { textSize: 0.0, textColour: toColour(0, 0, 0, 0), - } + }, + focused: { + borderColour: toColour(0, 0, 0, 0), + }, }); login.window.titleBarIconSize = toVector2(0,0); login.window.titleBarHeight = 0; - - login.logoImage = login.window.image(100, 20, 100, 100, "files/images/main-logo.png"); - + + login.logoImage = login.window.image(100, 20, 100, 100, mainLogoPath, { + focused: { + borderColour: toColour(0, 0, 0, 0), + }, + }); + login.messageLabel = login.window.text(20, 135, 260, 20, 'Please enter your password!', { main: { textSize: 10.0, textAlign: 0.5, textColour: toColour(200, 200, 200, 255), textFont: robotoFont, - } + }, + focused: { + borderColour: toColour(0, 0, 0, 0), + }, }); login.passwordInput = login.window.textInput(20, 170, 260, 25, '', { main: { backgroundColour: toColour(0, 0, 0, 120), + borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], textInputAlpha), textColour: toColour(200, 200, 200, 255), textSize: 10.0, textFont: robotoFont, }, caret: { - backgroundColour: toColour(200, 200, 200, 255), + lineColour: toColour(255, 255, 255, 255), }, placeholder: { - backgroundColour: toColour(0, 0, 0, 120), - textColour: toColour(200, 200, 200, 200), + textColour: toColour(200, 200, 200, 150), textSize: 10.0, - textFont: robotoFont, - } + textFont: robotoFont, + }, + focused: { + borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], 255), + }, }); login.passwordInput.masked = true; login.passwordInput.placeholder = "Password"; - + login.loginButton = login.window.button(20, 205, 260, 30, 'LOGIN', { main: { backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha), @@ -1131,47 +1146,35 @@ app.init = function() textFont: robotoFont, textAlign: 0.5, }, - }, checkLogin); - - login.notRegisteredLabel = login.window.text(20, 240, 175, 20, "Don't have an account?", { - main: { - textSize: 10.0, - textAlign: 1.0, - textColour: toColour(200, 200, 200, 255), - textFont: robotoFont, - } - }); - - login.registerButton = login.window.button(205, 242, 75, 15, 'REGISTER', { - main: { - backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha), - textColour: toColour(0, 0, 0, 255), - textSize: 9.0, - textFont: robotoFont, - textAlign: 0.5, + focused: { + borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha), }, - }, showRegistration); + }, checkLogin); - console.log(`[Asshat.GUI] Created login GUI.`); + console.log(`[Asshat.GUI] Created login GUI`); // --------------------------------------------------------------------------------- console.log(`[Asshat.GUI] Creating new character GUI ...`); - + newCharacter.window = mexui.window(game.width/2-215, game.height/2-83, 430, 166, 'New Character', { - main: { + main: { backgroundColour: toColour(0, 0, 0, 120), + transitionTime: 500, }, title: { textSize: 11.0, textColour: toColour(0, 0, 0, 255), backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha), - }, + }, icon: { textSize: 0.0, textColour: toColour(0, 0, 0, 0), backgroundColour: toColour(0, 0, 0, 0), }, + focused: { + borderColour: toColour(0, 0, 0, 0), + }, }); newCharacter.firstNameInput = newCharacter.window.textInput(10, 40, 200, 25, '', { @@ -1180,48 +1183,60 @@ app.init = function() backgroundColour: toColour(0, 0, 0, 200), textColour: toColour(200, 200, 200, 255), textSize: 10.0, - textFont: robotoFont, - }, + textFont: robotoFont, + }, backgroundColour: toColour(0, 0, 0, 200), textColour: toColour(200, 200, 200, 255), textSize: 10.0, textFont: robotoFont, }, caret: { - backgroundColour: toColour(200, 200, 200, 255), + lineColour: toColour(255, 255, 255, 255), }, placeholder: { backgroundColour: toColour(0, 0, 0, 200), textColour: toColour(200, 200, 200, 200), textSize: 10.0, - textFont: robotoFont, - } - }); + textFont: robotoFont, + }, + focused: { + borderColour: toColour(focusedColour[0], focusedColour[1], focusedColour[2], textInputAlpha), + }, + invalidValue: { + borderColour: toColour(invalidValueColour[0], invalidValueColour[1], invalidValueColour[2], textInputAlpha), + }, + }); newCharacter.firstNameInput.placeholder = "First Name"; - + newCharacter.lastNameInput = newCharacter.window.textInput(10, 70, 200, 25, '', { main: { hover: { - backgroundColour: toColour(0, 0, 0, 200), + backgroundColour: toColour(0, 0, 0, textInputAlpha), textColour: toColour(200, 200, 200, 255), textSize: 10.0, - textFont: robotoFont, - }, - backgroundColour: toColour(0, 0, 0, 200), + textFont: robotoFont, + }, + backgroundColour: toColour(0, 0, 0, textInputAlpha), textColour: toColour(200, 200, 200, 255), textSize: 10.0, textFont: robotoFont, }, caret: { - backgroundColour: toColour(200, 200, 200, 255), + lineColour: toColour(255, 255, 255, 255), }, placeholder: { - backgroundColour: toColour(0, 0, 0, 200), - textColour: toColour(200, 200, 200, 200), + backgroundColour: toColour(0, 0, 0, textInputAlpha), + textColour: toColour(150, 150, 150, 200), textSize: 10.0, - textFont: robotoFont, - } - }); + textFont: robotoFont, + }, + focused: { + borderColour: toColour(focusedColour[0], focusedColour[1], focusedColour[2], 255), + }, + invalidValue: { + borderColour: toColour(invalidValueColour[0], invalidValueColour[1], invalidValueColour[2], 255), + }, + }); newCharacter.lastNameInput.placeholder = "Last Name"; newCharacter.dateOfBirth = newCharacter.window.date(10, 130, 200, 25, 'Date of Birth', { @@ -1230,14 +1245,20 @@ app.init = function() backgroundColour: toColour(0, 0, 0, 200), textColour: toColour(200, 200, 200, 255), textSize: 10.0, - textFont: robotoFont, - }, + textFont: robotoFont, + }, backgroundColour: toColour(0, 0, 0, 200), textColour: toColour(200, 200, 200, 255), textSize: 10.0, textFont: robotoFont, - } - }); + }, + focused: { + borderColour: toColour(focusedColour[0], focusedColour[1], focusedColour[2], 255), + }, + invalidValue: { + borderColour: toColour(invalidValueColour[0], invalidValueColour[1], invalidValueColour[2], 255), + }, + }); newCharacter.placeOfOrigin = newCharacter.window.dropDown(10, 100, 200, 25, 'Place of Origin', { main: { @@ -1245,8 +1266,8 @@ app.init = function() backgroundColour: toColour(0, 0, 0, 200), textColour: toColour(200, 200, 200, 255), textSize: 10.0, - textFont: robotoFont, - }, + textFont: robotoFont, + }, backgroundColour: toColour(0, 0, 0, 200), textColour: toColour(200, 200, 200, 255), textSize: 10.0, @@ -1257,91 +1278,72 @@ app.init = function() backgroundColour: toColour(32, 32, 32, 200), textColour: toColour(200, 200, 200, 255), textSize: 10.0, - textFont: robotoFont, - width: 200, - }, + textFont: robotoFont, + width: 200, + }, backgroundColour: toColour(0, 0, 0, 200), textColour: toColour(200, 200, 200, 255), textSize: 10.0, - textFont: robotoFont, + textFont: robotoFont, width: 200, }, - }); + focused: { + borderColour: toColour(focusedColour[0], focusedColour[1], focusedColour[2], 255), + }, + invalidValue: { + borderColour: toColour(invalidValueColour[0], invalidValueColour[1], invalidValueColour[2], 255), + }, + }); for(let i in placesOfOrigin) { newCharacter.placeOfOrigin.item(placesOfOrigin[i]); } - - newCharacter.placeOfOrigin.axis.y.scrollBar.styles.innerBar.backgroundColour = toColour(primaryColour[0], primaryColour[1], primaryColour[2], 200); + + newCharacter.placeOfOrigin.axis.y.scrollBar.styles.innerBar.backgroundColour = toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha); newCharacter.placeOfOrigin.setScrollBarsManual(true); - //if(gta.game == GAME_GTA_III) { - // newCharacter.skinImage = newCharacter.window.image(265, 30, 110, 70, "files/images/skins/gta3/Skin000.png"); - //} else { - // newCharacter.skinImage = newCharacter.window.image(265, 30, 110, 70, "files/images/skins/none.png"); - //} - newCharacter.skinImage = newCharacter.window.image(265, 30, 110, 70, "files/images/skins/none.png"); - + newCharacter.skinImage = newCharacter.window.image(310, 32, 110, 70, "files/images/skins/none.png", { + focused: { + borderColour: toColour(0, 0, 0, 0), + }, + }); + newCharacter.skinDropDown = newCharacter.window.dropDown(220, 100, 200, 25, 'Choose Skin', { main: { hover: { backgroundColour: toColour(0, 0, 0, 200), textColour: toColour(200, 200, 200, 255), textSize: 10.0, - textFont: robotoFont, - }, + textFont: robotoFont, + }, backgroundColour: toColour(0, 0, 0, 120), textColour: toColour(200, 200, 200, 255), textSize: 10.0, textFont: robotoFont, - width: 200, - }, - item: { - backgroundColour: toColour(0, 0, 0, 200), - textColour: toColour(200, 200, 200, 255), - textSize: 10.0, - textFont: robotoFont, width: 200, }, item: { hover: { - backgroundColour: toColour(32, 32, 32, 200), + backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], 150), textColour: toColour(200, 200, 200, 255), textSize: 10.0, - textFont: robotoFont, - width: 200, + textFont: robotoFont, + width: 200, }, backgroundColour: toColour(0, 0, 0, 200), textColour: toColour(200, 200, 200, 255), textSize: 10.0, - textFont: robotoFont, + textFont: robotoFont, width: 200, }, }); - // function() { - //let skinImagePath = skinNames[gta.game][this.selectedEntryIndex][2]; - //if(newCharacter.skinImage != null) { - // newCharacter.skinImage.remove(); - //} - //if(gta.game == GAME_GTA_III) { - // newCharacter.skinImage = newCharacter.window.image(265, 30, 110, 70, "files/images/skins/gta3/" + toString(skinImagePath)); - //} else { - // newCharacter.skinImage = newCharacter.window.image(265, 30, 110, 70, "files/images/skins/none.png"); - //} - - //newCharacter.skinImage = newCharacter.window.image(265, 30, 110, 70, "files/images/skins/none.png"); - //} - - newCharacter.skinDropDown.axis.y.scrollBar.styles.innerBar.backgroundColour = toColour(255, 128, 0, 200); + newCharacter.skinDropDown.axis.y.scrollBar.styles.innerBar.backgroundColour = toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha); newCharacter.skinDropDown.setScrollBarsManual(true); - + for(let i in skinNames[gta.game]) { - //if(skinNames[gta.game][i] != "INVALID") { - newCharacter.skinDropDown.item(skinNames[gta.game][i][1]); - //} + newCharacter.skinDropDown.item(skinNames[gta.game][i][1]); } - //newCharacter.skinDropDown.selectedEntryIndex = 1; newCharacter.createButton = newCharacter.window.button(220, 130, 200, 25, 'CREATE', { main: { @@ -1351,41 +1353,52 @@ app.init = function() textFont: robotoFont, textAlign: 0.5, }, + focused: { + borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha), + }, }, checkNewCharacter); - console.log(`[Asshat.GUI] Creating new character GUI.`); + console.log(`[Asshat.GUI] Created new character GUI`); // --------------------------------------------------------------------------------- - console.log(`[Asshat.GUI] Creating register GUI ...`); - - register.window = mexui.window(game.width/2-130, game.height/2-140, 300, 260, 'Register', { + console.log(`[Asshat.GUI] Creating register GUI ...`); + + register.window = mexui.window(game.width/2-130, game.height/2-115, 300, 230, 'Register', { main: { backgroundColour: toColour(0, 0, 0, windowAlpha), + transitionTime: 500, }, title: { textSize: 0.0, textColour: toColour(0, 0, 0, 0), backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha), - }, + }, icon: { textSize: 0.0, textColour: toColour(0, 0, 0, 0), backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha), } - }); + }); register.window.titleBarIconSize = toVector2(0,0); - register.window.titleBarHeight = 0; - - register.window.image(115, 10, 65, 65, "files/images/main-logo.png"); - + register.window.titleBarHeight = 0; + + register.window.image(115, 10, 65, 65, "files/images/main-logo.png", { + focused: { + borderColour: toColour(0, 0, 0, 0), + }, + }); + register.messageLabel = register.window.text(20, 75, 260, 20, 'Create an account', { main: { textSize: 10.0, textAlign: 0.5, textColour: toColour(200, 200, 200, 255), textFont: robotoFont, - } + }, + focused: { + borderColour: toColour(0, 0, 0, 0), + }, }); register.passwordInput = register.window.textInput(20, 100, 260, 25, '', { @@ -1396,18 +1409,18 @@ app.init = function() textFont: robotoFont, }, caret: { - backgroundColour: toColour(200, 200, 200, 255), + lineColour: toColour(255, 255, 255, 255), }, placeholder: { backgroundColour: toColour(0, 0, 0, 120), textColour: toColour(200, 200, 200, 200), textSize: 10.0, - textFont: robotoFont, + textFont: robotoFont, } }); register.passwordInput.masked = true; register.passwordInput.placeholder = "Password"; - + register.confirmPasswordInput = register.window.textInput(20, 130, 260, 25, '', { main: { backgroundColour: toColour(0, 0, 0, 120), @@ -1416,18 +1429,18 @@ app.init = function() textFont: robotoFont, }, caret: { - backgroundColour: toColour(200, 200, 200, 255), + lineColour: toColour(255, 255, 255, 255), }, placeholder: { backgroundColour: toColour(0, 0, 0, 120), - textColour: toColour(200, 200, 200, 200), + textColour: toColour(150, 150, 150, 200), textSize: 10.0, - textFont: robotoFont, - } + textFont: robotoFont, + } }); register.confirmPasswordInput.masked = true; - register.confirmPasswordInput.placeholder = "Confirm password"; - + register.confirmPasswordInput.placeholder = "Confirm password"; + register.emailInput = register.window.textInput(20, 160, 260, 25, '', { main: { backgroundColour: toColour(0, 0, 0, 120), @@ -1436,68 +1449,53 @@ app.init = function() textFont: robotoFont, }, caret: { - backgroundColour: toColour(200, 200, 200, 255), + lineColour: toColour(255, 255, 255, 255), }, placeholder: { backgroundColour: toColour(0, 0, 0, 120), textColour: toColour(200, 200, 200, 200), textSize: 10.0, - textFont: robotoFont, + textFont: robotoFont, } }); - register.emailInput.placeholder = "Email"; - + register.emailInput.placeholder = "Email"; + register.registerButton = register.window.button(20, 195, 260, 30, 'CREATE ACCOUNT', { main: { - backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], 120), + backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha), textColour: toColour(255, 255, 255, 255), textSize: 12.0, textFont: robotoFont, textAlign: 0.5, }, - }, checkRegistration); - - register.alreadyRegisteredLabel = register.window.text(20, 230, 175, 22, "Already have an account?", { - main: { - textSize: 9.0, - textAlign: 1.0, - textColour: toColour(255, 255, 255, 255), - textFont: robotoFont, - } - }); - - register.loginButton = register.window.button(205, 232, 75, 15, 'LOGIN', { - main: { - backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], 120), - textColour: toColour(255, 255, 255, 255), - textSize: 9.0, - textAlign: 0.5, - textFont: robotoFont, + focused: { + borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha), }, - }, showLogin); + }, checkRegistration); + + console.log(`[Asshat.GUI] Created register GUI`); - console.log(`[Asshat.GUI] Create register GUI ...`); - // --------------------------------------------------------------------------------- - console.log(`[Asshat.GUI] Creating error GUI ...`); - + console.log(`[Asshat.GUI] Creating error GUI ...`); + errorDialog.window = mexui.window(game.width/2-200, game.height/2-70, 400, 140, 'ERROR', { main: { backgroundColour: toColour(0, 0, 0, windowAlpha), + transitionTime: 500, }, title: { textSize: 11.0, textColour: toColour(0, 0, 0, 255), backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha), - }, + }, icon: { textSize: 0.0, textColour: toColour(0, 0, 0, 0), backgroundColour: toColour(0, 0, 0, 0), }, }); - + errorDialog.messageLabel = errorDialog.window.text(15, 50, 370, 20, 'Error Message', { main: { textSize: 10.0, @@ -1506,7 +1504,7 @@ app.init = function() textFont: robotoFont, } }); - + errorDialog.okayButton = errorDialog.window.button(20, 95, 360, 30, 'OK', { main: { backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha), @@ -1516,25 +1514,30 @@ app.init = function() textAlign: 0.5, }, }, closeErrorDialog); - + + console.log(`[Asshat.GUI] Created error GUI ...`); + // --------------------------------------------------------------------------------- - + + console.log(`[Asshat.GUI] Created prompt GUI ...`); + yesNoDialog.window = mexui.window(game.width/2-200, game.height/2-70, 400, 140, 'Question', { main: { backgroundColour: toColour(0, 0, 0, windowAlpha), + transitionTime: 500, }, title: { textSize: 11.0, textColour: toColour(0, 0, 0, 255), backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha), - }, + }, icon: { textSize: 0.0, textColour: toColour(0, 0, 0, 0), backgroundColour: toColour(0, 0, 0, 0), }, }); - + yesNoDialog.messageLabel = yesNoDialog.window.text(15, 50, 370, 20, 'Would you like to answer this question?', { main: { textSize: 10.0, @@ -1543,7 +1546,7 @@ app.init = function() textFont: robotoFont, } }); - + yesNoDialog.yesButton = yesNoDialog.window.button(20, 95, 175, 30, 'YES', { main: { backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha), @@ -1563,9 +1566,13 @@ app.init = function() textAlign: 0.5, }, }, yesNoDialogAnswerNo); - + + console.log(`[Asshat.GUI] Created prompt GUI`); + // --------------------------------------------------------------------------------- - + + console.log(`[Asshat.GUI] Creating info dialog GUI ...`); + infoDialog.window = mexui.window(game.width/2-200, game.height/2-70, 400, 140, 'Information', { main: { backgroundColour: toColour(0, 0, 0, windowAlpha), @@ -1574,14 +1581,14 @@ app.init = function() textSize: 11.0, textColour: toColour(0, 0, 0, 255), backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha), - }, + }, icon: { textSize: 0.0, textColour: toColour(0, 0, 0, 0), backgroundColour: toColour(0, 0, 0, 0), }, }); - + infoDialog.messageLabel = infoDialog.window.text(15, 50, 370, 20, 'Information Message', { main: { textSize: 10.0, @@ -1590,7 +1597,7 @@ app.init = function() textFont: robotoFont, } }); - + infoDialog.okayButton = infoDialog.window.button(20, 95, 360, 30, 'OK', { main: { backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha), @@ -1599,24 +1606,28 @@ app.init = function() textFont: robotoFont, textAlign: 0.5, }, - }, closeInfoDialog); - - // --------------------------------------------------------------------------------- - + }, closeInfoDialog); + + console.log(`[Asshat.GUI] Created info dialog GUI`); + + // --------------------------------------------------------------------------------- + + console.log(`[Asshat.GUI] Creating character select GUI ...`); + characterSelect.window = mexui.window(game.width/2-215, game.height/2-83, 430, 166, 'Select Character', { - main: { + main: { backgroundColour: toColour(0, 0, 0, windowAlpha), }, title: { textSize: 11.0, textColour: toColour(0, 0, 0, 255), backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha), - }, + }, icon: { textSize: 0.0, textColour: toColour(0, 0, 0, 0), backgroundColour: toColour(0, 0, 0, 0), - }, + } }); characterSelect.nameText = characterSelect.window.text(10, 40, 200, 25, 'Lastname, Firstname', { @@ -1625,6 +1636,9 @@ app.init = function() textAlign: 0.0, textColour: toColour(255, 255, 255, 220), textFont: robotoFont, + }, + focused: { + borderColour: toColour(0, 0, 0, 0), } }); @@ -1634,6 +1648,9 @@ app.init = function() textAlign: 0.0, textColour: toColour(255, 255, 255, 220), textFont: robotoFont, + }, + focused: { + borderColour: toColour(0, 0, 0, 0), } }); @@ -1643,6 +1660,9 @@ app.init = function() textAlign: 0.0, textColour: toColour(255, 255, 255, 220), textFont: robotoFont, + }, + focused: { + borderColour: toColour(0, 0, 0, 0), } }); @@ -1654,6 +1674,9 @@ app.init = function() textFont: robotoFont, textAlign: 0.5, }, + focused: { + borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha), + } }, selectThisCharacter); characterSelect.newCharacterButton = characterSelect.window.button(140, 180, 150, 25, 'NEW CHARACTER', { @@ -1664,7 +1687,10 @@ app.init = function() textFont: robotoFont, textAlign: 0.5, }, - }, showNewCharacter); + focused: { + borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha), + } + }, showNewCharacter); characterSelect.previousCharacterButton = characterSelect.window.button(10, 130, 75, 25, '< PREV', { main: { @@ -1674,6 +1700,9 @@ app.init = function() textFont: robotoFont, textAlign: 0.5, }, + focused: { + borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha), + } }, selectPreviousCharacter); characterSelect.nextCharacterButton = characterSelect.window.button(345, 130, 75, 25, 'NEXT >', { @@ -1684,53 +1713,65 @@ app.init = function() textFont: robotoFont, textAlign: 0.5, }, + focused: { + borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha), + } }, selectNextCharacter); - - characterSelect.skinImage = characterSelect.window.image(265, 30, 110, 97, "files/images/skins/none.png"); - + + characterSelect.skinImage = characterSelect.window.image(310, 32, 100, 90, "files/images/skins/none.png", { + focused: { + borderColour: toColour(0, 0, 0, 0), + } + }); + + console.log(`[Asshat.GUI] Created character select GUI`); + // --------------------------------------------------------------------------- - + + console.log(`[Asshat.GUI] All GUI created successfully!`); + closeAllWindows(); }; // --------------------------------------------------------------------------- let checkLogin = function() { + console.log(`[Asshat.GUI] Checking login with server ...`); triggerNetworkEvent("ag.checkLogin", login.passwordInput.lines[0]); } // --------------------------------------------------------------------------- let loginFailed = function(errorMessage) { - //if(loginAttemptsRemaining >= 1) { - login.messageLabel.text = errorMessage; - login.messageLabel.styles.main.textColour = toColour(180, 32, 32, 255); - login.passwordInput.text = ""; - //} else { - // closeAllWindows(); - //} + console.log(`[Asshat.GUI] Server reports login failed`); + login.messageLabel.text = errorMessage; + login.messageLabel.styles.main.textColour = toColour(180, 32, 32, 255); + login.passwordInput.text = ""; } // --------------------------------------------------------------------------- let loginSuccess = function() { + console.log(`[Asshat.GUI] Server reports login was successful`); closeAllWindows(); } // --------------------------------------------------------------------------- let checkRegistration = function() { + console.log(`[Asshat.GUI] Checking registration with server ...`); triggerNetworkEvent("ag.checkRegistration", register.passwordInput.lines[0], register.confirmPasswordInput.lines[0], register.emailInput.lines[0]); } // --------------------------------------------------------------------------- let checkNewCharacter = function() { - let skinId = false; + console.log(`[Asshat.GUI] Checking new character with server ...`); + let skinId = false; if(newCharacter.firstNameInput.lines[0].length < 2) { return false; } - + if(newCharacter.lastNameInput.lines[0].length < 2) { return false; } @@ -1743,9 +1784,9 @@ let checkNewCharacter = function() { placeOfOrigin = 0; } - triggerNetworkEvent("ag.checkNewCharacter", - newCharacter.firstNameInput.lines[0], - newCharacter.lastNameInput.lines[0], + triggerNetworkEvent("ag.checkNewCharacter", + newCharacter.firstNameInput.lines[0], + newCharacter.lastNameInput.lines[0], toString(toString(newCharacter.dateOfBirth.day) + "/" + toString(newCharacter.dateOfBirth.month) + "/" + toString(newCharacter.dateOfBirth.year)), placesOfOrigin[newCharacter.placeOfOrigin.selectedEntryIndex], skinId, @@ -1755,6 +1796,7 @@ let checkNewCharacter = function() { // --------------------------------------------------------------------------- let registrationFailed = function(errorMessage) { + console.log(`[Asshat.GUI] Server reports registration failed. Reason: ${errorMessage}`); register.messageLabel.text = errorMessage; register.messageLabel.styles.main.textColour = toColour(180, 32, 32, 255); register.passwordInput.text = ""; @@ -1765,18 +1807,21 @@ let registrationFailed = function(errorMessage) { // --------------------------------------------------------------------------- let registrationSuccess = function() { + console.log(`[Asshat.GUI] Server reports registration was successful`); closeAllWindows(); } // --------------------------------------------------------------------------- let characterSelectSuccess = function() { + console.log(`[Asshat.GUI] Server reports character selection was successful`); closeAllWindows(); } // --------------------------------------------------------------------------- let closeErrorDialog = function() { + console.log(`[Asshat.GUI] Closing error dialog`); errorDialog.window.shown = false; mexui.setInput(false); } @@ -1784,6 +1829,7 @@ let closeErrorDialog = function() { // --------------------------------------------------------------------------- let closeInfoDialog = function() { + console.log(`[Asshat.GUI] Closing info dialog`); infoDialog.window.shown = false; mexui.setInput(false); } @@ -1791,6 +1837,7 @@ let closeInfoDialog = function() { // --------------------------------------------------------------------------- let closeAllWindows = function() { + console.log(`[Asshat.GUI] Closing all GUI windows`); infoDialog.window.shown = false; errorDialog.window.shown = false; yesNoDialog.window.shown = false; @@ -1805,20 +1852,23 @@ let closeAllWindows = function() { // --------------------------------------------------------------------------- let yesNoDialogAnswerNo = function() { + console.log(`[Asshat.GUI] Responding with answer NO to server prompt`); triggerNetworkEvent("ag.promptAnswerNo"); } // --------------------------------------------------------------------------- let yesNoDialogAnswerYes = function() { + console.log(`[Asshat.GUI] Responding with answer YES to server prompt`); triggerNetworkEvent("ag.promptAnswerYes"); } // --------------------------------------------------------------------------- let showRegistration = function() { - setChatWindowEnabled(false); + console.log(`[Asshat.GUI] Showing registration window`); closeAllWindows(); + setChatWindowEnabled(false); mexui.setInput(true); register.window.shown = true; } @@ -1826,35 +1876,33 @@ let showRegistration = function() { // --------------------------------------------------------------------------- let showLogin = function() { - console.log("login showing"); - setChatWindowEnabled(false); closeAllWindows(); + console.log(`[Asshat.GUI] Showing login window`); + setChatWindowEnabled(false); mexui.setInput(true); login.window.shown = true; - console.log("login shown"); } // --------------------------------------------------------------------------- let showCharacterSelect = function(firstName, lastName, placeOfOrigin, dateOfBirth, skinId) { closeAllWindows(); + console.log(`[Asshat.GUI] Showing character selection window`); setChatWindowEnabled(false); mexui.setInput(true); - characterSelect.nameText.text = lastName + ", " + firstName; characterSelect.dateOfBirthText.text = "Born: " + toString(dateOfBirth); characterSelect.placeOfOrigin.text = "From: " + toString(placeOfOrigin); - - characterSelect.skinImage = characterSelect.window.image(265, 30, 110, 97, "files/images/skins/none.png"); - + characterSelect.skinImage = characterSelect.window.image(310, 32, 100, 90, "files/images/skins/none.png"); characterSelect.window.shown = true; } // --------------------------------------------------------------------------- let showError = function(errorMessage, errorTitle) { - setChatWindowEnabled(false); closeAllWindows(); + console.log(`[Asshat.GUI] Showing error window. Error: ${errorTitle} - ${errorMessage}`); + setChatWindowEnabled(false); mexui.setInput(true); errorDialog.messageLabel.text = errorMessage; errorDialog.window.shown = true; @@ -1864,6 +1912,7 @@ let showError = function(errorMessage, errorTitle) { let showYesNo = function(promptMessage, promptTitle) { closeAllWindows(); + console.log(`[Asshat.GUI] Showing prompt window. Prompt: ${promptTitle} - ${promptMessage}`); mexui.setInput(true); yesNoDialog.messageLabel.text = promptMessage; yesNoDialog.window.shown = true; @@ -1872,8 +1921,8 @@ let showYesNo = function(promptMessage, promptTitle) { // --------------------------------------------------------------------------- let showInfo = function(infoMessage, infoTitle) { - setChatWindowEnabled(false); closeAllWindows(); + console.log(`[Asshat.GUI] Showing info dialog window. Info: ${infoTitle} - ${infoMessage}`); mexui.setInput(true); infoDialog.messageLabel.text = infoMessage; infoDialog.window.shown = true; @@ -1882,8 +1931,9 @@ let showInfo = function(infoMessage, infoTitle) { // --------------------------------------------------------------------------- let showNewCharacter = function() { - setChatWindowEnabled(false); closeAllWindows(); + console.log(`[Asshat.GUI] Showing info dialog window`); + setChatWindowEnabled(false); mexui.setInput(true); newCharacter.window.shown = true; } @@ -1891,91 +1941,104 @@ let showNewCharacter = function() { // --------------------------------------------------------------------------- let selectNextCharacter = function() { + console.log(`[Asshat.GUI] Requesting next character info from server for character select window`); triggerNetworkEvent("ag.nextCharacter"); } // --------------------------------------------------------------------------- let selectPreviousCharacter = function() { + console.log(`[Asshat.GUI] Requesting previous character info from server for character select window`); triggerNetworkEvent("ag.previousCharacter"); } // --------------------------------------------------------------------------- let selectThisCharacter = function() { + console.log(`[Asshat.GUI] Tell server the current shown character was selected in character select window`); triggerNetworkEvent("ag.selectCharacter"); } // --------------------------------------------------------------------------- let switchCharacterSelect = function(firstName, lastName, placeOfOrigin, dateOfBirth, skinId) { + console.log(`[Asshat.GUI] Updating character info with data from server`); setChatWindowEnabled(false); characterSelect.window.shown = false; characterSelect.nameText.text = lastName + ", " + firstName; characterSelect.dateOfBirthText.text = "Born: " + toString(dateOfBirth); characterSelect.placeOfOrigin.text = "From: " + toString(placeOfOrigin); - - characterSelect.skinImage = characterSelect.window.image(265, 30, 110, 97, "files/images/skins/none.png"); + characterSelect.skinImage = characterSelect.window.image(310, 32, 100, 90, "files/images/skins/none.png"); characterSelect.window.shown = true; } // --------------------------------------------------------------------------- addNetworkHandler("ag.showLogin", function() { + console.log(`[Asshat.GUI] Received request from server to show login window`); showLogin(); }); // --------------------------------------------------------------------------- addNetworkHandler("ag.showRegistration", function() { + console.log(`[Asshat.GUI] Received request from server to show registration window`); showRegistration(); }); // --------------------------------------------------------------------------- addNetworkHandler("ag.showNewCharacter", function() { + console.log(`[Asshat.GUI] Received request from server to show new character window`); showNewCharacter(); }); // --------------------------------------------------------------------------- addNetworkHandler("ag.showCharacterSelect", function(firstName, lastName, placeOfOrigin, dateOfBirth, skinId) { + console.log(`[Asshat.GUI] Received request from server to show character selection window`); showCharacterSelect(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`); switchCharacterSelect(firstName, lastName, placeOfOrigin, dateOfBirth, skinId); }); // --------------------------------------------------------------------------- addNetworkHandler("ag.showError", function(errorMessage, errorTitle) { + console.log(`[Asshat.GUI] Received request from server to show error window`); showError(errorMessage, errorTitle); }); // --------------------------------------------------------------------------- addNetworkHandler("ag.showPrompt", function(promptMessage, promptTitle) { + console.log(`[Asshat.GUI] Received request from server to show prompt window`); showYesNo(promptMessage, promptTitle); }); // --------------------------------------------------------------------------- addNetworkHandler("ag.showInfo", function(infoMessage) { + console.log(`[Asshat.GUI] Received request from server to show info dialog`); showInfo(infoMessage); }); // --------------------------------------------------------------------------- addNetworkHandler("ag.loginSuccess", function() { + console.log(`[Asshat.GUI] Received signal of successful login from server`); loginSuccess(); }); // --------------------------------------------------------------------------- addNetworkHandler("ag.characterSelectSuccess", function() { + console.log(`[Asshat.GUI] Received signal of successful character selection from server`); characterSelectSuccess(); setChatWindowEnabled(true); }); @@ -1983,28 +2046,34 @@ addNetworkHandler("ag.characterSelectSuccess", function() { // --------------------------------------------------------------------------- addNetworkHandler("ag.loginFailed", function(remainingAttempts) { + console.log(`[Asshat.GUI] Received signal of failed login from server`); loginFailed(remainingAttempts); }); // --------------------------------------------------------------------------- addNetworkHandler("ag.registrationSuccess", function() { + console.log(`[Asshat.GUI] Received signal of successful registration from server`); registrationSuccess(); }); // --------------------------------------------------------------------------- addNetworkHandler("ag.registrationFailed", function(errorMessage) { + console.log(`[Asshat.GUI] Received signal of failed registration from server`); registrationFailed(errorMessage); }); // --------------------------------------------------------------------------- addNetworkHandler("ag.guiColour", function(red, green, blue) { - console.log("New colours for GUI"); + console.log(`[Asshat.GUI] Received new GUI colours from server`); primaryColour = [red, green, blue]; + focusedColour = [red+focusedColourOffset, green+focusedColourOffset, blue+focusedColourOffset]; + + console.log(`[Asshat.GUI] Initializing MexUI app`); app.init(); - closeAllWindows(); + triggerNetworkEvent("ag.guiReady", true); }); // --------------------------------------------------------------------------- \ No newline at end of file diff --git a/scripts/client/label.js b/scripts/client/label.js index 13a96b67..6f610a7b 100644 --- a/scripts/client/label.js +++ b/scripts/client/label.js @@ -45,11 +45,11 @@ function renderPropertyEntranceLabel(name, position, locked, isBusiness, price) if(propertyLabelNameFont == null) { return false; } - + if(propertyLabelLockedFont == null) { return false; } - + if(localPlayer.position.distance(position) > 7.5) { return false; } @@ -62,9 +62,9 @@ function renderPropertyEntranceLabel(name, position, locked, isBusiness, price) if(price > 0) { text = `For sale: $${price}`; let size = propertyLabelLockedFont.measure(text, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true); - propertyLabelLockedFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, toColour(0, 150, 0, 255), false, true, false, true); - - screenPosition.y -= 18; + propertyLabelLockedFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, toColour(0, 150, 0, 255), false, true, false, true); + + screenPosition.y -= 18; } text = (locked) ? "LOCKED" : "UNLOCKED"; @@ -73,13 +73,13 @@ function renderPropertyEntranceLabel(name, position, locked, isBusiness, price) } let size = propertyLabelLockedFont.measure(text, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true); - propertyLabelLockedFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, (locked) ? lockedColour : unlockedColour, false, true, false, true); + propertyLabelLockedFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, (locked) ? lockedColour : unlockedColour, false, true, false, true); screenPosition.y -= 22; text = name || " "; size = propertyLabelNameFont.measure(text, game.width, 0.0, 0.0, propertyLabelNameFont.size, true, true); - propertyLabelNameFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelNameFont.size, (isBusiness) ? toColour(0, 153, 255, 255) : toColour(17, 204, 17, 255), false, true, false, true); + propertyLabelNameFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelNameFont.size, (isBusiness) ? toColour(0, 153, 255, 255) : toColour(17, 204, 17, 255), false, true, false, true); } // ---------------------------------------------------------------------------- @@ -92,11 +92,11 @@ function renderPropertyExitLabel(position) { if(propertyLabelNameFont == null) { return false; } - + if(propertyLabelLockedFont == null) { return false; } - + if(localPlayer.position.distance(position) > 7.5) { return false; } @@ -107,7 +107,7 @@ function renderPropertyExitLabel(position) { let text = "EXIT"; size = propertyLabelNameFont.measure(text, game.width, 0.0, 0.0, propertyLabelNameFont.size, true, true); - propertyLabelNameFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelNameFont.size, COLOUR_WHITE, false, true, false, true); + propertyLabelNameFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelNameFont.size, COLOUR_WHITE, false, true, false, true); } // ---------------------------------------------------------------------------- @@ -120,11 +120,11 @@ function renderJobLabel(name, position, jobType) { if(jobNameLabelFont == null) { return false; } - + if(jobHelpLabelFont == null) { return false; } - + if(localPlayer.position.distance(position) > 7.5) { return false; } @@ -149,13 +149,13 @@ function renderJobLabel(name, position, jobType) { } let size = jobHelpLabelFont.measure(text, game.width, 0.0, 0.0, jobHelpLabelFont.size, true, true); - jobHelpLabelFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, jobHelpLabelFont.size, COLOUR_YELLOW, false, true, false, true); + jobHelpLabelFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, jobHelpLabelFont.size, COLOUR_YELLOW, false, true, false, true); screenPosition.y -= 18; text = name + " Job"; size = jobNameLabelFont.measure(text, game.width, 0.0, 0.0, jobNameLabelFont.size, true, true); - jobNameLabelFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, jobNameLabelFont.size, COLOUR_WHITE, false, true, false, true); + jobNameLabelFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, jobNameLabelFont.size, COLOUR_WHITE, false, true, false, true); } // ---------------------------------------------------------------------------- @@ -182,14 +182,14 @@ addEventHandler("OnDrawnHUD", function (event) { case AG_LABEL_HOUSE: renderPropertyEntranceLabel(pickups[i].getData("ag.label.name"), pickups[i].position, pickups[i].getData("ag.label.locked"), false, price); break; - + case AG_LABEL_JOB: renderJobLabel(pickups[i].getData("ag.label.name"), pickups[i].position, pickups[i].getData("ag.label.jobType")); break; case AG_LABEL_EXIT: renderPropertyExitLabel(pickups[i].position); - break; + break; } //} //} diff --git a/scripts/client/main.js b/scripts/client/main.js index b0c79bcb..a80d8d14 100644 --- a/scripts/client/main.js +++ b/scripts/client/main.js @@ -72,6 +72,9 @@ bindEventHandler("onResourceStart", thisResource, function(event, resource) { gta.setCiviliansEnabled(false); } + // Run garbage collector every minute + garbageCollectorInterval = setInterval(collectAllGarbage, 1000*60); + addNetworkHandler("ag.passenger", enterVehicleAsPassenger); }); @@ -338,6 +341,12 @@ function processEvent(event, deltaTime) { } }); + getElementsByType(ELEMENT_PICKUP).forEach(function(pickup) { + if(pickup.owner != -1) { + destroyElement(pickup); + } + }); + if(gta.game == GAME_GTA_SA) { if(jobRouteStopSphere != null) { if(position.distance(jobRouteStopSphere.position) <= 2.0) { @@ -381,10 +390,12 @@ addEventHandler("OnDrawnHUD", function (event) { } // Draw logo in corner of screen - if(mainLogo != null && showLogo) { - let logoPos = toVector2(gta.width-132, gta.height-132); - let logoSize = toVector2(128, 128); - drawing.drawRectangle(mainLogo, logoPos, logoSize); + if(mainLogo != null) { + if(showLogo) { + let logoPos = toVector2(gta.width-132, gta.height-132); + let logoSize = toVector2(128, 128); + drawing.drawRectangle(mainLogo, logoPos, logoSize); + } } }); @@ -482,9 +493,7 @@ addNetworkHandler("ag.showBusStop", function(position, colour) { jobRouteStopSphere.colour = colour; } - jobRouteStopBlip = gta.createBlip(position, 0, 2, colour); - }); // --------------------------------------------------------------------------- diff --git a/scripts/client/mouse-camera.js b/scripts/client/mouse-camera.js index 181e0349..ddd7137f 100644 --- a/scripts/client/mouse-camera.js +++ b/scripts/client/mouse-camera.js @@ -429,14 +429,14 @@ addEventHandler("OnProcess", (event, deltaTime) => if(!localPlayer) { return false; } - + if(gta.game >= GAME_GTA_SA) { // We don't need this for GTA SA+ return false; } /* - if(localPlayer.vehicle == null) { + if(localPlayer.vehicle == null) { let newAngle = 0.0; let moveKeyHeld = false; if(isKeyDown(SDLK_w)) { @@ -462,15 +462,15 @@ addEventHandler("OnProcess", (event, deltaTime) => newAngle = Math.PI/2; moveKeyHeld = true; } - + if(moveKeyHeld && !gui.cursorEnabled) { - localPlayer.heading = cameraAngle + newAngle; + localPlayer.heading = cameraAngle + newAngle; } - + if(sdl.getModState()&KMOD_ALT && !gui.cursorEnabled) { if(moveKeyHeld) { let position = getPosInFrontOfPos(localPlayer.position, localPlayer.heading, 1.0); - localPlayer.walkTo(vec3ToVec2(position)); + localPlayer.walkTo(vec3ToVec2(position)); isWalking = true; triggerNetworkEvent("ag.walk", true); } else { @@ -479,7 +479,7 @@ addEventHandler("OnProcess", (event, deltaTime) => } } else { isWalking = false; - triggerNetworkEvent("ag.walk", false); + triggerNetworkEvent("ag.walk", false); } } */ @@ -490,7 +490,7 @@ let IdleTime = 0;//2019 Lucas was here! function processReturnToRestRotation() { //resetCameraRotation();//2019 Lucas was here! - + //2019 Lucas was here! let Target = getCameraTarget(); if (!ShouldReturnToRestRotation(Target)) @@ -652,7 +652,7 @@ function update() positionX += normalX*Distance; positionY += normalY*Distance; positionZ += normalZ*Distance; - + cameraMatrix.m41 = positionX; cameraMatrix.m42 = positionY; cameraMatrix.m43 = positionZ; @@ -680,7 +680,7 @@ function getPosInFrontOfPos(pos, angle, distance) { let x = (pos.x+((Math.cos(angle+(Math.PI/2)))*distance)); let y = (pos.y+((Math.sin(angle+(Math.PI/2)))*distance)); let z = pos.z; - + return new Vec3(x,y,z); } diff --git a/scripts/client/nametag.js b/scripts/client/nametag.js index ccf97542..04e985f1 100644 --- a/scripts/client/nametag.js +++ b/scripts/client/nametag.js @@ -50,16 +50,16 @@ function drawNametag(x, y, health, armour, text, ping, alpha, distance, colour, if(nametagFont == null) { return false; } - + alpha *= 0.75; let width = nametagWidth; health = Math.max(0.0, Math.min(1.0, health)); armour = Math.max(0.0, Math.min(1.0, armour)); - + // Starts at bottom and works it's way up // ------------------------------------------- // Health Bar - + if(gta.game == GAME_GTA_III) { // Mickey Hamfists is ridiculously tall. Raise the nametag for him a bit if(skin == 109) { @@ -70,7 +70,7 @@ function drawNametag(x, y, health, armour, text, ping, alpha, distance, colour, } else { y -= 5; } - + if(health > 0.0) { let hx = x-width/2; let hy = y-10/2; @@ -79,12 +79,12 @@ function drawNametag(x, y, health, armour, text, ping, alpha, distance, colour, let colour = createColour(Math.floor(255.0*alpha), Math.floor(255.0-(health*255.0)), Math.floor(health*255.0), 0); // Health bar colour (varies, depending on health) drawing.drawRectangle(null, [hx+2, hy+2], [(width-4)*health, 10-6], colour, colour, colour, colour); } - + // Armour Bar if (armour > 0.0) { // Go up 10 pixels to draw the next part - y -= 10; + y -= 10; let hx = x-width/2; let hy = y-10/2; let colourB = toColour(255, 0, 0, 0); // Background colour (black) @@ -92,18 +92,18 @@ function drawNametag(x, y, health, armour, text, ping, alpha, distance, colour, let colour = toColour(255, 255, 255, 255); // Armour bar colour (white) drawing.drawRectangle(null, [hx+2, hy+2], [(width-4)*armour, 10-6], colour, colour, colour, colour); } - + y -= 20; - + // Nametag if(nametagFont != null) { let size = nametagFont.measure(text, game.width, 0.0, 0.0, nametagFont.size, false, false); nametagFont.render(text, [x-size[0]/2, y-size[1]/2], game.width, 0.0, 0.0, nametagFont.size, colour, false, false, false, true); } - + // Go up another 10 pixels for the next part - y -= 20; - + y -= 20; + // AFK Status if(afkStatusFont != null) { if(afk) { @@ -119,34 +119,34 @@ function updateNametags(element) { if(localPlayer != null) { let playerPos = localPlayer.position; let elementPos = element.position; - let client = getClientFromPlayerElement(element); - + let client = getClientFromPlayerElement(element); + elementPos[2] += 0.9; - + let screenPos = getScreenFromWorldPosition(elementPos); if (screenPos[2] >= 0.0) { let health = element.health/100.0; if(health > 1.0) { health = 1.0; } - + let armour = element.armour/100.0; if(armour > 1.0) { - armour = 1.0; + armour = 1.0; } - + let distance = playerPos.distance(elementPos); if(distance <= nametagDistance) { if(element.type == ELEMENT_PLAYER) { let name = element.name; let colour = COLOUR_WHITE; - let paused = false; - let ping = -1; - + let paused = false; + let ping = -1; + if(typeof playerNames[element.name] != "undefined") { name = playerNames[element.name]; } - + if(typeof playerPaused[element.name] != "undefined") { paused = playerPaused[element.name]; } @@ -154,10 +154,10 @@ function updateNametags(element) { if(typeof playerColours[element.name] != "undefined") { colour = playerColours[element.name]; } - + if(typeof playerPing[element.name] != "undefined") { ping = playerPing[element.name]; - } + } drawNametag(screenPos[0], screenPos[1], health, armour, name, ping, 1.0-distance/nametagDistance, distance, colour, paused, element.skin); } @@ -182,7 +182,7 @@ addEventHandler("OnDrawnHUD", function(event) { if(gta.game >= GAME_GTA_IV) { return false; } - + getElementsByType(ELEMENT_PLAYER).forEach(function(player) { if(player != localPlayer) { updateNametags(player); diff --git a/scripts/client/scoreboard.js b/scripts/client/scoreboard.js index b4304299..1f525ad4 100644 --- a/scripts/client/scoreboard.js +++ b/scripts/client/scoreboard.js @@ -28,23 +28,23 @@ addEventHandler("OnDrawnHUD", function (event) { if(listFont != null && titleFont != null) { let scoreboardStart = (game.height/2)-(Math.floor(getClients().length/2)*20); let titleSize = titleFont.measure("PLAYERS", game.width, 0.0, 1.0, 10, false, false); - titleFont.render("PLAYERS", [game.width/2, scoreboardStart-50], 0, 0.5, 0.0, titleFont.size, COLOUR_WHITE, false, false, false, true); + titleFont.render("PLAYERS", [game.width/2, scoreboardStart-50], 0, 0.5, 0.0, titleFont.size, COLOUR_WHITE, false, false, false, true); titleSize = titleFont.measure("____________________________", game.width, 0.0, 1.0, 10, false, false); - titleFont.render("____________________________", [game.width/2, scoreboardStart-35], 0, 0.5, 0.0, titleFont.size, COLOUR_WHITE, false, false, false, true); - + titleFont.render("____________________________", [game.width/2, scoreboardStart-35], 0, 0.5, 0.0, titleFont.size, COLOUR_WHITE, false, false, false, true); + let clients = getClients(); for(let i in clients) { if(!clients[i].console) { let name = clients[i].name; let colour = COLOUR_WHITE; - let paused = false; - let ping = "-1"; - + let paused = false; + let ping = "-1"; + if(typeof playerNames[clients[i].name] != "undefined") { name = playerNames[clients[i].name]; } - + if(typeof playerPaused[clients[i].name] != "undefined") { paused = playerPaused[clients[i].name]; } @@ -55,27 +55,27 @@ addEventHandler("OnDrawnHUD", function (event) { if(typeof playerPing[clients[i].name] != "undefined") { ping = toString(playerPing[clients[i].name]); - } - + } + // Player ID let text = String(clients[i].index); let size = listFont.measure(text, 75, 0.0, 1.0, 10, false, false); - listFont.render(text, [game.width/2-100, scoreboardStart + (i*20)], 0, 0.5, 0.0, listFont.size, COLOUR_WHITE, false, false, false, true); - + listFont.render(text, [game.width/2-100, scoreboardStart + (i*20)], 0, 0.5, 0.0, listFont.size, COLOUR_WHITE, false, false, false, true); + // Player Name text = name; size = listFont.measure(text, 100, 0.0, 1.0, 10, false, false); listFont.render(text, [game.width/2, scoreboardStart + (i*20)], 0, 0.5, 0.0, listFont.size, colour, false, false, false, true); - + // Ping text = ping; size = listFont.measure(ping, 75, 0.0, 1.0, 10, false, false); - listFont.render(ping, [game.width/2+100, scoreboardStart + (i*20)], 0, 0.5, 0.0, listFont.size, COLOUR_WHITE, false, false, false, true); - + listFont.render(ping, [game.width/2+100, scoreboardStart + (i*20)], 0, 0.5, 0.0, listFont.size, COLOUR_WHITE, false, false, false, true); + // PAUSED Status (depends on resource "afk") if(paused == true) { size = listFont.measure("PAUSED", 100, 0.0, 1.0, 10, false, false); - listFont.render("PAUSED", [game.width/2+200, scoreboardStart + (i*20)], 0, 0.5, 0.0, listFont.size, pausedColour, false, false, false, true); + listFont.render("PAUSED", [game.width/2+200, scoreboardStart + (i*20)], 0, 0.5, 0.0, listFont.size, pausedColour, false, false, false, true); } } } diff --git a/scripts/client/sync.js b/scripts/client/sync.js index 40a953c0..a2b24c41 100644 --- a/scripts/client/sync.js +++ b/scripts/client/sync.js @@ -18,7 +18,7 @@ addEventHandler("onProcess", function(event, deltaTime) { if(localPlayer != null && localPlayer.getData("ag.spawned") != null) { if(localPlayer.health <= 0) { localPlayer.clearWeapons(); - triggerNetworkEvent("ag.player.death", localPlayer.position, localPlayer.heading.toFixed(2)); + triggerNetworkEvent("ag.player.death", localPlayer.position); } } }); diff --git a/scripts/server/account.js b/scripts/server/account.js index b8a6235d..35d1be47 100644 --- a/scripts/server/account.js +++ b/scripts/server/account.js @@ -20,12 +20,12 @@ function loginCommand(command, params, client) { messagePlayerError(client, "Your name is not registered! Use /register to make an account."); return false; } - + if(areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - + checkLogin(client, params); return true; } @@ -34,7 +34,7 @@ function loginCommand(command, params, client) { function autoLoginByIPCommand(command, params, client) { let flagValue = getAccountSettingsFlagValue("autoLoginIP"); - + if(isAccountAutoIPLoginEnabled(getPlayerData(client).accountData)) { getPlayerData(client).accountData.settings = getPlayerData(client).accountData.settings & ~flagValue; messagePlayerSuccess(client, `You will not be automatically logged in via your current IP (${client.ip})`); @@ -49,7 +49,7 @@ function autoLoginByIPCommand(command, params, client) { function autoSelectLastCharacterCommand(command, params, client) { let flagValue = getAccountSettingsFlagValue("autoSelectLastCharacter"); - + if(doesPlayerHaveAutoSelectLastCharacterEnabled(client)) { getPlayerData(client).accountData.settings = getPlayerData(client).accountData.settings & ~flagValue; messagePlayerSuccess(client, `You will not be automatically spawned as your last used character`); @@ -64,7 +64,7 @@ function autoSelectLastCharacterCommand(command, params, client) { function toggleAccountGUICommand(command, params, client) { let flagValue = getAccountSettingsFlagValue("noGUI"); - + if(!doesPlayerHaveGUIEnabled(client)) { getPlayerData(client).accountData.settings = getPlayerData(client).accountData.settings & ~flagValue; messagePlayerNormal(client, `⚙️ You will now be shown GUI (if enabled on current server)`); @@ -101,7 +101,7 @@ function toggleAccountGUICommand(command, params, client) { function toggleAccountServerLogoCommand(command, params, client) { let flagValue = getAccountSettingsFlagValue("noServerLogo"); - + if(!doesPlayerHaveLogoEnabled(client)) { getPlayerData(client).accountData.settings = getPlayerData(client).accountData.settings & ~flagValue; messagePlayerNormal(client, `⚙️ You will ${getBoolRedGreenInlineColour(true)}now [#FFFFFF]be shown the server logo (if enabled on current server)`); @@ -113,7 +113,7 @@ function toggleAccountServerLogoCommand(command, params, client) { console.log(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} has toggled the server logo OFF for their account`); triggerNetworkEvent("ag.logo", client, false); } - + return true; } @@ -123,7 +123,7 @@ function toggleAccountServerLogoCommand(command, params, client) { // TO-DO: Make GUI, add command to generate code to add to auth app and command to input code returned by auth app function toggleAccountTwoFactorAuthCommand(command, params, client) { let flagValue = getAccountSettingsFlagValue("twoStepAuth"); - + if(getPlayerData(client).emailAddress != "") { messagePlayerError(client, "You need to add your email to your account to use two-factor authentication."); messagePlayerTip(client, "[#FFFFFF]Use [#AAAAAA]/setemail [#FFFFFF]to add your email."); @@ -132,7 +132,7 @@ function toggleAccountTwoFactorAuthCommand(command, params, client) { if(!isValidEmailAddress(getPlayerData(client).emailAddress)) { messagePlayerError(client, "The email you previously added is not valid."); - messagePlayerTip(client, "[#FFFFFF]Use [#AAAAAA]/setemail [#FFFFFF]to add a valid email."); + messagePlayerTip(client, "[#FFFFFF]Use [#AAAAAA]/setemail [#FFFFFF]to add a valid email."); return false; } @@ -155,12 +155,12 @@ function registerCommand(command, params, client) { messagePlayerError(client, "Your name is already registered!"); return false; } - + if(areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - + checkRegistration(client, params); //getPlayerData(client).accountData = accountData; //messagePlayerSuccess(client, "Your account has been created!"); @@ -183,13 +183,13 @@ function changePasswordCommand(command, params, client) { messagePlayerError(client, "The old password is invalid!"); return false; } - + if(!doesPasswordMeetRequirements(newPassword)) { messagePlayerError(client, "The new password must meet the requirements!"); messagePlayerInfo(client, "Passwords must have at least one capital letter, one lowercase letter, and one number!"); return false; } - + getPlayerData(client).accountData.password = hashAccountPassword(getPlayerData(client).accountData.name, params); messagePlayerSuccess(client, "Your password has been changed!"); } @@ -207,12 +207,12 @@ function setAccountEmailCommand(command, params, client) { let splitParams = params.split(" "); let emailAddress = splitParams[0]; - + if(!isValidEmailAddress(emailAddress)) { messagePlayerError(client, `The email '${emailAddress} is not valid!`); return false; } - + // TO-DO: Command (like /verifyemail or use this one for second step too) to input verification code sent to email. //getPlayerData(client).accountData.emailAddress = emailAddress; messagePlayerSuccess(client, "Your password has been changed!"); @@ -231,12 +231,12 @@ function setAccountDiscordCommand(command, params, client) { let splitParams = params.split(" "); let discordName = splitParams[0]; - + if(!isValidEmailAddress(emailAddress)) { messagePlayerError(client, `The discord '${discordName} is not valid!`); return false; } - + // TO-DO: Command (like /verifyemail or use this one for second step too) to input verification code sent to email. //getPlayerData(client).accountData.emailAddress = emailAddress; //messagePlayerSuccess(client, "Your discord account has been attached to your game account!"); @@ -268,7 +268,7 @@ function isPlayerRegistered(client) { return true; } } - + return false; } @@ -285,7 +285,7 @@ function isAccountPasswordCorrect(accountData, password) { if(accountData.password == password) { return true; } - + return false; } @@ -295,7 +295,7 @@ function loadAccountFromName(accountName, fullLoad = false) { let dbConnection = connectToDatabase(); if(dbConnection) { accountName = escapeDatabaseString(dbConnection, accountName); - let dbQueryString = `SELECT * FROM acct_main WHERE acct_name = '${accountName}' LIMIT 1;`; + let dbQueryString = `SELECT *, INET_NTOA(acct_ip) AS ipstring FROM acct_main WHERE acct_name = '${accountName}' LIMIT 1;`; let dbQuery = queryDatabase(dbConnection, dbQueryString); if(dbQuery) { if(dbQuery.numRows > 0) { @@ -313,7 +313,7 @@ function loadAccountFromName(accountName, fullLoad = false) { } disconnectFromDatabase(dbConnection); } - + return false; } @@ -322,7 +322,7 @@ function loadAccountFromName(accountName, fullLoad = false) { function loadAccountFromId(accountId, fullLoad = false) { let dbConnection = connectToDatabase(); if(dbConnection) { - let dbQueryString = `SELECT *, INET_NTOA(acct_ip) AS ip FROM acct_main WHERE acct_id = ${accountId} LIMIT 1;`; + let dbQueryString = `SELECT *, INET_NTOA(acct_ip) AS ipstring FROM acct_main WHERE acct_id = ${accountId} LIMIT 1;`; let dbQuery = queryDatabase(dbConnection, dbQueryString); if(dbQuery) { let dbAssoc = fetchQueryAssoc(dbQuery); @@ -339,7 +339,7 @@ function loadAccountFromId(accountId, fullLoad = false) { } disconnectFromDatabase(dbConnection); } - + return false; } @@ -349,27 +349,27 @@ function getAccountHashingFunction() { switch(toLowerCase(getGlobalConfig().accountPasswordHash)) { case "md5": return module.hashing.md5; - + case "sha1": return module.hashing.sha1; case "sha224": - return module.hashing.sha224; - + return module.hashing.sha224; + case "sha256": - return module.hashing.sha256; + return module.hashing.sha256; case "sha384": - return module.hashing.sha384; + return module.hashing.sha384; case "sha512": - return module.hashing.sha512; + return module.hashing.sha512; case "ripemd128": - return module.hashing.ripemd128; + return module.hashing.ripemd128; case "ripemd160": - return module.hashing.ripemd160; + return module.hashing.ripemd160; case "ripemd256": return module.hashing.ripemd256; @@ -378,7 +378,7 @@ function getAccountHashingFunction() { return module.hashing.ripemd320; case "whirlpool": - return module.hashing.whirlpool; + return module.hashing.whirlpool; } } @@ -389,7 +389,7 @@ function isNameRegistered(name) { if(accountData.databaseId > 0) { return true; } - + return false; } @@ -430,7 +430,7 @@ function loginSuccess(client) { } else { showCharacterSelectToClient(client); } - + getPlayerData(client).accountData.ipAddress = client.ip; sendRemovedWorldObjectsToPlayer(client); @@ -443,7 +443,7 @@ function loginSuccess(client) { function saveAccountToDatabase(accountData) { let dbConnection = connectToDatabase(); - if(dbConnection) { + if(dbConnection) { let safePassword = escapeDatabaseString(dbConnection, accountData.password); let safeStaffTitle = escapeDatabaseString(dbConnection, accountData.staffTitle); let safeEmailAddress = escapeDatabaseString(dbConnection, accountData.emailAddress); @@ -460,7 +460,7 @@ function saveAccountToDatabase(accountData) { function saveAccountKeyBindsDatabase(keyBindData) { let dbConnection = connectToDatabase(); - if(dbConnection) { + if(dbConnection) { let safeCommandString = escapeDatabaseString(dbConnection, keyBindData.commandString); if(keyBindData.databaseId == 0) { let dbQueryString = `INSERT INTO acct_hotkey (acct_hotkey_cmdstr, acct_hotkey_key, acct_hotkey_down, acct_hotkey_enabled) VALUES ('${safeCommandString}', ${keyBindData.key}, ${boolToInt(keyBindData.keyState)}, ${boolToInt(keyBindData.enabled)}, ${keyBindData.account}`; @@ -470,7 +470,7 @@ function saveAccountKeyBindsDatabase(keyBindData) { } else { let dbQueryString = `UPDATE acct_hotkey SET acct_hotkey_cmdstr='${safeCommandString}', acct_hotkey_key=${keyBindData.key}, acct_hotkey_down=${boolToInt(keyBindData.keyState)}, acct_hotkey_enabled=${boolToInt(keyBindData.enabled)} WHERE acct_hotkey_id=${keyBindData.databaseId}`; let dbQuery = queryDatabase(dbConnection, dbQueryString); - freeDatabaseQuery(dbQuery); + freeDatabaseQuery(dbQuery); } disconnectFromDatabase(dbConnection); @@ -481,7 +481,7 @@ function saveAccountKeyBindsDatabase(keyBindData) { function saveAccountStaffNotesDatabase(staffNoteData) { let dbConnection = connectToDatabase(); - if(dbConnection) { + if(dbConnection) { let safeNoteContent = escapeDatabaseString(dbConnection, staffNoteData.note); if(staffNoteData.databaseId == 0) { let dbQueryString = `INSERT INTO acct_note (acct_note_message, acct_note_who_added, acct_note_when_added, acct_note_server, acct_note_acct) VALUES ('${safeNoteContent}', ${staffNoteData.whoAdded}, UNIX_TIMESTAMP(), ${getServerId()}, ${staffNoteData.account}`; @@ -499,7 +499,7 @@ function saveAccountStaffNotesDatabase(staffNoteData) { /* function saveAccountContactsDatabase(accountContactData) { let dbConnection = connectToDatabase(); - if(dbConnection) { + if(dbConnection) { let safeNoteContent = escapeDatabaseString(dbConnection, accountContactData.note); if(accountContactData.databaseId == 0) { let dbQueryString = `INSERT INTO acct_contact (acct_contact_note, acct_contact_, acct_note_when_added, acct_note_server, acct_note_acct) VALUES ('${safeNoteContent}', ${staffNoteData.whoAdded}, UNIX_TIMESTAMP(), ${getServerId()}, ${staffNoteData.account}`; @@ -509,7 +509,7 @@ function saveAccountContactsDatabase(accountContactData) { }// else { // let dbQueryString = `UPDATE acct_hotkey SET acct_hotkey_cmdstr='${safeCommandString}', acct_hotkey_key=${keyBindData.key}, acct_hotkey_down=${boolToInt(keyBindData.keyState)}, acct_hotkey_enabled=${boolToInt(keyBindData.enabled)} WHERE acct_hotkey_id=${keyBindData.databaseId}`; // let dbQuery = queryDatabase(dbConnection, dbQueryString); - // freeDatabaseQuery(dbQuery); + // freeDatabaseQuery(dbQuery); //} disconnectFromDatabase(dbConnection); @@ -544,16 +544,16 @@ function checkLogin(client, password) { let loginAttemptsRemaining = getEntityData(client, "ag.loginAttemptsRemaining")-1; if(isPlayerLoggedIn(client)) { + console.warn(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} attempted to login but is already logged in`); if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { triggerNetworkEvent("ag.loginSuccess", client); - console.log(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} has successfully logged in`); } else { messagePlayerError(client, "You are already logged in!"); - console.warn(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} attempted to login but is already logged in`); } + return false; } - + if(!isPlayerRegistered(client)) { console.warn(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} attempted to login but is not registered`); if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { @@ -562,22 +562,22 @@ function checkLogin(client, password) { } else { messagePlayerError(client, "Your name is not registered! Use /register to make an account."); console.log(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the register message (GUI disabled)`); - } + } return false; } if(areParamsEmpty(password)) { console.warn(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} attempted to login but failed (empty password). ${loginAttemptsRemaining} login attempts remaining`); if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { - triggerNetworkEvent("ag.loginFailed", client, `Invalid password! ${loginAttemptsRemaining} tries remaining.`); - console.log(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI with ${loginAttemptsRemaining} login attempts remaining alert.`); + 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.`); } else { messagePlayerError(client, `You must enter a password! ${loginAttemptsRemaining} tries remaining.`); console.log(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled) with ${loginAttemptsRemaining} login attempts remaining alert.`); } return false; } - + if(!isAccountPasswordCorrect(getPlayerData(client).accountData, hashAccountPassword(client.name, password))) { console.warn(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} attempted to login but failed (wrong password). ${loginAttemptsRemaining} login attempts remaining`); if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { @@ -589,7 +589,7 @@ function checkLogin(client, password) { } return false; } - + if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { triggerNetworkEvent("ag.loginSuccess", client); } @@ -650,7 +650,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress return false; } } - + if(!doesPasswordMeetRequirements(password)) { if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { // Work on this later. Function should return true by default anyway for now. @@ -675,7 +675,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress } else { messagePlayerAlert(client, "Something went wrong. Your account could not be created!"); } - + messagePlayerAlert(client, "Asshat Gaming staff have been notified of the problem and will fix it shortly."); return false; } @@ -685,7 +685,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress messagePlayerSuccess(client, "Your account has been created!"); messagePlayerAlert(client, "To play on the server, you will need to make a character."); - + if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { triggerNetworkEvent("ag.registrationSuccess", client); triggerNetworkEvent("ag.showPrompt", client, "You have no characters. Would you like to make one?", "No Characters"); @@ -718,7 +718,7 @@ function savePlayerToDatabase(client) { if(getPlayerData(client) == null) { return false; } - + if(!getPlayerData(client).loggedIn) { return false; } @@ -755,7 +755,7 @@ function initClient(client) { showConnectCameraToPlayer(client); messageClient(`Please wait ...`, client, getColourByName("softGreen")); - + setTimeout(function() { let sessionId = saveSessionToDatabase(client); setEntityData(client, "ag.session", sessionId, false); @@ -763,7 +763,7 @@ function initClient(client) { clearChatBox(client); let tempAccountData = loadAccountFromName(client.name, true); let tempSubAccounts = loadSubAccountsFromAccount(tempAccountData.databaseId); - + getServerData().clients[client.index] = new serverClasses.clientData(client, tempAccountData, tempSubAccounts); if(tempAccountData != false) { @@ -818,7 +818,7 @@ function loadAccountKeybindsFromDatabase(accountDatabaseID) { let dbConnection = connectToDatabase(); let dbQuery = null; let dbAssoc; - + if(dbConnection) { dbQuery = queryDatabase(dbConnection, `SELECT * FROM acct_hotkey WHERE acct_hotkey_enabled = 1 AND acct_hotkey_acct = ${accountDatabaseID}`); if(dbQuery) { @@ -847,7 +847,7 @@ function loadAccountStaffNotesFromDatabase(accountDatabaseID) { let dbConnection = connectToDatabase(); let dbQuery = null; let dbAssoc; - + if(dbConnection) { dbQuery = queryDatabase(dbConnection, "SELECT * FROM `acct_note` WHERE `acct_note_deleted` = 0 AND `acct_note_acct` = " + toString(accountDatabaseID)); if(dbQuery) { @@ -876,7 +876,7 @@ function loadAccountContactsFromDatabase(accountDatabaseID) { let dbConnection = connectToDatabase(); let dbQuery = null; let dbAssoc; - + if(dbConnection) { dbQuery = queryDatabase(dbConnection, "SELECT * FROM `acct_contact` WHERE `acct_contact_deleted` = 0 AND `acct_contact_acct` = " + toString(accountDatabaseID)); if(dbQuery) { @@ -905,7 +905,7 @@ function loadAccountMessagesFromDatabase(accountDatabaseID) { let dbConnection = connectToDatabase(); let dbQuery = null; let dbAssoc; - + if(dbConnection) { dbQuery = queryDatabase(dbConnection, "SELECT * FROM `acct_msg` WHERE `acct_msg_deleted` = 0 AND `acct_msg_acct` = " + toString(accountDatabaseID)); if(dbQuery) { diff --git a/scripts/server/anticheat.js b/scripts/server/anticheat.js index a2de3d33..aa7e9713 100644 --- a/scripts/server/anticheat.js +++ b/scripts/server/anticheat.js @@ -26,7 +26,7 @@ function loadAntiCheatGameScriptWhiteListFromDatabase() { if(dbQuery.numRows > 0) { let dbAssoc = fetchQueryAssoc(dbQuery); let tempWhiteListedGameScriptData = new serverClasses.whiteListedGameScriptData(dbAssoc); - + tempWhiteListedGameScripts.push(tempWhiteListedGameScriptData); console.log(`[Asshat.AntiCheat] Whitelisted game script '${tempWhiteListedGameScriptData.scriptName}' loaded successfully!`); } @@ -51,7 +51,7 @@ function loadAntiCheatGameScriptBlackListFromDatabase() { if(dbQuery.numRows > 0) { let dbAssoc = fetchQueryAssoc(dbQuery); let tempBlackListedGameScriptData = new serverClasses.blackListedGameScriptData(dbAssoc); - + tempBlackListedGameScripts.push(tempBlackListedGameScriptData); console.log(`[Asshat.AntiCheat] Blacklisted game script '${tempBlackListedGameScriptData.scriptName}' loaded successfully!`); } diff --git a/scripts/server/ban.js b/scripts/server/ban.js index 9ecd2d0f..ebf93416 100644 --- a/scripts/server/ban.js +++ b/scripts/server/ban.js @@ -55,7 +55,7 @@ function subAccountBanCommand(command, params, client, fromDiscord) { messagePlayerError(client, "You cannot ban this person!"); return false; } - + let splitParams = params.split(" "); let targetClient = getPlayerFromParams(splitParams[0]); let reason = splitParams.slice(1).join(" "); @@ -77,14 +77,14 @@ function ipBanCommand(command, params, client, fromDiscord) { if(doesPlayerHaveStaffPermission(targetClient, "ManageServer") || doesPlayerHaveStaffPermission(targetClient, "Developer")) { messagePlayerError(client, "You cannot ban this person!"); return false; - } - + } + let splitParams = params.split(" "); let targetClient = getPlayerFromParams(splitParams[0]); - let reason = splitParams.slice(1).join(" "); + let reason = splitParams.slice(1).join(" "); messageAdminAction(`${targetClient.name} has been banned from the server (IP ban).`); - banIPAddress(targetClient.ip, getPlayerData(client).accountData.databaseId, reason); + banIPAddress(targetClient.ip, getPlayerData(client).accountData.databaseId, reason); server.banIP(targetClient.ip); targetClient.disconnect(); } @@ -102,14 +102,14 @@ function subNetBanCommand(command, params, client, fromDiscord) { messagePlayerError(client, "You cannot ban this person!"); return false; } - + let splitParams = params.split(" "); let targetClient = getPlayerFromParams(splitParams[0]); let octetAmount = Number(splitParams[1]); let reason = splitParams.slice(2).join(" "); messageAdminAction(`${targetClient.name} has been banned from the server (subnet ban).`); - banSubNet(targetClient.ip, getSubNet(targetClient.ip, octetAmount), getPlayerData(client).accountData.databaseId, reason); + banSubNet(targetClient.ip, getSubNet(targetClient.ip, octetAmount), getPlayerData(client).accountData.databaseId, reason); } // --------------------------------------------------------------------------- @@ -254,7 +254,7 @@ function isSubAccountBanned(subAccountId) { } } } - + return false; } @@ -269,7 +269,7 @@ function isIpAddressBanned(ipAddress) { } } } - + return false; } diff --git a/scripts/server/bitflag.js b/scripts/server/bitflag.js index 6e54ab0d..aa08c06f 100644 --- a/scripts/server/bitflag.js +++ b/scripts/server/bitflag.js @@ -23,22 +23,22 @@ let serverBitFlags = { let serverBitFlagKeys = { staffFlagKeys: [ - "none", - "basicModeration", - "manageHouses", - "manageVehicles", - "manageBusinesses", - "manageFactions", - "manageClans", - "manageServer", + "none", + "basicModeration", + "manageHouses", + "manageVehicles", + "manageBusinesses", + "manageFactions", + "manageClans", + "manageServer", "manageAdmins", "manageJobs", "developer", ], moderationFlagKeys: [ - "none", - "muted", - "frozen", + "none", + "muted", + "frozen", "hackerBox", "jobBanned", "ammuBanned", @@ -47,47 +47,47 @@ let serverBitFlagKeys = { "gunBanned", ], factionFlagKeys: [ - "none", - "police", - "medical", - "fire", + "none", + "police", + "medical", + "fire", "government" ], clanFlagKeys: [ - "none", - "illegal", - "legal", - "mafia", - "streetGang", - "weapons", - "drugs", - "humanTrafficking", - "vigilante", + "none", + "illegal", + "legal", + "mafia", + "streetGang", + "weapons", + "drugs", + "humanTrafficking", + "vigilante", "hitContracts" ], clanPermissionFlagKeys: [ - "none", - "inviteMember", - "removeMember", - "memberRank", - "memberFlags", - "memberTag", - "memberTitle", - "rankFlags", - "rankTag", + "none", + "inviteMember", + "removeMember", + "memberRank", + "memberFlags", + "memberTag", + "memberTitle", + "rankFlags", + "rankTag", "rankTitle", "clanTag", - "clanName", + "clanName", "manageVehicles", "manageHouses", "manageBusinesses", "owner", ], accountSettingsFlagKeys: [ - "none", - "useWhiteList", - "useBlackList", - "twoStepAuth", + "none", + "useWhiteList", + "useBlackList", + "twoStepAuth", "authAttemptAlert", "noGUI", "autoLoginIP", @@ -122,14 +122,14 @@ function createBitFlagTable(keyNames) { let bitVal = 0; let bitTable = {}; let incVal = 1; - + for(let i in keyNames) { let key = keyNames[i]; bitTable[key] = bitVal; bitVal = 1 << incVal; incVal++; } - return bitTable; + return bitTable; } // --------------------------------------------------------------------------- @@ -204,7 +204,7 @@ function getStaffFlagValue(flagName) { if(flagName == "all") { return -1; } - + if(typeof serverBitFlags.staffFlags[flagName] === "undefined") { return false; } @@ -218,7 +218,7 @@ function getClanFlagValue(flagName) { if(flagName == "all") { return -1; } - + if(typeof getServerBitFlags().clanFlags[flagName] === "undefined") { return false; } @@ -232,7 +232,7 @@ function getAccountSettingsFlagValue(flagName) { if(flagName == "all") { return -1; } - + if(typeof serverBitFlags.accountSettingsFlags[flagName] === "undefined") { return false; } @@ -246,7 +246,7 @@ function getAccountFlagsFlagValue(flagName) { if(flagName == "all") { return -1; } - + if(typeof serverBitFlags.accountFlags[flagName] === "undefined") { return false; } diff --git a/scripts/server/business.js b/scripts/server/business.js index 7b34b6d0..a6b9931c 100644 --- a/scripts/server/business.js +++ b/scripts/server/business.js @@ -31,7 +31,7 @@ function loadBusinessFromId(businessId) { } disconnectFromDatabase(dbConnection); } - + return false; } @@ -44,7 +44,7 @@ function loadBusinessesFromDatabase() { let dbConnection = connectToDatabase(); let dbQuery = null; let dbAssoc; - + if(dbConnection) { dbQuery = queryDatabase(dbConnection, `SELECT * FROM biz_main WHERE biz_server = ${getServerId()}`); if(dbQuery) { @@ -74,7 +74,7 @@ function loadBusinessLocationsFromDatabase(businessId) { let dbConnection = connectToDatabase(); let dbQuery = null; let dbAssoc; - + if(dbConnection) { dbQuery = queryDatabase(dbConnection, "SELECT * FROM `biz_loc` WHERE `biz_loc_biz` = " + toString(businessId)); if(dbQuery) { @@ -103,7 +103,9 @@ function createBusinessCommand(command, params, client) { createBusinessEntrancePickup(getServerData().businesses.length-1); createBusinessExitPickup(getServerData().businesses.length-1); createBusinessEntranceBlip(getServerData().businesses.length-1); - createBusinessExitBlip(getServerData().businesses.length-1); + createBusinessExitBlip(getServerData().businesses.length-1); + + saveBusinessToDatabase(getServerData().businesses.length-1); messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]created business [#0099FF]${tempBusinessData.name}`); } @@ -121,12 +123,12 @@ function createBusinessLocationCommand(command, params, client) { if(!areParamsEmpty(params)) { businessId = getBusinessFromParams(params); - } + } if(!getBusinessData(businessId)) { messagePlayerError("Business not found!"); return false; - } + } let tempBusinessLocationData = createBusinessLocation(locationType, businessId); getServerData().businesses[businessId].push(tempBusinessLocationData); @@ -152,7 +154,7 @@ function createBusiness(name, entrancePosition, exitPosition, entrancePickupMode tempBusinessData.exitPickupModel = exitPickupModel; tempBusinessData.exitBlipModel = exitBlipModel; tempBusinessData.exitInterior = exitInteriorId; - tempBusinessData.exitDimension = exitVirtualWorld; + tempBusinessData.exitDimension = exitVirtualWorld; return tempBusinessData; } @@ -169,7 +171,7 @@ function deleteBusinessCommand(command, params, client) { if(!getBusinessData(businessId)) { messagePlayerError("Business not found!"); return false; - } + } messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]deleted business [#0099FF]${getBusinessData(businessId).name}`); deleteBusiness(businessId, getPlayerData(client).accountData.databaseId); @@ -193,7 +195,7 @@ function setBusinessNameCommand(command, params, client) { if(!getBusinessData(businessId)) { messagePlayerError("Business not found!"); return false; - } + } let oldBusinessName = getBusinessData(businessId).name; getBusinessData(businessId).name = newBusinessName; @@ -251,7 +253,7 @@ function setBusinessJobCommand(command, params, client) { if(!areParamsEmpty(params)) { businessId = getBusinessFromParams(params); } - + let closestJobLocation = getClosestJobLocation(getVehiclePosition(vehicle)); let jobId = closestJobLocation.job; @@ -281,7 +283,7 @@ function setBusinessPublicCommand(command, params, client) { if(!areParamsEmpty(params)) { businessId = getBusinessFromParams(params); - } + } if(!getBusinessData(businessId)) { messagePlayerError("Business not found!"); @@ -301,11 +303,11 @@ function lockBusinessCommand(command, params, client) { if(!areParamsEmpty(params)) { businessId = getBusinessFromParams(params); } - + if(!getBusinessData(businessId)) { messagePlayerError("Business not found!"); return false; - } + } getBusinessData(businessId).locked = !getBusinessData(businessId).locked; getBusinessData(businessId).entrancePickup.setData("ag.label.locked", getBusinessData(businessId).locked, true); @@ -363,8 +365,8 @@ function getBusinessInfoCommand(command, params, client) { case AG_BIZOWNER_PUBLIC: ownerName = "Public"; - break; - } + break; + } messagePlayerInfo(client, `[#0099FF][Business Info] [#FFFFFF]Name: [#AAAAAA]${getBusinessData(businessId).name}, [#FFFFFF]Owner: [#AAAAAA]${ownerName} (${getBusinessOwnerTypeText(getBusinessData(businessId).ownerType)}), [#FFFFFF]Locked: [#AAAAAA]${getYesNoFromBool(intToBool(getBusinessData(businessId).locked))}, [#FFFFFF]ID: [#AAAAAA]${businessId}/${getBusinessData(businessId).databaseId}`); } @@ -403,6 +405,55 @@ function setBusinessPickupCommand(command, params, client) { // --------------------------------------------------------------------------- +function setBusinessInteriorTypeCommand(command, params, client) { + let splitParams = params.split(" "); + let typeParam = splitParams[0] || "business"; + let businessId = getBusinessFromParams(splitParams[1]) || (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client)); + + if(!getBusinessData(businessId)) { + messagePlayerError(client, "Business not found!"); + return false; + } + + if(isNaN(typeParam)) { + if(toLowerCase(typeParam) == "none") { + getBusinessData(businessId).exitPosition = toVector3(0.0, 0.0, 0.0); + getBusinessData(businessId).exitInterior = 0; + getBusinessData(businessId).hasInterior = false; + messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]remove business [#0099FF]${getBusinessData(businessId).name} [#FFFFFF]interior`); + return false; + } + + if(isNull(getGameConfig().interiorTemplates[getServerGame()][typeParam])) { + messagePlayerError(client, "Invalid interior type! Use an interior type name or an existing business database ID"); + messagePlayerInfo(client, `Interior Types: [#AAAAAA]${Object.keys(getGameConfig().interiorTemplates[getServerGame()]).join(", ")}`) + return false; + } + + messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]set business [#0099FF]${getBusinessData(businessId).name} [#FFFFFF]interior type to [#AAAAAA]${toLowerCase(typeParam)}`); + getBusinessData(businessId).exitPosition = getGameConfig().interiorTemplates[getServerGame()][typeParam].exitPosition; + getBusinessData(businessId).exitInterior = getGameConfig().interiorTemplates[getServerGame()][typeParam].exitInterior; + getBusinessData(businessId).exitDimension = getBusinessData(businessId).databaseId+getGlobalConfig().businessDimensionStart; + getBusinessData(businessId).hasInterior = true; + } else { + if(!getBusinessData(businessId)) { + messagePlayerError(client, "Business ID not found!"); + return false; + } + getBusinessData(businessId).exitPosition = getBusinessData(businessId).exitPosition; + getBusinessData(businessId).exitInterior = getBusinessData(businessId).exitInterior; + getBusinessData(businessId).exitDimension = getBusinessData(businessId).databaseId+getGlobalConfig().businessDimensionStart; + getBusinessData(businessId).hasInterior = true; + } + + deleteBusinessEntrancePickup(businessId); + deleteBusinessExitPickup(businessId); + createBusinessEntrancePickup(businessId); + createBusinessExitPickup(businessId); +} + +// --------------------------------------------------------------------------- + function setBusinessBlipCommand(command, params, client) { let splitParams = params.split(" "); @@ -453,7 +504,7 @@ function withdrawFromBusinessCommand(command, params, client) { } let tempBusinessData = getServerData().businesses.filter(b => b.databaseId == businessId)[0]; - + if(getServerData().businesses[businessId].till < amount) { messagePlayerError(client, `Business '${tempBusinessData.name}' doesn't have that much money! Use /bizbalance.`); return false; @@ -481,8 +532,8 @@ function depositIntoBusinessCommand(command, params, client) { if(!getBusinessData(businessId)) { messagePlayerError(client, "Business not found!"); return false; - } - + } + if(getPlayerCurrentSubAccount(client).cash < amount) { messagePlayerError(client, `You don't have that much money! You only have $${getPlayerCurrentSubAccount(client).cash}`); return false; @@ -506,7 +557,7 @@ function viewBusinessTillAmountCommand(command, params, client) { if(!getBusinessData(businessId)) { messagePlayerError(client, "Business not found!"); return false; - } + } messagePlayerSuccess(client, `Business '${getServerData().businesses[businessId].name}' till has $'${getServerData().businesses[businessId].till}'!`); } @@ -523,12 +574,12 @@ function moveBusinessEntranceCommand(command, params, client) { if(!getBusinessData(businessId)) { messagePlayerError(client, "Business not found!"); return false; - } - + } + getBusinessData(businessId).entrancePosition = getPlayerPosition(client); getBusinessData(businessId).entranceDimension = getPlayerVirtualWorld(client); getBusinessData(businessId).entranceInterior = getPlayerInterior(client); - + deleteBusinessEntranceBlip(businessId); deleteBusinessEntrancePickup(businessId); @@ -551,14 +602,14 @@ function moveBusinessExitCommand(command, params, client) { messagePlayerError(client, "Business not found!"); return false; } - + getBusinessData(businessId).exitPosition = getPlayerPosition(client); getBusinessData(businessId).exitDimension = getPlayerVirtualWorld(client); getBusinessData(businessId).exitInterior = getPlayerInterior(client); - + deleteBusinessExitBlip(businessId); deleteBusinessExitPickup(businessId); - + createBusinessExitBlip(businessId); createBusinessExitPickup(businessId); @@ -625,11 +676,11 @@ function saveBusinessToDatabase(businessId) { if(dbConnection) { let safeBusinessName = escapeDatabaseString(dbConnection, tempBusinessData.name); if(tempBusinessData.databaseId == 0) { - let dbQueryString = `INSERT INTO biz_main (biz_server, biz_name, biz_owner_type, biz_owner_id, biz_locked, biz_entrance_fee, biz_till, biz_entrance_pos_x, biz_entrance_pos_y, biz_entrance_pos_z, biz_entrance_rot_z, biz_entrance_int, biz_entrance_vw, biz_exit_pos_x, biz_exit_pos_y, biz_exit_pos_z, biz_exit_rot_z, biz_exit_int, biz_exit_vw) VALUES (${getServerId()}, '${safeBusinessName}', ${tempBusinessData.ownerType}, ${tempBusinessData.ownerId}, ${boolToInt(tempBusinessData.locked)}, ${tempBusinessData.entranceFee}, ${tempBusinessData.till}, ${tempBusinessData.entrancePosition.x}, ${tempBusinessData.entrancePosition.y}, ${tempBusinessData.entrancePosition.z}, ${tempBusinessData.entranceRotation}, ${tempBusinessData.entranceInterior}, ${tempBusinessData.entranceDimension}, ${tempBusinessData.exitPosition.x}, ${tempBusinessData.exitPosition.y}, ${tempBusinessData.exitPosition.z}, ${tempBusinessData.exitRotation}, ${tempBusinessData.exitInterior}, ${tempBusinessData.exitDimension})`; + let dbQueryString = `INSERT INTO biz_main (biz_server, biz_name, biz_owner_type, biz_owner_id, biz_locked, biz_entrance_fee, biz_till, biz_entrance_pos_x, biz_entrance_pos_y, biz_entrance_pos_z, biz_entrance_rot_z, biz_entrance_int, biz_entrance_vw, biz_exit_pos_x, biz_exit_pos_y, biz_exit_pos_z, biz_exit_rot_z, biz_exit_int, biz_exit_vw) VALUES (${getServerId()}, '${safeBusinessName}', ${tempBusinessData.ownerType}, ${tempBusinessData.ownerId}, ${boolToInt(tempBusinessData.locked)}, ${tempBusinessData.entranceFee}, ${tempBusinessData.till}, ${tempBusinessData.entrancePosition.x}, ${tempBusinessData.entrancePosition.y}, ${tempBusinessData.entrancePosition.z}, ${tempBusinessData.entranceRotation}, ${tempBusinessData.entranceInterior}, ${tempBusinessData.entranceDimension}, ${tempBusinessData.exitPosition.x}, ${tempBusinessData.exitPosition.y}, ${tempBusinessData.exitPosition.z}, ${tempBusinessData.exitRotation}, ${tempBusinessData.exitInterior}, ${tempBusinessData.databaseId+getGlobalConfig().businessDimensionStart}, ${boolToInt(tempBusinessData.hasInterior)})`; queryDatabase(dbConnection, dbQueryString); getServerData().businesses[businessId].databaseId = getDatabaseInsertId(dbConnection); } else { - let dbQueryString = `UPDATE biz_main SET biz_name='${safeBusinessName}', biz_owner_type=${tempBusinessData.ownerType}, biz_owner_id=${tempBusinessData.ownerId}, biz_locked=${boolToInt(tempBusinessData.locked)}, biz_entrance_fee=${tempBusinessData.entranceFee}, biz_till=${tempBusinessData.till}, biz_entrance_pos_x=${tempBusinessData.entrancePosition.x}, biz_entrance_pos_y=${tempBusinessData.entrancePosition.y}, biz_entrance_pos_z=${tempBusinessData.entrancePosition.z}, biz_entrance_rot_z=${tempBusinessData.entranceRotation}, biz_entrance_int=${tempBusinessData.entranceInterior}, biz_entrance_vw=${tempBusinessData.entranceDimension}, biz_exit_pos_x=${tempBusinessData.exitPosition.x}, biz_exit_pos_y=${tempBusinessData.exitPosition.y}, biz_exit_pos_z=${tempBusinessData.exitPosition.z}, biz_exit_rot_z=${tempBusinessData.exitRotation}, biz_exit_int=${tempBusinessData.exitInterior}, biz_exit_vw=${tempBusinessData.exitDimension} WHERE biz_id=${tempBusinessData.databaseId}`; + let dbQueryString = `UPDATE biz_main SET biz_name='${safeBusinessName}', biz_owner_type=${tempBusinessData.ownerType}, biz_owner_id=${tempBusinessData.ownerId}, biz_locked=${boolToInt(tempBusinessData.locked)}, biz_entrance_fee=${tempBusinessData.entranceFee}, biz_till=${tempBusinessData.till}, biz_entrance_pos_x=${tempBusinessData.entrancePosition.x}, biz_entrance_pos_y=${tempBusinessData.entrancePosition.y}, biz_entrance_pos_z=${tempBusinessData.entrancePosition.z}, biz_entrance_rot_z=${tempBusinessData.entranceRotation}, biz_entrance_int=${tempBusinessData.entranceInterior}, biz_entrance_vw=${tempBusinessData.entranceDimension}, biz_exit_pos_x=${tempBusinessData.exitPosition.x}, biz_exit_pos_y=${tempBusinessData.exitPosition.y}, biz_exit_pos_z=${tempBusinessData.exitPosition.z}, biz_exit_rot_z=${tempBusinessData.exitRotation}, biz_exit_int=${tempBusinessData.exitInterior}, biz_exit_vw=${tempBusinessData.exitDimension}, biz_has_interior=${boolToInt(tempBusinessData.hasInterior)} WHERE biz_id=${tempBusinessData.databaseId}`; queryDatabase(dbConnection, dbQueryString); } disconnectFromDatabase(dbConnection); @@ -637,7 +688,7 @@ function saveBusinessToDatabase(businessId) { } console.log(`[Asshat.Business]: Saved business '${tempBusinessData.name}' to database!`); - return false; + return false; } // --------------------------------------------------------------------------- @@ -720,7 +771,7 @@ function createBusinessExitPickup(businessId) { getBusinessData(businessId).exitPickup.dimension = getBusinessData(businessId).exitDimension; //getBusinessData(businessId).exitPickup.interior = getBusinessData(businessId).exitInterior; getBusinessData(businessId).exitPickup.setData("ag.owner.type", AG_PICKUP_BUSINESS_EXIT, false); - getBusinessData(businessId).exitPickup.setData("ag.owner.id", businessId, false); + getBusinessData(businessId).exitPickup.setData("ag.owner.id", businessId, false); getBusinessData(businessId).exitPickup.setData("ag.label.type", AG_LABEL_EXIT, true); addToWorld(getBusinessData(businessId).exitPickup); } @@ -756,7 +807,7 @@ function deleteBusiness(businessId, deletedBy = 0) { let dbConnection = connectToDatabase(); let dbQuery = null; - + if(dbConnection) { dbQuery = queryDatabase(dbConnection, `DELETE FROM biz_main WHERE biz_id = ${tempBusinessData.databaseId}`); if(dbQuery) { @@ -769,7 +820,7 @@ function deleteBusiness(businessId, deletedBy = 0) { deleteBusinessExitPickup(businessId); deleteBusinessEntranceBlip(businessId); - deleteBusinessExitBlip(businessId); + deleteBusinessExitBlip(businessId); removePlayersFromBusiness(businessId); @@ -821,12 +872,12 @@ function getBusinessOwnerTypeText(ownerType) { return "job"; case AG_BIZOWNER_PLAYER: - return "player"; + return "player"; case AG_BIZOWNER_NONE: case AG_BIZOWNER_PUBLIC: - return "not owned"; - + return "not owned"; + default: return "unknown"; } @@ -849,34 +900,9 @@ function doesBusinessHaveInterior(businessId) { // --------------------------------------------------------------------------- -function sendAllBusinessLabelsToPlayer(client) { - let tempBusinessLabels = []; - let totalBusinesses = getServerData().businesses.length; - let businessesPerNetworkEvent = 100; - let totalNetworkEvents = Math.ceil(totalBusinesses/businessesPerNetworkEvent); - for(let i = 0 ; i < totalNetworkEvents ; i++) { - for(let j = 0 ; j < businessesPerNetworkEvent ; j++) { - let tempBusinessId = (i*businessesPerNetworkEvent)+j; - if(typeof getServerData().businesses[tempBusinessId] != "undefined") { - let tempBusinessLabels = []; - tempBusinessLabels.push([tempBusinessId, getServerData().businesses[tempBusinessId].entrancePosition, getGameConfig().propertyLabelHeight[getServerGame()], getServerData().businesses[tempBusinessId].description, getServerData().businesses[tempBusinessId].locked, false]); - } - } - triggerNetworkEvent("ag.bizlabel.all", client, tempBusinessLabels); - tempBusinessLabels = []; - } -} - -// --------------------------------------------------------------------------- - -function sendBusinessLabelToPlayers(businessId) { - triggerNetworkEvent("ag.bizlabel.add", null, businessId, getServerData().businesses[businessId].entrancePosition, getGameConfig().propertyLabelHeight[getServerGame()], getServerData().businesses[businessId].name, getServerData().businesses[businessId].locked, false); -} - -// --------------------------------------------------------------------------- - function deleteBusinessEntrancePickup(businessId) { - if(getBusinessData(businessId).entrancePickup) { + if(getBusinessData(businessId).entrancePickup != null) { + removeFromWorld(getBusinessData(businessId).entrancePickup); destroyElement(getBusinessData(businessId).entrancePickup); getBusinessData(businessId).entrancePickup = false; } @@ -885,16 +911,18 @@ function deleteBusinessEntrancePickup(businessId) { // --------------------------------------------------------------------------- function deleteBusinessExitPickup(businessId) { - if(getBusinessData(businessId).exitPickup) { + if(getBusinessData(businessId).exitPickup != null) { + removeFromWorld(getBusinessData(businessId).exitPickup); destroyElement(getBusinessData(businessId).exitPickup); getBusinessData(businessId).exitPickup = false; - } + } } // --------------------------------------------------------------------------- function deleteBusinessEntranceBlip(businessId) { - if(getBusinessData(businessId).entranceBlip) { + if(getBusinessData(businessId).entranceBlip != null) { + removeFromWorld(getBusinessData(businessId).entranceBlip); destroyElement(getBusinessData(businessId).entranceBlip); getBusinessData(businessId).entranceBlip = false; } @@ -903,10 +931,11 @@ function deleteBusinessEntranceBlip(businessId) { // --------------------------------------------------------------------------- function deleteBusinessExitBlip(businessId) { - if(getBusinessData(businessId).exitBlip) { + if(getBusinessData(businessId).exitBlip != null) { + removeFromWorld(getBusinessData(businessId).exitBlip); destroyElement(getBusinessData(businessId).exitBlip); getBusinessData(businessId).exitBlip = false; - } + } } // --------------------------------------------------------------------------- @@ -925,17 +954,13 @@ function reloadAllBusinessesCommand(command, params, client) { deleteBusinessExitPickup(i); deleteBusinessEntrancePickup(i); } - + //forceAllPlayersToStopWorking(); getServerData().businesses = null; getServerData().businesses = loadBusinessesFromDatabase(); createAllBusinessPickups(); createAllBusinessBlips(); - for(let i in clients) { - sendAllBusinessLabelsToPlayer(clients[i]); - } - messageAdminAction(`All businesses have been reloaded by an admin!`); } diff --git a/scripts/server/chat.js b/scripts/server/chat.js index 3d732696..788dd6ea 100644 --- a/scripts/server/chat.js +++ b/scripts/server/chat.js @@ -68,7 +68,7 @@ function whisperCommand(command, params, client) { if(areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; - } + } whisperToNearbyPlayers(client, params); return true; @@ -76,7 +76,7 @@ function whisperCommand(command, params, client) { // --------------------------------------------------------------------------- -function adminChatCommand(command, params, client) { +function adminChatCommand(command, params, client) { if(areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; @@ -87,7 +87,7 @@ function adminChatCommand(command, params, client) { // --------------------------------------------------------------------------- -function clanChatCommand(command, params, client) { +function clanChatCommand(command, params, client) { if(areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; @@ -115,7 +115,7 @@ function whisperToNearbyPlayers(client, messageText) { //if(clients[i] != client) { messagePlayerWhisper(getClientFromPlayerElement(clients[i]), client, messageText); //} - } + } } // --------------------------------------------------------------------------- diff --git a/scripts/server/clan.js b/scripts/server/clan.js index 5f18455a..efba3f3e 100644 --- a/scripts/server/clan.js +++ b/scripts/server/clan.js @@ -23,7 +23,7 @@ function loadClansFromDatabase() { let tempClans = []; let dbConnection = connectToDatabase(); let dbAssoc; - + if(dbConnection) { let dbQuery = queryDatabase(dbConnection, `SELECT * FROM clan_main WHERE clan_deleted = 0 AND clan_server = ${getServerId()}`); if(dbQuery) { @@ -88,7 +88,7 @@ function setClanOwnerCommand(command, params, client) { if(!doesClientHaveClanPermission(client, getClanFlagValue("owner"))) { messagePlayerError(client, "You must be the clan owner to use this command!"); return false; - } + } if(areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); @@ -102,7 +102,7 @@ function setClanTagCommand(command, params, client) { if(!doesClientHaveClanPermission(client, getClanFlagValue("clanTag"))) { messagePlayerError(client, "You can not change the clan tag!"); return false; - } + } if(areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); @@ -116,7 +116,7 @@ function setClanNameCommand(command, params, client) { if(!doesClientHaveClanPermission(client, getClanFlagValue("clanName"))) { messagePlayerError(client, "You can not change the clan name!"); return false; - } + } if(areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); @@ -130,7 +130,7 @@ function setClanMemberTagCommand(command, params, client) { if(!doesClientHaveClanPermission(client, getClanFlagValue("memberTag"))) { messagePlayerError(client, "You can not change a clan member's tag!"); return false; - } + } if(areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); @@ -144,7 +144,7 @@ function setClanRankTagCommand(command, params, client) { if(!doesClientHaveClanPermission(client, getClanFlagValue("rankTag"))) { messagePlayerError(client, "You can not change a clan ranks's tag!"); return false; - } + } if(areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); @@ -174,7 +174,7 @@ function addClanMemberFlagCommand(command, params, client) { if(!doesClientHaveClanPermission(client, getClanFlagValue("memberFlags"))) { messagePlayerError(client, "You can not change a clan member's permissions!"); return false; - } + } if(areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); @@ -200,9 +200,9 @@ function addClanMemberFlagCommand(command, params, client) { return false; } - let flagValue = getClanFlagValue(splitParams[1]); + let flagValue = getClanFlagValue(splitParams[1]); getPlayerCurrentSubAccount(client).clanFlags = getPlayerCurrentSubAccount(client).clanFlags | flagValue; - messagePlayerSuccess(client, `You added the [#AAAAAA]${splitParams[1]} [#FFFFFF]clan flag to [#AAAAAA]${getCharacterFullName(client)}`); + messagePlayerSuccess(client, `You added the [#AAAAAA]${splitParams[1]} [#FFFFFF]clan flag to [#AAAAAA]${getCharacterFullName(client)}`); } // ---------------------------------------------------------------------------- @@ -211,7 +211,7 @@ function removeClanMemberFlagCommand(command, params, client) { if(!doesClientHaveClanPermission(client, getClanFlagValue("memberFlags"))) { messagePlayerError(client, "You can not change a clan member's permissions!"); return false; - } + } if(areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); @@ -237,9 +237,9 @@ function removeClanMemberFlagCommand(command, params, client) { return false; } - let flagValue = getClanFlagValue(splitParams[1]); + let flagValue = getClanFlagValue(splitParams[1]); getPlayerCurrentSubAccount(client).clanFlags = getPlayerCurrentSubAccount(client).clanFlags & ~flagValue; - messagePlayerSuccess(client, `You removed the [#AAAAAA]${splitParams[1]} [#FFFFFF]clan flag from [#AAAAAA]${getCharacterFullName(client)}`); + messagePlayerSuccess(client, `You removed the [#AAAAAA]${splitParams[1]} [#FFFFFF]clan flag from [#AAAAAA]${getCharacterFullName(client)}`); } // ---------------------------------------------------------------------------- @@ -248,7 +248,7 @@ function addClanRankFlagCommand(command, params, client) { if(!doesClientHaveClanPermission(client, getClanFlagValue("rankFlags"))) { messagePlayerError(client, "You can not change a clan rank's permissions!"); return false; - } + } if(areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); @@ -272,12 +272,12 @@ function addClanRankFlagCommand(command, params, client) { if(!getClanFlagValue(splitParams[1])) { messagePlayerError(client, "Clan flag not found!"); return false; - } + } let flagValue = getClanFlagValue(splitParams[1]); getClanRankData(clanId, rankId).flags = getClanRankData(clanId, rankId).flags | flagValue; - messagePlayerSuccess(client, `You added the [#AAAAAA]${splitParams[1]} [#FFFFFF]clan flag to rank [#AAAAAA]${getClanRankData(clanId, rankId).name}`); + messagePlayerSuccess(client, `You added the [#AAAAAA]${splitParams[1]} [#FFFFFF]clan flag to rank [#AAAAAA]${getClanRankData(clanId, rankId).name}`); } // ---------------------------------------------------------------------------- @@ -286,7 +286,7 @@ function removeClanRankFlagCommand(command, params, client) { if(!doesClientHaveClanPermission(client, getClanFlagValue("rankFlags"))) { messagePlayerError(client, "You can not change a clan rank's permissions!"); return false; - } + } if(areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); @@ -315,7 +315,7 @@ function removeClanRankFlagCommand(command, params, client) { let flagValue = getClanFlagValue(splitParams[1]); getClanRankData(clanId, rankId).flags = getClanRankData(clanId, rankId).flags & ~flagValue; - messagePlayerSuccess(client, `You removed the [#AAAAAA]${splitParams[1]} [#FFFFFF]clan flag from rank [#AAAAAA]${getClanRankData(clanId, rankId).name}`); + messagePlayerSuccess(client, `You removed the [#AAAAAA]${splitParams[1]} [#FFFFFF]clan flag from rank [#AAAAAA]${getClanRankData(clanId, rankId).name}`); } // ---------------------------------------------------------------------------- @@ -324,7 +324,7 @@ function setClanMemberTitleCommand(command, params, client) { if(!doesClientHaveClanPermission(client, getClanFlagValue("memberTitle"))) { messagePlayerError(client, "You can not change a clan member's title!"); return false; - } + } if(areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); @@ -347,7 +347,7 @@ function setClanMemberTitleCommand(command, params, client) { let oldMemberTitle = getPlayerCurrentSubAccount(client).clanTitle; getPlayerCurrentSubAccount(client).clanTitle = params; - messagePlayerSuccess(client, `You changed the name of [#AAAAAA]${getCharacterFullName(client)} [#FFFFFF]from [#AAAAAA]${oldMemberTitle} [#FFFFFF]to [#AAAAAA]${params}`); + messagePlayerSuccess(client, `You changed the name of [#AAAAAA]${getCharacterFullName(client)} [#FFFFFF]from [#AAAAAA]${oldMemberTitle} [#FFFFFF]to [#AAAAAA]${params}`); } // ---------------------------------------------------------------------------- @@ -356,7 +356,7 @@ function setClanRankTitleCommand(command, params, client) { if(!doesClientHaveClanPermission(client, getClanFlagValue("rankTitle"))) { messagePlayerError(client, "You can not change your clan's rank titles!"); return false; - } + } if(areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); @@ -387,7 +387,7 @@ function setClanRankTitleCommand(command, params, client) { function createClan(name) { let dbConnection = connectToDatabase(); let escapedName = name; - + if(dbConnection) { escapedName = escapeDatabaseString(dbConnection, escapedName) let dbQuery = queryDatabase(dbConnection, `INSERT INTO clan_main (clan_server, clan_name) VALUES (${getServerId()}, '${escapedName}')`); diff --git a/scripts/server/class.js b/scripts/server/class.js index 2ca2342c..2d3d7cd1 100644 --- a/scripts/server/class.js +++ b/scripts/server/class.js @@ -65,7 +65,7 @@ function initClassTable() { bank: dbAssoc["svr_newchar_bank"], skin: dbAssoc["svr_newchar_skin"], }, - + this.connectCameraPosition = toVector3(dbAssoc["svr_connectcam_pos_x"], dbAssoc["svr_connectcam_pos_y"], dbAssoc["svr_connectcam_pos_z"]); this.connectCameraLookAt = toVector3(dbAssoc["svr_connectcam_lookat_x"], dbAssoc["svr_connectcam_lookat_y"], dbAssoc["svr_connectcam_lookat_z"]); this.hour = toInteger(dbAssoc["svr_start_time_hour"]); @@ -76,7 +76,7 @@ function initClassTable() { this.useGUI = intToBool(dbAssoc["svr_gui"]); this.guiColour = [toInteger(dbAssoc["svr_gui_col1_r"]), toInteger(dbAssoc["svr_gui_col1_g"]), toInteger(dbAssoc["svr_gui_col1_b"])]; this.showLogo = intToBool(dbAssoc["svr_logo"]); - + this.antiCheat = { enabled: intToBool(dbAssoc["svr_ac_enabled"]), checkGameScripts: intToBool(dbAssoc["svr_ac_check_scripts"]), @@ -104,7 +104,7 @@ function initClassTable() { this.garbageRoute = null; this.garbageRouteStop = null; this.garbageRouteIsland = null; - + this.spawned = false; this.rentingVehicle = false; @@ -114,38 +114,59 @@ function initClassTable() { this.returnToJobVehicleTick = 0; this.returnToJobVehicleTimer = null; - + this.switchingCharacter = false; } }, accountData: class { constructor(accountAssoc) { - if(!accountAssoc) { - return; - } - - this.databaseId = accountAssoc["acct_id"]; - this.name = accountAssoc["acct_name"]; - this.password = accountAssoc["acct_pass"]; - this.registerDate = accountAssoc["acct_when_made"]; + this.databaseId = 0; + this.name = ""; + this.password = ""; + this.registerDate = 0; this.flags = { - moderation: accountAssoc["acct_mod_flags"], - settings: accountAssoc["acct_settings"], - admin: accountAssoc["acct_staff_flags"], + moderation: 0, + settings: 0, + admin: 0, }; - this.staffTitle = accountAssoc["acct_staff_title"]; - this.ircAccount = accountAssoc["acct_irc"] || "None"; - this.discordAccount = accountAssoc["acct_discord"]; - this.settings = accountAssoc["acct_settings"]; - this.emailAddress = accountAssoc["acct_email"]; - this.ipAddress = accountAssoc["ip"]; - + this.staffTitle = ""; + this.ircAccount = ""; + this.discordAccount = 0, + this.settings = 0, + this.emailAddress = ""; + this.ipAddress = 0, + this.notes = []; this.messages = []; this.keyBinds = []; this.contacts = []; this.subAccounts = []; - this.loggedIn = false; + this.loggedIn = false; + + if(accountAssoc) { + this.databaseId = accountAssoc["acct_id"]; + this.name = accountAssoc["acct_name"]; + this.password = accountAssoc["acct_pass"]; + this.registerDate = accountAssoc["acct_when_made"]; + this.flags = { + moderation: accountAssoc["acct_mod_flags"], + settings: accountAssoc["acct_settings"], + admin: accountAssoc["acct_staff_flags"], + }; + this.staffTitle = accountAssoc["acct_staff_title"]; + this.ircAccount = accountAssoc["acct_irc"] || "None"; + this.discordAccount = accountAssoc["acct_discord"]; + this.settings = accountAssoc["acct_settings"]; + this.emailAddress = accountAssoc["acct_email"]; + this.ipAddress = accountAssoc["ipstring"]; + + this.notes = []; + this.messages = []; + this.keyBinds = []; + this.contacts = []; + this.subAccounts = []; + this.loggedIn = false; + } } }, accountContactData: class { @@ -153,7 +174,7 @@ function initClassTable() { if(!accountContactAssoc) { return; } - + this.databaseId = accountContactAssoc["acct_contact_id"]; this.accountId = accountContactAssoc["acct_contact_acct"]; this.contactAccountId = accountContactAssoc["acct_contact_contact"]; @@ -166,7 +187,7 @@ function initClassTable() { if(!accountMessageAssoc) { return; } - + this.databaseId = accountMessageAssoc["acct_msg_id"]; this.account = accountMessageAssoc["acct_msg_acct"]; this.whoSent = accountMessageAssoc["acct_msg_who_sent"]; @@ -177,13 +198,13 @@ function initClassTable() { this.folder = accountMessageAssoc["acct_msg_folder"]; this.message = accountMessageAssoc["acct_msg_message"]; } - }, + }, accountStaffNoteData: class { constructor(accountStaffNoteAssoc) { if(!accountStaffNoteAssoc) { return; } - + this.databaseId = accountStaffNoteAssoc["acct_note_id"]; this.account = accountStaffNoteAssoc["acct_note_acct"]; this.whoAdded = accountStaffNoteAssoc["acct_note_who_added"]; @@ -193,13 +214,13 @@ function initClassTable() { this.server = accountMessageAssoc["acct_note_server"]; this.note = accountMessageAssoc["acct_note_message"]; } - }, + }, subAccountData: class { constructor(subAccountAssoc) { if(!subAccountAssoc) { return; } - + this.databaseId = subAccountAssoc["sacct_id"]; this.server = subAccountAssoc["sacct_server"]; this.firstName = subAccountAssoc["sacct_name_first"]; @@ -225,11 +246,11 @@ function initClassTable() { this.weapons = []; this.inJail = false; - + this.interior = 0; this.dimension = 0; } - }, + }, businessData: class { constructor(businessAssoc) { this.databaseId = 0; @@ -248,7 +269,7 @@ function initClassTable() { this.entranceBlipModel = -1; this.entrancePickup = null; this.entranceBlip = null; - + this.exitPosition = false; this.exitRotation = 0.0; this.exitInterior = 0; @@ -269,25 +290,21 @@ function initClassTable() { this.buyPrice = toInteger(businessAssoc["biz_buy_price"]); this.locked = intToBool(toInteger(businessAssoc["biz_locked"])); this.hasInterior = intToBool(toInteger(businessAssoc["biz_has_interior"])); - + this.entrancePosition = toVector3(toFloat(businessAssoc["biz_entrance_pos_x"]), toFloat(businessAssoc["biz_entrance_pos_y"]), toFloat(businessAssoc["biz_entrance_pos_z"])); this.entranceRotation = toInteger(businessAssoc["biz_entrance_rot_z"]); this.entranceInterior = toInteger(businessAssoc["biz_entrance_int"]); this.entranceDimension = toInteger(businessAssoc["biz_entrance_vw"]); this.entrancePickupModel = toInteger(businessAssoc["biz_entrance_pickup"]); - this.entranceBlipModel = toInteger(businessAssoc["biz_entrance_blip"]); - this.entrancePickup = null; - this.entrancePickup = null; - + this.entranceBlipModel = toInteger(businessAssoc["biz_entrance_blip"]); + this.exitPosition = toVector3(businessAssoc["biz_exit_pos_x"], businessAssoc["biz_exit_pos_y"], businessAssoc["biz_exit_pos_z"]); this.exitRotation = toInteger(businessAssoc["biz_exit_rot_z"]); this.exitInterior = toInteger(businessAssoc["biz_exit_int"]); this.exitDimension = toInteger(businessAssoc["biz_exit_vw"]); this.exitPickupModel = toInteger(businessAssoc["biz_exit_pickup"]); this.exitBlipModel = toInteger(businessAssoc["biz_exit_blip"]); - this.exitPickup = null; - this.exitBlip = null; - + this.entranceFee = toInteger(businessAssoc["biz_entrance_fee"]); this.till = toInteger(businessAssoc["biz_till"]); } @@ -319,7 +336,7 @@ function initClassTable() { this.buyPrice = 0; this.locked = false; this.hasInterior = false; - + this.entrancePosition = false; this.entranceRotation = 0.0; this.entranceInterior = 0; @@ -328,7 +345,7 @@ function initClassTable() { this.entranceBlipModel = -1; this.entrancePickup = null; this.entranceBlip = null; - + this.exitPosition = false; this.exitRotation = 0.0; this.exitInterior = 0; @@ -346,24 +363,20 @@ function initClassTable() { this.buyPrice = toInteger(houseAssoc["house_buy_price"]); this.locked = intToBool(toInteger(houseAssoc["house_locked"])); this.hasInterior = intToBool(toInteger(houseAssoc["house_has_interior"])); - + this.entrancePosition = toVector3(toFloat(houseAssoc["house_entrance_pos_x"]), toFloat(houseAssoc["house_entrance_pos_y"]), toFloat(houseAssoc["house_entrance_pos_z"])); this.entranceRotation = toFloat(houseAssoc["house_entrance_rot_z"]); this.entranceInterior = toInteger(houseAssoc["house_entrance_int"]); this.entranceDimension = toInteger(houseAssoc["house_entrance_vw"]); this.entrancePickupModel = toInteger(houseAssoc["house_entrance_pickup"]); - this.entranceBlipModel = toInteger(houseAssoc["house_entrance_blip"]); - this.entrancePickup = null; - this.entranceBlip = null; - + this.entranceBlipModel = toInteger(houseAssoc["house_entrance_blip"]); + this.exitPosition = toVector3(toFloat(houseAssoc["house_exit_pos_x"]), toFloat(houseAssoc["house_exit_pos_y"]), toFloat(houseAssoc["house_exit_pos_z"])); this.exitRotation = toFloat(houseAssoc["house_exit_rot_z"]); this.exitInterior = toInteger(houseAssoc["house_exit_int"]); this.exitDimension = toInteger(houseAssoc["house_exit_vw"]); this.exitPickupModel = toInteger(houseAssoc["house_exit_pickup"]); this.exitBlipModel = toInteger(houseAssoc["house_exit_blip"]); - this.exitPickup = null; - this.exitBlip = null; } } }, @@ -380,32 +393,32 @@ function initClassTable() { this.server = getServerId(); this.model = (vehicle != false) ? vehicle.modelIndex : 0; this.vehicle = vehicle; - + // Ownership this.ownerType = AG_VEHOWNER_NONE; this.ownerId = 0; this.buyPrice = 0; this.rentPrice = 0; this.rentedBy = false; - this.rentStart = 0; - + this.rentStart = 0; + // Position and Rotation this.spawnPosition = (vehicle) ? vehicle.position : toVector3(0.0, 0.0, 0.0); this.spawnRotation = (vehicle) ? vehicle.heading : 0.0; this.spawnLocked = false; - + // Colour Info this.colour1IsRGBA = 0; this.colour2IsRGBA = 0; this.colour3IsRGBA = 0; - this.colour4IsRGBA = 0; + this.colour4IsRGBA = 0; this.colour1RGBA = toColour(255, 255, 255, 255); this.colour2RGBA = toColour(255, 255, 255, 255); this.colour3RGBA = toColour(255, 255, 255, 255); - this.colour4RGBA = toColour(255, 255, 255, 255); + this.colour4RGBA = toColour(255, 255, 255, 255); this.colour1 = (vehicle) ? vehicle.colour1 : 1; this.colour2 = (vehicle) ? vehicle.colour2 : 1; - this.colour3 = (vehicle) ? vehicle.colour3 : 1; + this.colour3 = (vehicle) ? vehicle.colour3 : 1; this.colour4 = (vehicle) ? vehicle.colour4 : 1; // Vehicle Attributes @@ -416,37 +429,37 @@ function initClassTable() { this.engineDamage = 0; this.visualDamage = 0; this.dirtLevel = 0; - + if(vehicleAssoc) { // General Info this.databaseId = toInteger(vehicleAssoc["veh_id"]); this.server = toInteger(vehicleAssoc["veh_server"]); this.model = toInteger(vehicleAssoc["veh_model"]); - + // Ownership this.ownerType = toInteger(vehicleAssoc["veh_owner_type"]); this.ownerId = toInteger(vehicleAssoc["veh_owner_id"]); this.buyPrice = toInteger(vehicleAssoc["veh_buy_price"]); this.rentPrice = toInteger(vehicleAssoc["veh_buy_price"]); - + // Position and Rotation this.spawnPosition = toVector3(vehicleAssoc["veh_pos_x"], vehicleAssoc["veh_pos_y"], vehicleAssoc["veh_pos_z"]); this.spawnRotation = toInteger(vehicleAssoc["veh_rot_z"]); this.spawnLocked = intToBool(toInteger(vehicleAssoc["veh_spawn_lock"])); - + // Colour Info this.colour1IsRGBA = intToBool(toInteger(vehicleAssoc["veh_col1_isrgba"])); this.colour2IsRGBA = intToBool(toInteger(vehicleAssoc["veh_col2_isrgba"])); this.colour3IsRGBA = intToBool(toInteger(vehicleAssoc["veh_col3_isrgba"])); - this.colour4IsRGBA = intToBool(toInteger(vehicleAssoc["veh_col4_isrgba"])); + this.colour4IsRGBA = intToBool(toInteger(vehicleAssoc["veh_col4_isrgba"])); this.colour1RGBA = toColour(toInteger(vehicleAssoc["veh_col1_r"]), toInteger(vehicleAssoc["veh_col1_g"]), toInteger(vehicleAssoc["veh_col1_b"]), toInteger(vehicleAssoc["veh_col1_a"])); this.colour2RGBA = toColour(toInteger(vehicleAssoc["veh_col2_r"]), toInteger(vehicleAssoc["veh_col2_g"]), toInteger(vehicleAssoc["veh_col2_b"]), toInteger(vehicleAssoc["veh_col2_a"])); this.colour3RGBA = toColour(toInteger(vehicleAssoc["veh_col3_r"]), toInteger(vehicleAssoc["veh_col3_g"]), toInteger(vehicleAssoc["veh_col3_b"]), toInteger(vehicleAssoc["veh_col3_a"])); - this.colour4RGBA = toColour(toInteger(vehicleAssoc["veh_col4_r"]), toInteger(vehicleAssoc["veh_col4_g"]), toInteger(vehicleAssoc["veh_col4_b"]), toInteger(vehicleAssoc["veh_col4_a"])); + this.colour4RGBA = toColour(toInteger(vehicleAssoc["veh_col4_r"]), toInteger(vehicleAssoc["veh_col4_g"]), toInteger(vehicleAssoc["veh_col4_b"]), toInteger(vehicleAssoc["veh_col4_a"])); this.colour1 = toInteger(vehicleAssoc["veh_col1"]); this.colour2 = toInteger(vehicleAssoc["veh_col2"]); this.colour3 = toInteger(vehicleAssoc["veh_col3"]); - this.colour4 = toInteger(vehicleAssoc["veh_col4"]); + this.colour4 = toInteger(vehicleAssoc["veh_col4"]); // Vehicle Attributes this.locked = intToBool(toInteger(vehicleAssoc["veh_locked"])); @@ -526,7 +539,7 @@ function initClassTable() { this.colour = toColour(jobAssoc["job_colour_r"], jobAssoc["job_colour_g"], jobAssoc["job_colour_b"], 255); this.whiteListEnabled = jobAssoc["job_whitelist"]; this.blackListEnabled = jobAssoc["job_blacklist"]; - + this.equipment = []; this.uniforms = []; this.locations = []; @@ -584,8 +597,8 @@ function initClassTable() { this.name = jobUniformAssoc["job_uniform_name"]; this.requiredRank = jobUniformAssoc["job_uniform_minrank"]; this.skin = jobUniformAssoc["job_uniform_skin"]; - this.enabled = jobUniformAssoc["job_uniform_skin"]; - } + this.enabled = jobUniformAssoc["job_uniform_skin"]; + } } }, jobLocationData: class { @@ -640,7 +653,7 @@ function initClassTable() { this.enabled = jobBlackListAssoc["job_bl_enabled"]; } } - }, + }, keyBindData: class { constructor(keyBindAssoc, key = 0, commandString = "") { this.databaseId = 0; @@ -678,7 +691,7 @@ function initClassTable() { if(!dbAssoc) { return; } - + this.databaseId = dbAssoc["ac_script_wl_id"]; this.enabled = intToBool(dbAssoc["ac_script_wl_enabled"]); this.server = dbAssoc["ac_script_wl_server"]; @@ -692,21 +705,27 @@ function initClassTable() { this.range = range; } }, + interiorTemplateData: class { + constructor(exitPosition, interior) { + this.exitPosition = exitPosition; + this.interior = interior; + } + }, } - + return tempClasses; } // --------------------------------------------------------------------------- function getClasses() { - return serverClasses; + return serverClasses; } // --------------------------------------------------------------------------- function getClass(className) { - return serverClasses[className]; + return serverClasses[className]; } // --------------------------------------------------------------------------- diff --git a/scripts/server/client.js b/scripts/server/client.js index 6fed951a..1f12a7d1 100644 --- a/scripts/server/client.js +++ b/scripts/server/client.js @@ -17,10 +17,10 @@ addNetworkHandler("ag.promptAnswerNo", function(client) { switch(getEntityData(client, "ag.prompt")) { case AG_PROMPT_CREATEFIRSTCHAR: - triggerNetworkEvent("ag.showError", client, "You don't have a character to play. Goodbye!", "No Characters"); + triggerNetworkEvent("ag.showError", client, "You don't have a character to play. Goodbye!", "No Characters"); setTimeout(function() { client.disconnect(); }, 5000); break; - + default: break; } @@ -38,8 +38,8 @@ addNetworkHandler("ag.promptAnswerYes", function(client) { switch(getEntityData(client, "ag.prompt")) { case AG_PROMPT_CREATEFIRSTCHAR: triggerNetworkEvent("ag.showNewCharacter", client); - break; - + break; + default: break; } @@ -79,28 +79,28 @@ addNetworkHandler("ag.afk", function(client, afkState) { // Not implemented yet addNetworkHandler("ag.heldKey", function(client, key) { switch(key) { - case getGlobalConfig().keybinds.actionKey: + case getGlobalConfig().keybinds.actionKey: processHoldActionKey(client); break; - case getGlobalConfig().keybinds.vehicleLightsKey: + case getGlobalConfig().keybinds.vehicleLightsKey: processHoldVehicleLightsKey(client); break; - case getGlobalConfig().keybinds.vehicleLockKey: + case getGlobalConfig().keybinds.vehicleLockKey: processHoldVehicleLockKey(client); break; - case getGlobalConfig().keybinds.vehicleEngineKey: + case getGlobalConfig().keybinds.vehicleEngineKey: processHoldVehicleEngineKey(client); - break; + break; } }); // --------------------------------------------------------------------------- -addNetworkHandler("ag.player.death", function(client, position, heading) { - processPlayerDeath(client); +addNetworkHandler("ag.player.death", function(client, position) { + processPlayerDeath(client, position); }); // --------------------------------------------------------------------------- @@ -143,6 +143,13 @@ addNetworkHandler("ag.clientReady", function(client) { // --------------------------------------------------------------------------- +addNetworkHandler("ag.guiReady", function(client) { + client.setData("ag.guiReady", true, false); + console.log(`${getPlayerDisplayForConsole(client)}'s client GUI is initialized and ready!`); +}); + +// --------------------------------------------------------------------------- + addNetworkHandler("ag.clientStarted", function(client) { client.setData("ag.isStarted", true, false); console.log(`${getPlayerDisplayForConsole(client)}'s client resources are started and running!`); diff --git a/scripts/server/command.js b/scripts/server/command.js index a154cb15..0154e79c 100644 --- a/scripts/server/command.js +++ b/scripts/server/command.js @@ -37,7 +37,7 @@ function loadCommandData() { ban: [ commandData("aban", accountBanCommand, " ", getStaffFlagValue("manageBans"), true, true), commandData("saban", subAccountBanCommand, " ", getStaffFlagValue("manageBans"), true, true), - commandData("ipban", ipBanCommand, " ", getStaffFlagValue("manageBans"), true, true), + commandData("ipban", ipBanCommand, " ", getStaffFlagValue("manageBans"), true, true), ], bitFlag: [], business: [ @@ -59,6 +59,7 @@ function loadCommandData() { commandData("bizinfo", getBusinessInfoCommand, "[id]", getStaffFlagValue("none"), true, true), commandData("bizentrance", moveBusinessEntranceCommand, "", getStaffFlagValue("manageBusinesses"), true, true), commandData("bizexit", moveBusinessExitCommand, "", getStaffFlagValue("manageBusinesses"), true, true), + commandData("bizinttype", setBusinessInteriorTypeCommand, "", getStaffFlagValue("manageBusinesses"), true, true), ], chat: [ commandData("me", meActionCommand, "", getStaffFlagValue("none"), true, false), @@ -69,19 +70,19 @@ function loadCommandData() { commandData("local", talkCommand, "", getStaffFlagValue("none"), true, false), commandData("l", talkCommand, "", getStaffFlagValue("none"), true, false), commandData("w", whisperCommand, "", getStaffFlagValue("none"), true, false), - commandData("whisper", whisperCommand, "", getStaffFlagValue("none"), true, false), - commandData("clanchat", clanChatCommand, "", getStaffFlagValue("none"), true, false), - commandData("clan", clanChatCommand, "", getStaffFlagValue("none"), true, false), - commandData("c", clanChatCommand, "", getStaffFlagValue("none"), true, false), + commandData("whisper", whisperCommand, "", getStaffFlagValue("none"), true, false), + commandData("clanchat", clanChatCommand, "", getStaffFlagValue("none"), true, false), + commandData("clan", clanChatCommand, "", getStaffFlagValue("none"), true, false), + commandData("c", clanChatCommand, "", getStaffFlagValue("none"), true, false), commandData("adminchat", adminChatCommand, "", getStaffFlagValue("basicModeration"), true, true), commandData("a", adminChatCommand, "", getStaffFlagValue("basicModeration"), true, true), commandData("achat", adminChatCommand, "", getStaffFlagValue("basicModeration"), true, true), ], clan: [ - commandData("addclan", createClanCommand, "", getStaffFlagValue("manageClans"), true, true), - commandData("delclan", deleteClanCommand, "", getStaffFlagValue("manageClans"), true, true), + commandData("addclan", createClanCommand, "", getStaffFlagValue("manageClans"), true, true), + commandData("delclan", deleteClanCommand, "", getStaffFlagValue("manageClans"), true, true), - commandData("clanowner", setClanOwnerCommand, " ", getStaffFlagValue("none"), true, true), + commandData("clanowner", setClanOwnerCommand, " ", getStaffFlagValue("none"), true, true), commandData("clantag", setClanTagCommand, "", getStaffFlagValue("none"), true, true), commandData("clanranktag", setClanRankTagCommand, " ", getStaffFlagValue("none"), true, true), commandData("clanmembertag", setClanMemberTagCommand, " ", getStaffFlagValue("none"), true, true), @@ -89,8 +90,8 @@ function loadCommandData() { commandData("clanmembertitle", setClanMemberTitleCommand, " ", getStaffFlagValue("none"), true, true), commandData("addrankflag", addClanRankFlagCommand, "<rank name/id> <flag name>", getStaffFlagValue("none"), true, true), commandData("delrankflag", removeClanRankFlagCommand, "<rank name/id> <flag name>", getStaffFlagValue("none"), true, true), - commandData("addmemberflag", addClanMemberFlagCommand, "<player name/id> <flag name>", getStaffFlagValue("none"), true, true), - commandData("delmemberflag", removeClanMemberFlagCommand, "<player name/id> <flag name>", getStaffFlagValue("none"), true, true), + commandData("addmemberflag", addClanMemberFlagCommand, "<player name/id> <flag name>", getStaffFlagValue("none"), true, true), + commandData("delmemberflag", removeClanMemberFlagCommand, "<player name/id> <flag name>", getStaffFlagValue("none"), true, true), ], class: [], client: [], @@ -105,18 +106,18 @@ function loadCommandData() { commandData("settime", setTimeCommand, "<hour> [minute]", getStaffFlagValue("manageServer"), true, true), commandData("setweather", setWeatherCommand, "<weather id/name>", getStaffFlagValue("manageServer"), true, true), commandData("setsnow", setSnowingCommand, "<falling snow> <ground snow>", getStaffFlagValue("manageServer"), true, true), - commandData("setlogo", toggleServerLogoCommand, "<0/1 state>", getStaffFlagValue("manageServer"), true, true), - commandData("setgui", toggleServerGUICommand, "<0/1 state>", getStaffFlagValue("manageServer"), true, true), + commandData("setlogo", toggleServerLogoCommand, "<0/1 state>", getStaffFlagValue("manageServer"), true, true), + commandData("setgui", toggleServerGUICommand, "<0/1 state>", getStaffFlagValue("manageServer"), true, true), commandData("newcharspawn", setNewCharacterSpawnPositionCommand, "", getStaffFlagValue("manageServer"), true, true), commandData("newcharcash", setNewCharacterMoneyCommand, "<amount>", getStaffFlagValue("manageServer"), true, true), - commandData("newcharskin", setNewCharacterSkinCommand, "[skin id]", getStaffFlagValue("manageServer"), true, true), - commandData("jobinfo", getJobInfoCommand, "", getStaffFlagValue("none"), true, true), - commandData("joblocinfo", getJobLocationInfoCommand, "", getStaffFlagValue("none"), true, true), + commandData("newcharskin", setNewCharacterSkinCommand, "[skin id]", getStaffFlagValue("manageServer"), true, true), + commandData("jobinfo", getJobInfoCommand, "", getStaffFlagValue("none"), true, true), + commandData("joblocinfo", getJobLocationInfoCommand, "", getStaffFlagValue("none"), true, true), ], core: [], database: [], developer: [ - commandData("scode", executeServerCodeCommand, "<code>", getStaffFlagValue("developer"), true, true), + commandData("scode", executeServerCodeCommand, "<code>", getStaffFlagValue("developer"), true, true), commandData("ccode", executeClientCodeCommand, "<code>", getStaffFlagValue("developer"), true, true), commandData("gmx", restartGameModeCommand, "", getStaffFlagValue("developer"), true, true), commandData("saveall", saveAllServerDataCommand, "", getStaffFlagValue("developer"), true, true), @@ -141,7 +142,8 @@ function loadCommandData() { commandData("housepickup", setHousePickupCommand, "<type name/model id>", getStaffFlagValue("manageHouses"), true, true), commandData("houseinfo", getHouseInfoCommand, "[id]", getStaffFlagValue("none"), true, true), commandData("houseentrance", moveHouseEntranceCommand, "", getStaffFlagValue("manageHouses"), true, true), - commandData("houseexit", moveHouseExitCommand, "", getStaffFlagValue("manageHouses"), true, true), + commandData("houseexit", moveHouseExitCommand, "", getStaffFlagValue("manageHouses"), true, true), + commandData("houseinttype", setHouseInteriorTypeCommand, "<interior template name/business id>", getStaffFlagValue("manageHouses"), true, true), ], item: [], job: [ @@ -149,7 +151,7 @@ function loadCommandData() { commandData("startwork", startWorkingCommand, "", getStaffFlagValue("none"), true, false), commandData("stopwork", stopWorkingCommand, "", getStaffFlagValue("none"), true, false), commandData("startjob", startWorkingCommand, "", getStaffFlagValue("none"), true, false), - commandData("stopjob", stopWorkingCommand, "", getStaffFlagValue("none"), true, false), + commandData("stopjob", stopWorkingCommand, "", getStaffFlagValue("none"), true, false), commandData("quitjob", quitJobCommand, "", getStaffFlagValue("none"), true, false), commandData("uniform", jobUniformCommand, "[uniform]", getStaffFlagValue("none"), true, false), commandData("equip", jobEquipmentCommand, "[equipment]", getStaffFlagValue("none"), true, false), @@ -168,7 +170,7 @@ function loadCommandData() { commandData("detain", policeDetainCommand, "", getStaffFlagValue("none"), true, false), commandData("drag", policeDragCommand, "", getStaffFlagValue("none"), true, false), commandData("search", policeSearchCommand, "", getStaffFlagValue("none"), true, false), - + // Bus/Garbage commandData("startroute", jobStartRouteCommand, "", getStaffFlagValue("none"), true, false), commandData("stoproute", jobStopRouteCommand, "", getStaffFlagValue("none"), true, false), @@ -207,24 +209,24 @@ function loadCommandData() { commandData("mute", muteClientCommand, "<player name/id> [reason]", getStaffFlagValue("basicModeration"), true, true), commandData("freeze", freezeClientCommand, "<player name/id> [reason]", getStaffFlagValue("basicModeration"), true, true), commandData("unmute", unMuteClientCommand, "<player name/id> [reason]", getStaffFlagValue("basicModeration"), true, true), - commandData("unfreeze", unFreezeClientCommand, "<player name/id> [reason]", getStaffFlagValue("basicModeration"), true, true), - commandData("goto", gotoPlayerCommand, "<player name/id>", getStaffFlagValue("basicModeration"), true, true), - commandData("gethere", getPlayerCommand, "<player name/id>", getStaffFlagValue("basicModeration"), true, true), - commandData("gotopos", gotoPositionCommand, "<x> <y> <z> [int] [vw]", getStaffFlagValue("basicModeration"), true, true), + commandData("unfreeze", unFreezeClientCommand, "<player name/id> [reason]", getStaffFlagValue("basicModeration"), true, true), + commandData("goto", gotoPlayerCommand, "<player name/id>", getStaffFlagValue("basicModeration"), true, true), + commandData("gethere", getPlayerCommand, "<player name/id>", getStaffFlagValue("basicModeration"), true, true), + commandData("gotopos", gotoPositionCommand, "<x> <y> <z> [int] [vw]", getStaffFlagValue("basicModeration"), true, true), commandData("gotoveh", gotoVehicleCommand, "<vehicle id>", getStaffFlagValue("basicModeration"), true, true), commandData("gotobiz", gotoBusinessCommand, "<business id/name>", getStaffFlagValue("basicModeration"), true, true), commandData("gotohouse", gotoHouseCommand, "<house id/name>", getStaffFlagValue("basicModeration"), true, true), commandData("gotojob", gotoJobLocationCommand, "<job id/name> <location id>", getStaffFlagValue("basicModeration"), true, true), //commandData("gotoloc", gotoLocationCommand, "<location name>", getStaffFlagValue("basicModeration"), true, true), commandData("fr", teleportForwardCommand, "<distance in meters>", getStaffFlagValue("basicModeration"), true, true), - commandData("ba", teleportBackwardCommand, "<distance in meters>", getStaffFlagValue("basicModeration"), true, true), - commandData("lt", teleportLeftCommand, "<distance in meters>", getStaffFlagValue("basicModeration"), true, true), - commandData("rt", teleportRightCommand, "<distance in meters>", getStaffFlagValue("basicModeration"), true, true), - commandData("up", teleportUpCommand, "<distance in meters>", getStaffFlagValue("basicModeration"), true, true), - commandData("dn", teleportDownCommand, "<distance in meters>", getStaffFlagValue("basicModeration"), true, true), + commandData("ba", teleportBackwardCommand, "<distance in meters>", getStaffFlagValue("basicModeration"), true, true), + commandData("lt", teleportLeftCommand, "<distance in meters>", getStaffFlagValue("basicModeration"), true, true), + commandData("rt", teleportRightCommand, "<distance in meters>", getStaffFlagValue("basicModeration"), true, true), + commandData("up", teleportUpCommand, "<distance in meters>", getStaffFlagValue("basicModeration"), true, true), + commandData("dn", teleportDownCommand, "<distance in meters>", getStaffFlagValue("basicModeration"), true, true), commandData("int", playerInteriorCommand, "<interior id>", getStaffFlagValue("basicModeration"), true, true), commandData("vw", playerVirtualWorldCommand, "<virtual world id>", getStaffFlagValue("basicModeration"), true, true), - + commandData("addstaffflag", addStaffFlagCommand, "<player name/id> [flag name]", getStaffFlagValue("manageAdmins"), true, true), commandData("delstaffflag", takeStaffFlagCommand, "<player name/id> [flag name]", getStaffFlagValue("manageAdmins"), true, true), commandData("getstaffflags", getStaffFlagsCommand, "<player name/id>", getStaffFlagValue("manageAdmins"), true, true), @@ -238,20 +240,20 @@ function loadCommandData() { subAccount: [ commandData("switchchar", switchCharacterCommand, "", getStaffFlagValue("none"), true, false), commandData("newchar", newCharacterCommand, "<first name> <last name>", getStaffFlagValue("none"), true, false), - commandData("usechar", useCharacterCommand, "<character id>", getStaffFlagValue("none"), true, false), + commandData("usechar", useCharacterCommand, "<character id>", getStaffFlagValue("none"), true, false), ], translate: [], utilities: [], vehicle: [ - commandData("addveh", createVehicleCommand, "<model id/name>", getStaffFlagValue("manageVehicles"), true, false), + commandData("addveh", createVehicleCommand, "<model id/name>", getStaffFlagValue("manageVehicles"), true, false), commandData("tempveh", createTemporaryVehicleCommand, "<model id/name>", getStaffFlagValue("manageVehicles"), true, false), commandData("delveh", deleteVehicleCommand, "", getStaffFlagValue("manageVehicles"), true, false), - - commandData("lock", vehicleLockCommand, "", getStaffFlagValue("none"), true, false), - commandData("unlock", vehicleLockCommand, "", getStaffFlagValue("none"), true, false), - commandData("engine", vehicleEngineCommand, "", getStaffFlagValue("none"), true, false), - commandData("siren", vehicleSirenCommand, "", getStaffFlagValue("none"), true, false), - commandData("lights", vehicleLightsCommand, "", getStaffFlagValue("none"), true, false), + + commandData("lock", vehicleLockCommand, "", getStaffFlagValue("none"), true, false), + commandData("unlock", vehicleLockCommand, "", getStaffFlagValue("none"), true, false), + commandData("engine", vehicleEngineCommand, "", getStaffFlagValue("none"), true, false), + commandData("siren", vehicleSirenCommand, "", getStaffFlagValue("none"), true, false), + commandData("lights", vehicleLightsCommand, "", getStaffFlagValue("none"), true, false), commandData("vehowner", setVehicleOwnerCommand, "<player id/name>", getStaffFlagValue("manageVehicles"), true, true), commandData("vehclan", setVehicleClanCommand, "<clan id/name>", getStaffFlagValue("manageVehicles"), true, true), @@ -338,13 +340,13 @@ function disableCommand(command, params, client) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - + params = toLowerCase(params); if(!getCommand(params)) { messagePlayerError(client, `The command [#AAAAAA]/${params} [#FFFFFF] does not exist!`); return false; - } + } getCommand(params).enabled = false; messagePlayerSuccess(client, `Command [#AAAAAA]/${params} [#FFFFFF]has been disabled!`); @@ -358,13 +360,13 @@ function enableCommand(command, params, client) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - + params = toLowerCase(params); if(!getCommand(params)) { messagePlayerError(client, `The command [#AAAAAA]/${params} [#FFFFFF] does not exist!`); return false; - } + } getCommand(params).enabled = true; messagePlayerSuccess(client, `Command [#AAAAAA]/${params} [#FFFFFF]has been enabled!`); @@ -380,11 +382,11 @@ function disableAllCommandsByType(command, params, client) { } params = toLowerCase(params); - + if(isNull(getServerData().commands[params])) { messagePlayerError(client, `Command type [#AAAAAA]${params} [#FFFFFF]does not exist!`); return false; - } + } for(let i in getServerData().commands[params]) { getServerData().commands[params][i].enabled = false; @@ -401,9 +403,9 @@ function enableAllCommandsByType(command, params, client) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - + params = toLowerCase(params); - + if(isNull(getServerData().commands[params])) { messagePlayerError(client, `Command type [#AAAAAA]${params} [#FFFFFF]does not exist!`); return false; @@ -452,7 +454,7 @@ function onPlayerCommand(event, client, command, params) { // console.warn(`[Asshat.Command] ${getPlayerDisplayForConsole(client)} attempted to use command from discord, but failed (not available on discord): /${command} ${paramsDisplay}`); // messagePlayerError(client, `The [#AAAAAA]/${command} [#FFFFFF] command isn't available on discord!`); // return false; - // } + // } //} if(!doesPlayerHaveStaffPermission(client, getCommandRequiredPermissions(command))) { @@ -460,7 +462,7 @@ function onPlayerCommand(event, client, command, params) { messagePlayerError(client, `You do not have permission to use the [#AAAAAA]/${command} [#FFFFFF]command!`); return false; } - + console.log(`[Asshat.Command] ${getPlayerDisplayForConsole(client)} used command: /${command} ${paramsDisplay}`); commandData.handlerFunction(command, params, client); } diff --git a/scripts/server/config.js b/scripts/server/config.js index a3927e5e..6135ed52 100644 --- a/scripts/server/config.js +++ b/scripts/server/config.js @@ -26,7 +26,7 @@ let globalConfig = { takeJobDistance: 5, stopWorkingDistance: 10, spawnCarDistance: 5, - payAndSprayDistance: 5, + payAndSprayDistance: 5, defaultKeybinds: [ new serverClasses.keyBindData(false, toInteger(SDLK_i), "engine"), new serverClasses.keyBindData(false, toInteger(SDLK_k), "lights"), @@ -37,8 +37,8 @@ let globalConfig = { ], exitPropertyDistance: 3.0, enterPropertyDistance: 3.0, - businessDimensionStart: 1000, - houseDimensionStart: 3000, + businessDimensionStart: 5000, + houseDimensionStart: 100, buyVehicleDriveAwayDistance: 25.0, returnToJobVehicleTime: 30, }; @@ -49,7 +49,7 @@ let gameConfig = { { // GTA III policeStation: 8, fireStation: 9, - hospital: 12, + hospital: 12, ammunation: 20, payAndSpray: 18, vehicleDealership: 6, @@ -63,7 +63,7 @@ let gameConfig = { { // GTA VC policeStation: 0, fireStation: 0, - hospital: 0, + hospital: 0, ammunation: 16, payAndSpray: 27, vehicleDealership: 7, @@ -72,12 +72,12 @@ let gameConfig = { bank: 0, fuelStation: -1, business: -1, - house: -1, + house: -1, }, { // GTA SA policeStation: 30, fireStation: 20, - hospital: 22, + hospital: 22, ammunation: 6, payAndSpray: 63, vehicleDealership: 55, @@ -92,12 +92,12 @@ let gameConfig = { bank: 52, fuelStation: 0, business: -1, - house: 31, + house: 31, }, { // GTA UG policeStation: 8, fireStation: 9, - hospital: 12, + hospital: 12, ammunation: 20, payAndSpray: 18, vehicleDealership: 6, @@ -106,12 +106,12 @@ let gameConfig = { bank: 52, fuelStation: 0, business: -1, - house: -1, + house: -1, }, { // GTA IV policeStation: 8, fireStation: 9, - hospital: 12, + hospital: 12, ammunation: 20, payAndSpray: 18, vehicleDealership: 6, @@ -120,8 +120,8 @@ let gameConfig = { bank: 52, fuelStation: 0, business: -1, - house: -1, - }, + house: -1, + }, ], pickupModels: [ {}, @@ -129,7 +129,7 @@ let gameConfig = { { // GTA 3 policeStation: 1361, fireStation: 1361, - hospital: 1361, + hospital: 1361, ammunation: 1361, payAndSpray: 1361, vehicleDealership: 1361, @@ -143,11 +143,11 @@ let gameConfig = { misc: 1361, exit: 1361 }, - + { // GTA Vice City policeStation: 375, fireStation: 406, - hospital: 366, + hospital: 366, ammunation: 406, payAndSpray: 406, vehicleDealership: 406, @@ -165,7 +165,7 @@ let gameConfig = { { // GTA San Andreas policeStation: 1247, fireStation: 1318, - hospital: 1240, + hospital: 1240, ammunation: 1239, payAndSpray: 1239, vehicleDealership: 1239, @@ -190,7 +190,7 @@ let gameConfig = { clothes: 0, info: 0, }, - + { // GTA Vice City business: 0, house: 0, @@ -205,7 +205,7 @@ let gameConfig = { bank: 1, clothes: 1, info: 1, - } + } ], // THIS IS SCREEN HEIGHT, NOT ACTUAL DOOR POSITION IN THE WORLD @@ -222,21 +222,48 @@ let gameConfig = { removedWorldObjects: [ false, [ - new serverClasses.removedWorldObjectData("fraightback04", new Vec3(1229.88, -84.8012, 13.4004), 50.0), // Truck trailer in Easy Credit Autos dealership parking lot - new serverClasses.removedWorldObjectData("fraightback03", new Vec3(1239.49, -68.0529, 11.6914), 50.0), // Truck trailer in Easy Credit Autos dealership parking lot + new serverClasses.removedWorldObjectData("fraightback04", toVector3(1229.88, -84.8012, 13.4004), 50.0), // Truck trailer in Easy Credit Autos dealership parking lot + new serverClasses.removedWorldObjectData("fraightback03", toVector3(1239.49, -68.0529, 11.6914), 50.0), // Truck trailer in Easy Credit Autos dealership parking lot ], [], [], [], [], [], - ] + ], + + interiorTemplates: [ + false, + { // GTA 3 + + }, + { // GTA VC + mall: new serverClasses.interiorTemplateData(toVector3(379.62, 1007.00, 19.22), 4), + malibuClub: new serverClasses.interiorTemplateData(toVector3(489.83, -76.49, 11.48), 17), + policeStation: new serverClasses.interiorTemplateData(toVector3(396.38, -472.96, 12.34), 12), + apartment: new serverClasses.interiorTemplateData(toVector3(26.67, -1328.89, 13.00), 11), + hotel: new serverClasses.interiorTemplateData(toVector3(228.53, -1277.12, 12.07), 1), + bikerBar: new serverClasses.interiorTemplateData(toVector3(-597.41, 651.84, 11.30), 11), + mansion: new serverClasses.interiorTemplateData(toVector3(-379.14, -551.65, 19.32), 2), + ammunationRange: new serverClasses.interiorTemplateData(toVector3(-667.79, 1217.51, 11.10), 10), + bank: new serverClasses.interiorTemplateData(toVector3(-894.52, -341.16, 13.45), 3), + stripClub: new serverClasses.interiorTemplateData(toVector3(97.53, -1472.06, 10.43), 5), + office: new serverClasses.interiorTemplateData(toVector3(120.82, -827.98, 10.62), 6), + arena: new serverClasses.interiorTemplateData(toVector3(-1080.49, 1331.16, 13.91), 15), + ghettoShack: new serverClasses.interiorTemplateData(toVector3(-962.72, 146.11, 9.395), 12), + }, + { // GTA SA + + } + ], }; // ---------------------------------------------------------------------------- function initConfigScript() { console.log("[Asshat.Config]: Initializing config script ..."); + serverConfig = loadServerConfigFromGameAndPort(server.game, server.port); + applyConfigToServer(serverConfig); console.log("[Asshat.Config]: Config script initialized!"); } @@ -256,7 +283,7 @@ function loadServerConfigFromGameAndPort(gameId, port) { } } disconnectFromDatabase(dbConnection); - } + } return false; } @@ -297,7 +324,7 @@ function applyConfigToServer(tempServerConfig) { function saveServerConfigToDatabase(serverConfigData) { console.log(`[Asshat.Config]: Saving server ${serverConfigData.databaseId} configuration to database ...`); let dbConnection = connectToDatabase(); - if(dbConnection) { + if(dbConnection) { let safeServerName = escapeDatabaseString(dbConnection, serverConfigData.name); let safePassword = escapeDatabaseString(dbConnection, serverConfigData.password); @@ -358,14 +385,14 @@ function setTimeCommand(command, params, client) { if(hour > 23 || hour < 0) { messagePlayerError(client, "The hour must be between 0 and 23!"); - return false; + return false; } if(minute > 59 || minute < 0) { messagePlayerError(client, "The minute must be between 0 and 59!"); - return false; - } - + return false; + } + gta.time.hour = hour; gta.time.minute = minute; @@ -399,8 +426,8 @@ function setWeatherCommand(command, params, client) { if(!weatherId) { messagePlayerError(client, `That weather ID or name is invalid!`); return false; - } - + } + gta.forceWeather(toInteger(weatherId)); messageAdminAction(`${client.name} set the weather to [#AAAAAA]${weatherNames[getServerGame()][toInteger(weatherId)]}`); @@ -431,7 +458,7 @@ function setSnowingCommand(command, params, client) { let splitParams = params.split(); let fallingSnow = Number(splitParams[0]) || !getServerConfig().fallingSnow; let groundSnow = Number(splitParams[1]) || !getServerConfig().groundSnow; - + fallingSnow = intToBool(toInteger(fallingSnow)); groundSnow = intToBool(toInteger(groundSnow)); @@ -461,7 +488,7 @@ function toggleServerLogoCommand(command, params, client) { } getServerConfig().useLogo = !getServerConfig().useLogo; - + triggerNetworkEvent("ag.logo", null, intToBool(getServerConfig().useLogo)); messageAdminAction(`${client.name} turned the server logo image ${getBoolRedGreenInlineColour(getServerConfig().useLogo)}${toUpperCase(getOnOffFromBool(getServerConfig().useLogo))}`); diff --git a/scripts/server/core.js b/scripts/server/core.js index cb9254b0..70850263 100644 --- a/scripts/server/core.js +++ b/scripts/server/core.js @@ -24,28 +24,28 @@ let serverData = { translation: { translationBaseURL: "http://api.mymemory.translated.net/get?de=example@example.com&q={0}&langpair={1}|{2}", languages: [ - ["Abkhazian", "AB"], - ["Afar", "AA"], - ["Afrikaans", "AF"], - ["Albanian", "SQ"], - ["Amharic", "AM"], - ["Arabic", "AR"], - ["Armenian", "HY"], - ["Assamese", "AS"], + ["Abkhazian", "AB"], + ["Afar", "AA"], + ["Afrikaans", "AF"], + ["Albanian", "SQ"], + ["Amharic", "AM"], + ["Arabic", "AR"], + ["Armenian", "HY"], + ["Assamese", "AS"], ["Aymara", "AY"], - ["Azerbaijani", "AZ"], - ["Bashkir", "BA"], - ["Basque", "EU"], - ["Bengali, Bangla", "BN"], - ["Bhutani", "DZ"], - ["Bihari", "BH"], - ["Bislama", "BI"], - ["Breton", "BR"], + ["Azerbaijani", "AZ"], + ["Bashkir", "BA"], + ["Basque", "EU"], + ["Bengali, Bangla", "BN"], + ["Bhutani", "DZ"], + ["Bihari", "BH"], + ["Bislama", "BI"], + ["Breton", "BR"], ["Bulgarian", "BG"], - ["Burmese", "MY"], + ["Burmese", "MY"], ["Byelorussian", "BE"], - ["Cambodian", "KM"], - ["Catalan", "CA"], + ["Cambodian", "KM"], + ["Catalan", "CA"], ["Chinese", "ZH"], ["Corsican", "CO"], ["Croatian", "HR"], @@ -167,19 +167,19 @@ let serverData = { policeStations: [ false, [ // GTA 3 - { + { position: toVector3(1143.875, -675.1875, 14.97), heading: 1.5, blip: false, name: "Portland", - }, - { + }, + { position: toVector3(340.25, -1123.375, 25.98), heading: 3.14, blip: false, name: "Staunton Island", }, - { + { position: toVector3(-1253.0, -138.1875, 58.75), heading: 1.5, blip: false, @@ -187,25 +187,25 @@ let serverData = { }, ], [ // GTA VC - { + { position: toVector3(399.77, -468.90, 11.73), heading: 0.0, blip: false, name: "Washington Beach", }, - { + { position: toVector3(508.96, 512.07, 12.10), heading: 0.0, blip: false, name: "Vice Point", }, - { + { position: toVector3(-657.43, 762.31, 11.59), heading: 0.0, blip: false, name: "Downtown", }, - { + { position: toVector3(-885.08, -470.44, 13.11), heading: 0.0, blip: false, @@ -213,103 +213,103 @@ let serverData = { }, ], [ // GTA SA - { + { position: toVector3(1545.53, -1675.64, 13.561), heading: -1.575, blip: false, name: "Los Santos", - }, - + }, + ], [ // GTA UG - + ], [ // GTA IV - { + { position: toVector3(894.99, -357.39, 18.185), heading: 2.923, blip: false, name: "Broker", }, - { + { position: toVector3(435.40, 1592.29, 17.353), heading: 3.087, blip: false, name: "South Bohan", - }, - { + }, + { position: toVector3(974.93, 1870.45, 23.073), heading: -1.621, blip: false, name: "Northern Gardens", - }, - { + }, + { position: toVector3(1233.25, -89.13, 28.034), heading: 1.568, blip: false, name: "South Slopes", }, - { + { position: toVector3(50.12, 679.88, 15.316), heading: 1.569, blip: false, name: "Middle Park East", }, - { + { position: toVector3(85.21, 1189.82, 14.755), heading: 3.127, blip: false, name: "East Holland", }, - { + { position: toVector3(2170.87, 448.87, 6.085), heading: 1.501, blip: false, name: "Francis International Airport", }, - { + { position: toVector3(213.12, -211.70, 10.752), heading: 0.200, blip: false, name: "Chinatown", }, - { + { position: toVector3(-1714.95, 276.31, 22.134), heading: 1.127, blip: false, name: "Acter", }, - { + { position: toVector3(-1220.73, -231.53, 3.024), heading: 2.210, blip: false, name: "Port Tudor", }, - { + { position: toVector3(-927.66, 1263.63, 24.587), heading: -0.913, blip: false, name: "Leftwood", - }, - ] + }, + ] ], fireStations: [ false, [ // GTA 3 - { + { position: toVector3(1103.70, -52.45, 7.49), heading: 1.5, blip: false, name: "Portland", - }, - { + }, + { position: toVector3(-78.48, -436.80, 16.17), heading: 3.14, blip: false, name: "Staunton Island", }, - { + { position: toVector3(-1202.10, -14.67, 53.20), heading: 1.5, blip: false, @@ -323,34 +323,34 @@ let serverData = { ], [ // GTA UG - + ], [ // GTA IV - { + { position: toVector3(953.13, 95.90, 35.004), heading: 1.595, blip: false, name: "Broker", }, - { + { position: toVector3(-271.02, 1542.15, 20.420), heading: -1.160, blip: false, name: "Northwood", }, - { + { position: toVector3(1120.47, 1712.36, 10.534), heading: -0.682, blip: false, name: "Northern Gardens", }, - { + { position: toVector3(2364.87, 166.83, 5.813), heading: 0.156, blip: false, name: "Francis International Airport", }, - { + { position: toVector3(295.40, -336.88, 4.963), heading: 2.887, blip: false, @@ -361,19 +361,19 @@ let serverData = { hospitals: [ false, [ // GTA 3 - { + { position: toVector3(1144.25, -596.875, 14.97), heading: 1.5, blip: false, name: "Portland", - }, - { + }, + { position: toVector3(183.5, -17.75, 16.21), heading: 3.14, blip: false, name: "Staunton Island", }, - { + { position: toVector3(-1259.5, -44.5, 58.89), heading: 1.5, blip: false, @@ -381,13 +381,13 @@ let serverData = { }, ], [ // GTA VC - { + { position: toVector3(493.14, 709.31, 11.80), heading: 1.5, blip: false, name: "Unknown", }, - { + { position: toVector3(-826.06, 1144.41, 12.41), heading: 1.5, blip: false, @@ -395,13 +395,13 @@ let serverData = { }, ], [ // GTA SA - { + { position: toVector3(1172.96, -1323.42, 15.40), heading: 1.5, blip: false, name: "All Saints", }, - { + { position: toVector3(2034.04, -1405.07, 17.24), heading: 1.5, blip: false, @@ -409,49 +409,49 @@ let serverData = { }, ], [ // GTA UG - + ], [ // GTA IV - { + { position: toVector3(1199.59, 196.78, 33.554), heading: 1.633, blip: false, name: "Schottler", }, - { + { position: toVector3(980.71, 1831.61, 23.898), heading: -0.049, blip: false, name: "Northern Gardens", - }, - { + }, + { position: toVector3(-1317.27, 1277.20, 22.370), heading: 2.246, blip: false, name: "Leftwood", - }, - { + }, + { position: toVector3(-1538.43, 344.58, 20.943), heading: -0.156, blip: false, name: "Acter", }, - ] + ] ], payAndSprays: [ false, [ // GTA 3 - { + { position: toVector3(925.4, -360.3, 10.83), blip: false, name: "Portland", - }, - { + }, + { position: toVector3(381.8, -493.8, 25.95), blip: false, name: "Staunton Island", }, - { + { position: toVector3(-1142.4, 35.01, 58.61), blip: false, name: "Shoreside Vale", @@ -464,22 +464,22 @@ let serverData = { ], [ // GTA UG - + ], [ // GTA IV ] ], - + ammunations: [ false, [ // GTA 3 - { + { position: toVector3(1068.3, -400.9, 15.24), blip: false, name: "Portland", - }, - { + }, + { position: toVector3(348.2, -717.9, 26.43), blip: false, name: "Staunton Island", @@ -492,7 +492,7 @@ let serverData = { ], [ // GTA UG - + ], [ // GTA IV @@ -501,8 +501,8 @@ let serverData = { fuelStations: [ false, [ // GTA 3 - - { + + { position: toVector3(1161.9, -76.73, 7.27), blip: false, name: "Portland", @@ -515,11 +515,11 @@ let serverData = { ], [ // GTA UG - + ], [ // GTA IV - ] + ] ], }; diff --git a/scripts/server/database.js b/scripts/server/database.js index 335c4e07..13401837 100644 --- a/scripts/server/database.js +++ b/scripts/server/database.js @@ -11,10 +11,10 @@ // ---------------------------------------------------------------------------- let databaseConfig = { - host: "158.69.238.64", - user: "db24053", - pass: "G3At3d7BsA", - name: "db24053", + host: "127.0.0.1", + user: "gtac-main", + pass: "QaH2rOP7BOBAkuX5V74EsOFi4uh5XO", + name: "gtac_main", port: 3306, usePersistentConnection: true, } @@ -41,7 +41,7 @@ function connectToDatabase() { } console.log("[Asshat.Database] Database connection successful!"); - return persistentDatabaseConnection; + return persistentDatabaseConnection; } else { //console.log("[Asshat.Database] Using existing database connection."); return persistentDatabaseConnection; diff --git a/scripts/server/developer.js b/scripts/server/developer.js index cdad5370..044c3714 100644 --- a/scripts/server/developer.js +++ b/scripts/server/developer.js @@ -155,12 +155,12 @@ function executeClientCodeCommand(command, params, client) { if(!targetClient) { messagePlayerError(client, "That player was not found!"); - return false; + return false; } if(targetCode == "") { messagePlayerError(client, "You didn't enter any code!"); - return false; + return false; } triggerNetworkEvent("ag.runCode", targetClient, targetCode, client.index); @@ -226,7 +226,7 @@ function submitIdea(client, ideaText) { } else { databaseId = getPlayerData(client).accountData.databaseId; } - + let dbConnection = connectToDatabase(); if(dbConnection) { let safeIdeaMessage = escapeDatabaseString(dbConnection, ideaText); diff --git a/scripts/server/discord.js b/scripts/server/discord.js index 16f0dee5..9fc23e7b 100644 --- a/scripts/server/discord.js +++ b/scripts/server/discord.js @@ -33,13 +33,13 @@ addEventHandler("OnDiscordCommand", function(command, params, discordUser) { function messageDiscordUser(discordUser, messageText) { let socketData = JSON.stringify({ - type: "chat.message.text", + type: "chat.message.text", payload: { author: discordUser.name, text: messageText, } }); - sendDiscordSocketData(socketData); + sendDiscordSocketData(socketData); } // --------------------------------------------------------------------------- @@ -48,7 +48,7 @@ function sendDiscordSocketData(socketData) { if(!getDiscordSocket()) { return false; } - + getDiscordSocket().send(module.hash.encodeBase64(socketData) + "\r\n"); } diff --git a/scripts/server/event.js b/scripts/server/event.js index c6d79431..e28c54aa 100644 --- a/scripts/server/event.js +++ b/scripts/server/event.js @@ -11,7 +11,7 @@ // --------------------------------------------------------------------------- function initEventScript() { - console.log("[Asshat.Event]: Initializing event script ..."); + console.log("[Asshat.Event]: Initializing event script ..."); addNetworkHandler("ag.onPlayerEnterVehicle", playerEnteredVehicle); addNetworkHandler("ag.onPlayerExitVehicle", playerExitedVehicle); console.log("[Asshat.Event]: Event script initialized!"); @@ -82,7 +82,7 @@ addEventHandler("OnProcess", function(event, deltaTime) { for(let i in clients) { if(getPlayerData(clients[i])) { if(getPlayerData(clients[i]).buyingVehicle) { - if(getPlayerVehicle(clients[i]) == getPlayerData(clients[i]).buyingVehicle) { + if(getPlayerVehicle(clients[i]) == getPlayerData(clients[i]).buyingVehicle) { if(getDistance(getVehiclePosition(getPlayerData(clients[i]).buyingVehicle), getVehicleData(getPlayerData(clients[i]).buyingVehicle).spawnPosition) > getGlobalConfig().buyVehicleDriveAwayDistance) { if(getPlayerCurrentSubAccount(clients[i]).cash < getVehicleData(getPlayerData(clients[i]).buyingVehicle).buyPrice) { messagePlayerError(client, "You don't have enough money to buy this vehicle!"); @@ -104,7 +104,7 @@ addEventHandler("OnProcess", function(event, deltaTime) { } } else { messagePlayerError(client, "You canceled the vehicle purchase by exiting the vehicle!"); - respawnVehicle(getPlayerData(clients[i]).buyingVehicle); + respawnVehicle(getPlayerData(clients[i]).buyingVehicle); getPlayerData(clients[i]).buyingVehicle = false; } } @@ -138,9 +138,9 @@ addEventHandler("OnPedEnterVehicle", function(event, ped, vehicle, seat) { } } else { messagePlayerNormal(client, `🔒 This ${getVehicleName(vehicle)} is locked and you don't have the keys to unlock it`); - } - } - } + } + } + } }); // --------------------------------------------------------------------------- @@ -160,7 +160,7 @@ async function playerEnteredVehicle(client) { console.log(`[Asshat.Event] ${getPlayerDisplayForConsole(client)} entered a ${getVehicleName(vehicle)} (ID: ${vehicle.getData("ag.dataSlot")}, Database ID: ${getVehicleData(vehicle).databaseId})`); getPlayerData(client).lastVehicle = vehicle; - + if(getPlayerVehicleSeat(client) == AG_VEHSEAT_DRIVER) { vehicle.engine = getVehicleData(vehicle).engine; @@ -186,7 +186,7 @@ async function playerEnteredVehicle(client) { } let currentSubAccount = getPlayerCurrentSubAccount(client); - + if(isPlayerWorking(client)) { if(getVehicleData(vehicle).ownerType == AG_VEHOWNER_JOB) { if(getVehicleData(vehicle).ownerId == getPlayerCurrentSubAccount(client).job) { @@ -203,7 +203,7 @@ async function playerEnteredVehicle(client) { stopReturnToJobVehicleCountdown(client); } } - } + } } } @@ -229,28 +229,75 @@ function playerExitedVehicle(client) { // --------------------------------------------------------------------------- -function processPlayerDeath(client) { - removeEntityData(client.player, "ag.spawned", true); - - let closestHospital = getClosestHospital(getPlayerPosition(client)); +function processPlayerDeath(client, position) { + removeEntityData(client.player, "ag.spawned"); + triggerNetworkEvent("ag.control", client, false); setTimeout(function() { triggerNetworkEvent("ag.fadeCamera", client, false, 1.0); setTimeout(function() { client.despawnPlayer(); if(getPlayerCurrentSubAccount(client).inJail) { - let closestJail = getClosestJail(getPlayerPosition(client)); + let closestJail = getClosestJail(position); spawnPlayer(client, closestJail.position, closestJail.heading, getPlayerCurrentSubAccount(client).skin); } else { + getPlayerCurrentSubAccount(client).inHospital = true; + let closestHospital = getClosestHospital(position); spawnPlayer(client, closestHospital.position, closestHospital.heading, getPlayerCurrentSubAccount(client).skin); } - setTimeout(function() { - setEntityData(client.player, "ag.spawned", true, true); - triggerNetworkEvent("ag.fadeCamera", client, true, 1.0); - triggerNetworkEvent("ag.control", client, true); - }, 1000); - }, 2000); + }, 2000); }, 1000); } +// --------------------------------------------------------------------------- + +function processPedSpawn(ped) { + if(ped.type == ELEMENT_PLAYER) { + setTimeout(processPlayerSpawn, 1000, ped); + } +} + +// --------------------------------------------------------------------------- + +function processPlayerSpawn(ped) { + if(getClientFromPlayerElement(ped) == null) { + setTimeout(processPlayerSpawn, ped, 500); + return false; + } + + let client = getClientFromPlayerElement(ped); + + if(!getPlayerData(client)) { + client.disconnect(); + return false; + } + + if(!getPlayerData(client).switchingCharacter) { + return false; + } + + messagePlayerAlert(client, `You are now playing as: [#0099FF]${tempSubAccount.firstName} ${tempSubAccount.lastName}`, getColourByName("white")); + messagePlayerNormal(client, "This server is in early development and may restart at any time for updates.", getColourByName("orange")); + messagePlayerNormal(client, "Please report any bugs using /bug and suggestions using /idea", getColourByName("yellow")); + + triggerNetworkEvent("ag.restoreCamera", client); + setEntityData(client, "ag.spawned", true, true); + + setTimeout(function() { + setEntityData(ped, "ag.spawned", true, true); + setPlayerPosition(client, tempSubAccount.spawnPosition); + setPlayerHeading(client, tempSubAccount.spawnHeading); + setPlayerInterior(client, tempSubAccount.interior); + setPlayerVirtualWorld(client, tempSubAccount.dimension); + setTimeout(function() { + updatePlayerCash(client); + }, 1000); + }, 500); + + updateAllPlayerNameTags(); + + getPlayerData(client).switchingCharacter = false; + triggerNetworkEvent("ag.jobType", client, tempSubAccount.job); +} + // --------------------------------------------------------------------------- \ No newline at end of file diff --git a/scripts/server/fishing.js b/scripts/server/fishing.js index 3f468b7a..d0ceaf5f 100644 --- a/scripts/server/fishing.js +++ b/scripts/server/fishing.js @@ -34,35 +34,35 @@ let fishingLocations = [ [ // GTA IV - ], + ], ]; // --------------------------------------------------------------------------- let fishingCatchables = [ // Fish - ["Salmon", 0, 500, 1, 15], - ["Tuna", 0, 700, 1, 15], - ["Crab", 0, 200, 1, 5], - ["Trout", 0, 250, 1, 15], - ["Sea Bass", 0, 550, 1, 8], - ["Shark", 0, 150, 1, 15], - ["Turtle", 0, 50, 1, 25], - ["Manta Ray", 0, 250, 1, 25], - ["Cat Fish", 0, 350, 1, 5], - ["Blue Marlin", 0, 450, 1, 5], + ["Salmon", 0, 500, 1, 15], + ["Tuna", 0, 700, 1, 15], + ["Crab", 0, 200, 1, 5], + ["Trout", 0, 250, 1, 15], + ["Sea Bass", 0, 550, 1, 8], + ["Shark", 0, 150, 1, 15], + ["Turtle", 0, 50, 1, 25], + ["Manta Ray", 0, 250, 1, 25], + ["Cat Fish", 0, 350, 1, 5], + ["Blue Marlin", 0, 450, 1, 5], // Junk - ["Can", 0, 0, 0, 0], - ["Pants", 0, 0, 0, 0], - ["Shoes", 0, 0, 0, 0], - ["Garbage", 0, 0, 0, 0], - ["Baby Diaper", 0, 0, 0, 0], - ["Tire", 0, 0, 0, 0], - ["Car Battery", 0, 0, 0, 0], - ["Horse Hoove", 0, 0, 0, 0], - ["Log", 0, 0, 0, 0], - ["Soggy Dildo", 0, 0, 0, 0], + ["Can", 0, 0, 0, 0], + ["Pants", 0, 0, 0, 0], + ["Shoes", 0, 0, 0, 0], + ["Garbage", 0, 0, 0, 0], + ["Baby Diaper", 0, 0, 0, 0], + ["Tire", 0, 0, 0, 0], + ["Car Battery", 0, 0, 0, 0], + ["Horse Hoove", 0, 0, 0, 0], + ["Log", 0, 0, 0, 0], + ["Soggy Dildo", 0, 0, 0, 0], ]; // --------------------------------------------------------------------------- \ No newline at end of file diff --git a/scripts/server/help.js b/scripts/server/help.js index 33d51f7a..a69f668c 100644 --- a/scripts/server/help.js +++ b/scripts/server/help.js @@ -41,37 +41,37 @@ function helpCommand(command, params, client) { case "vehicle": showVehicleHelpMessage(client); - break; + break; case "dealership": showVehicleDealershipHelpMessage(client); - break; - + break; + case "job": showJobHelpMessage(client); - break; - + break; + case "chat": showChatHelpMessage(client); - break; + break; case "rules": showRulesHelpMessage(client); - break; - + break; + case "website": showWebsiteHelpMessage(client); break; - + case "discord": showDiscordHelpMessage(client); break; - + case "anim": case "animation": showAnimationHelpMessage(client); break; - + case "ammunation": case "ammu": showAmmunationHelpMessage(client); @@ -81,8 +81,8 @@ function helpCommand(command, params, client) { case "clothes": showClothesHelpMessage(client); break; - - case "key": + + case "key": case "keys": case "keybinds": case "bindkey": @@ -133,7 +133,7 @@ function showAccountHelpMessage(client) { function showVehicleHelpMessage(client) { messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Vehicle Help [#FF9900]============================="); - messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Visit dealerships to buy new vehicles (Use [#AAAAAA]/help dealership [#FFFFFF]for more info."); + messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Visit dealerships to buy new vehicles (Use [#AAAAAA]/help dealership [#FFFFFF]for more info.)"); messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Some commands: [#AAAAAA]/lock, /engine, /lights, /trunk, /rentveh, /buyveh, /rentprice, /buyprice"); messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Your personal vehicles will save wherever you or somebody else leaves them!"); messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Visit a mechanic garage to repair, colour, and tune up your car! [#AAAAAA]/help mechanic [#FFFFFF] for info"); @@ -179,7 +179,7 @@ function showRulesHelpMessage(client) { messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]No terrorist or terrorism roleplay is allowed."); messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Always follow instructions given by moderators and admins."); messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Do not mix the chats (metagaming). You can't use info in IC that was received OOC"); - messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Keep English in main chats. If you aren't good at English, use [#AAAAAA]/help [#FFFFFF]language"); + messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Keep English in main chats. If you aren't good at English, use [#AAAAAA]/help language"); } // ---------------------------------------------------------------------------- @@ -246,7 +246,7 @@ function showApproachJobWhileUnemployedTip(client) { if(getPlayerData(client).accountData.shownTips & !shownTipsFlags.approachJobWhileUnemployed) { messagePlayerTip(client, `Approach the icon and use /jobinfo to see details about this job.`); getPlayerData(client).accountData.shownTips = getPlayerData(client).accountData.shownTips | shownTipsFlags.approachJobWhileUnemployed; - } + } } // ---------------------------------------------------------------------------- @@ -255,7 +255,7 @@ function showTakeNearbyJobTip(client) { if(getPlayerData(client).accountData.shownTips & !shownTipsFlags.takeJobWhileUnemployed) { messagePlayerTip(client, `You are nearby a job location. Look for the spinning icon.`); getPlayerData(client).accountData.shownTips = getPlayerData(client).accountData.shownTips | shownTipsFlags.takeJobWhileUnemployed; - } + } } // ---------------------------------------------------------------------------- diff --git a/scripts/server/house.js b/scripts/server/house.js index 806bf4c3..0784574d 100644 --- a/scripts/server/house.js +++ b/scripts/server/house.js @@ -24,7 +24,7 @@ function loadHousesFromDatabase() { let tempHouses = []; let dbConnection = connectToDatabase(); let dbAssoc; - + if(dbConnection) { let dbQuery = queryDatabase(dbConnection, `SELECT * FROM house_main WHERE house_server = ${getServerId()}`); if(dbQuery) { @@ -52,7 +52,7 @@ function createHouseCommand(command, params, client) { createHouseEntrancePickup(getServerData().houses.length-1); createHouseExitPickup(getServerData().houses.length-1); createHouseEntranceBlip(getServerData().houses.length-1); - createHouseExitBlip(getServerData().houses.length-1); + createHouseExitBlip(getServerData().houses.length-1); messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]created house [#11CC11]${tempHouseData.description}`); } @@ -61,11 +61,11 @@ function createHouseCommand(command, params, client) { function lockUnlockHouseCommand(command, params, client) { let houseId = toInteger((isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client))); - + if(!getHouseData(houseId)) { messagePlayerError("House not found!"); return false; - } + } getHouseData(houseId).locked = !getHouseData(houseId).locked; getHouseData(houseId).entrancePickup.setData("ag.label.locked", getHouseData(houseId).locked, true); @@ -82,7 +82,7 @@ function setHouseDescriptionCommand(command, params, client) { if(!getHouseData(houseId)) { messagePlayerError("House not found!"); return false; - } + } let oldDescription = getHouseData(houseId).description; getHouseData(houseId).description = newHouseDescription; @@ -162,13 +162,63 @@ function setHousePickupCommand(command, params, client) { } createHouseEntrancePickup(houseId); - } + } messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]set house [#11CC11]${getHouseData(houseId).description} [#FFFFFF]pickup display to [#AAAAAA]${toLowerCase(typeParam)}`); } // --------------------------------------------------------------------------- +function setHouseInteriorTypeCommand(command, params, client) { + let splitParams = params.split(" "); + let typeParam = splitParams[0] || "none"; + let houseId = getHouseFromParams(splitParams[1]) || (isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client)); + + if(!getHouseData(houseId)) { + messagePlayerError(client, "Business not found!"); + return false; + } + + if(isNaN(typeParam)) { + if(toLowerCase(typeParam) == "none") { + getHouseData(houseId).exitPosition = toVector3(0.0, 0.0, 0.0); + getHouseData(houseId).exitInterior = -1; + getHouseData(houseId).hasInterior = false; + messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]remove house [#11CC11]${getHouseData(houseId).description} [#FFFFFF]interior`); + return false; + } + + if(isNull(getGameConfig().interiorTemplates[getServerGame()][typeParam])) { + messagePlayerError(client, "Invalid interior type! Use an interior type name or an existing house database ID"); + messagePlayerInfo(client, `Interior Types: [#AAAAAA]${Object.keys(getGameConfig().interiorTemplates[getServerGame()]).join(", ")}`) + return false; + } + + getHouseData(houseId).exitPosition = getGameConfig().interiorTemplates[getServerGame()][typeParam].exitPosition; + getHouseData(houseId).exitInterior = getGameConfig().interiorTemplates[getServerGame()][typeParam].exitInterior; + getHouseData(houseId).exitDimension = getHouseData(houseId).databaseId+getGlobalConfig().houseDimensionStart; + getHouseData(houseId).hasInterior = true; + } else { + if(!getHouseData(houseId)) { + messagePlayerError(client, "Business ID not found!"); + return false; + } + getHouseData(houseId).exitPosition = getHouseData(houseId).exitPosition; + getHouseData(houseId).exitInterior = getHouseData(houseId).exitInterior; + getHouseData(houseId).exitDimension = getHouseData(houseId).databaseId+getGlobalConfig().houseDimensionStart; + getHouseData(houseId).hasInterior = true; + } + + deleteHouseEntrancePickup(houseId); + deleteHouseExitPickup(houseId); + createHouseEntrancePickup(houseId); + createHouseExitPickup(houseId); + + messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]set house [#11CC11]${getHouseData(houseId).description} [#FFFFFF]interior type to [#AAAAAA]${toLowerCase(typeParam)}`); +} + +// --------------------------------------------------------------------------- + function setHouseBlipCommand(command, params, client) { let typeParam = params || "house"; let houseId = toInteger((isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client))); @@ -196,7 +246,7 @@ function setHouseBlipCommand(command, params, client) { } createHouseEntranceBlip(houseId); - } + } messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]set house [#11CC11]${getHouseData(houseId).description} [#FFFFFF]blip display to [#AAAAAA]${toLowerCase(typeParam)}`); } @@ -205,16 +255,16 @@ function setHouseBlipCommand(command, params, client) { function moveHouseEntranceCommand(command, params, client) { let houseId = toInteger((isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client))); - + getHouseData(houseId).entrancePosition = getPlayerPosition(client); getHouseData(houseId).entranceDimension = getPlayerVirtualWorld(client); getHouseData(houseId).entranceInterior = getPlayerInterior(client); deleteHouseEntranceBlip(houseId); deleteHouseEntrancePickup(houseId); - + createHouseEntranceBlip(houseId); - createHouseEntrancePickup(houseId); + createHouseEntrancePickup(houseId); messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]moved house [#11CC11]${getHouseData(houseId).description} [#FFFFFF]entrance to their position`); } @@ -223,14 +273,14 @@ function moveHouseEntranceCommand(command, params, client) { function moveHouseExitCommand(command, params, client) { let houseId = toInteger((isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client))); - + getHouseData(houseId).entrancePosition = getPlayerPosition(client); getHouseData(houseId).entranceDimension = getPlayerVirtualWorld(client); getHouseData(houseId).entranceInterior = getPlayerInterior(client); - + deleteHouseExitBlip(houseId); deleteHouseExitPickup(houseId); - + createHouseExitBlip(houseId); createHouseExitPickup(houseId); @@ -259,7 +309,7 @@ function deleteHouse(houseId, whoDeleted = 0) { let dbConnection = connectToDatabase(); let dbQuery = null; - + if(dbConnection) { dbQuery = queryDatabase(dbConnection, `DELETE FROM house_main WHERE house_id = ${tempHouseData.databaseId}`); if(dbQuery) { @@ -272,7 +322,7 @@ function deleteHouse(houseId, whoDeleted = 0) { deleteHouseExitPickup(houseId); deleteHouseEntranceBlip(houseId); - deleteHouseExitBlip(houseId); + deleteHouseExitBlip(houseId); removePlayersFromHouse(houseId); @@ -305,7 +355,7 @@ function createHouse(description, entrancePosition, exitPosition, entrancePickup tempHouseData.exitPickupModel = exitPickupModel; tempHouseData.exitBlipModel = exitBlipModel; tempHouseData.exitInterior = exitInteriorId; - tempHouseData.exitDimension = exitVirtualWorld; + tempHouseData.exitDimension = exitVirtualWorld; return tempHouseData; } @@ -361,11 +411,11 @@ function saveHouseToDatabase(houseId) { if(dbConnection) { let safeHouseDescription = escapeDatabaseString(dbConnection, tempHouseData.description); if(tempHouseData.databaseId == 0) { - let dbQueryString = `INSERT INTO house_main (house_server, house_description, house_owner_type, house_owner_id, house_locked, house_entrance_pos_x, house_entrance_pos_y, house_entrance_pos_z, house_entrance_rot_z, house_entrance_int, house_entrance_vw, house_exit_pos_x, house_exit_pos_y, house_exit_pos_z, house_exit_rot_z, house_exit_int, house_exit_vw) VALUES (${getServerId()}, '${safeHouseDescription}', ${tempHouseData.ownerType}, ${tempHouseData.ownerId}, ${boolToInt(tempHouseData.locked)}, ${tempHouseData.entrancePosition.x}, ${tempHouseData.entrancePosition.y}, ${tempHouseData.entrancePosition.z}, ${tempHouseData.entranceRotation}, ${tempHouseData.entranceInterior}, ${tempHouseData.entranceDimension}, ${tempHouseData.exitPosition.x}, ${tempHouseData.exitPosition.y}, ${tempHouseData.exitPosition.z}, ${tempHouseData.exitRotation}, ${tempHouseData.exitInterior}, ${tempHouseData.exitDimension})`; + let dbQueryString = `INSERT INTO house_main (house_server, house_description, house_owner_type, house_owner_id, house_locked, house_entrance_pos_x, house_entrance_pos_y, house_entrance_pos_z, house_entrance_rot_z, house_entrance_int, house_entrance_vw, house_exit_pos_x, house_exit_pos_y, house_exit_pos_z, house_exit_rot_z, house_exit_int, house_exit_vw, house_has_interior) VALUES (${getServerId()}, '${safeHouseDescription}', ${tempHouseData.ownerType}, ${tempHouseData.ownerId}, ${boolToInt(tempHouseData.locked)}, ${tempHouseData.entrancePosition.x}, ${tempHouseData.entrancePosition.y}, ${tempHouseData.entrancePosition.z}, ${tempHouseData.entranceRotation}, ${tempHouseData.entranceInterior}, ${tempHouseData.entranceDimension}, ${tempHouseData.exitPosition.x}, ${tempHouseData.exitPosition.y}, ${tempHouseData.exitPosition.z}, ${tempHouseData.exitRotation}, ${tempHouseData.exitInterior}, ${tempHouseData.exitDimension}, ${boolToInt(tempHouseData.hasInterior)})`; queryDatabase(dbConnection, dbQueryString); getServerData().houses[houseId].databaseId = getDatabaseInsertId(dbConnection); } else { - let dbQueryString = `UPDATE house_main SET house_description='${safeHouseDescription}', house_owner_type=${tempHouseData.ownerType}, house_owner_id=${tempHouseData.ownerId}, house_locked=${boolToInt(tempHouseData.locked)}, house_entrance_pos_x=${tempHouseData.entrancePosition.x}, house_entrance_pos_y=${tempHouseData.entrancePosition.y}, house_entrance_pos_z=${tempHouseData.entrancePosition.z}, house_entrance_rot_z=${tempHouseData.entranceRotation}, house_entrance_int=${tempHouseData.entranceInterior}, house_entrance_vw=${tempHouseData.entranceDimension}, house_exit_pos_x=${tempHouseData.exitPosition.x}, house_exit_pos_y=${tempHouseData.exitPosition.y}, house_exit_pos_z=${tempHouseData.exitPosition.z}, house_exit_rot_z=${tempHouseData.exitRotation}, house_exit_int=${tempHouseData.exitInterior}, house_exit_vw=${tempHouseData.exitDimension} WHERE house_id=${tempHouseData.databaseId}`; + let dbQueryString = `UPDATE house_main SET house_description='${safeHouseDescription}', house_owner_type=${tempHouseData.ownerType}, house_owner_id=${tempHouseData.ownerId}, house_locked=${boolToInt(tempHouseData.locked)}, house_entrance_pos_x=${tempHouseData.entrancePosition.x}, house_entrance_pos_y=${tempHouseData.entrancePosition.y}, house_entrance_pos_z=${tempHouseData.entrancePosition.z}, house_entrance_rot_z=${tempHouseData.entranceRotation}, house_entrance_int=${tempHouseData.entranceInterior}, house_entrance_vw=${tempHouseData.entranceDimension}, house_exit_pos_x=${tempHouseData.exitPosition.x}, house_exit_pos_y=${tempHouseData.exitPosition.y}, house_exit_pos_z=${tempHouseData.exitPosition.z}, house_exit_rot_z=${tempHouseData.exitRotation}, house_exit_int=${tempHouseData.exitInterior}, house_exit_vw=${tempHouseData.exitDimension}, house_has_interior=${boolToInt(tempHouseData.hasInterior)} WHERE house_id=${tempHouseData.databaseId}`; queryDatabase(dbConnection, dbQueryString); } disconnectFromDatabase(dbConnection); @@ -373,7 +423,7 @@ function saveHouseToDatabase(houseId) { } console.log(`[Asshat.house]: Saved house '${tempHouseData.description}' to database!`); - return false; + return false; } // --------------------------------------------------------------------------- @@ -456,7 +506,7 @@ function createHouseExitPickup(houseId) { getHouseData(houseId).exitPickup.dimension = getHouseData(houseId).exitDimension; //getHouseData(houseId).exitPickup.interior = getHouseData(houseId).exitInterior; getHouseData(houseId).exitPickup.setData("ag.owner.type", AG_PICKUP_HOUSE_EXIT, false); - getHouseData(houseId).exitPickup.setData("ag.owner.id", houseId, false); + getHouseData(houseId).exitPickup.setData("ag.owner.id", houseId, false); getHouseData(houseId).exitPickup.setData("ag.label.type", AG_LABEL_EXIT, true); addToWorld(getHouseData(houseId).exitPickup); } @@ -493,17 +543,17 @@ function getHouseOwnerTypeText(ownerType) { return "clan"; case AG_HOUSEOWNER_PLAYER: - return "player"; + return "player"; case AG_BIZOWNER_NONE: return "not owned"; case AG_BIZOWNER_PUBLIC: - return "not owned"; - + return "not owned"; + case AG_BIZOWNER_JOB: - return "job"; - + return "job"; + default: return "unknown"; } @@ -544,8 +594,8 @@ function getHouseInfoCommand(command, params, client) { case AG_HOUSEOWNER_JOB: ownerName = getJobData(getHouseData(houseId).ownerId).name; - break; - } + break; + } messagePlayerNormal(client, `🏠 [#11CC11][House Info] [#FFFFFF]Description: [#AAAAAA]${getHouseData(houseId).description}, [#FFFFFF]Owner: [#AAAAAA]${ownerName} (${getHouseOwnerTypeText(getHouseData(houseId).ownerType)}), [#FFFFFF]Locked: [#AAAAAA]${getYesNoFromBool(intToBool(getHouseData(houseId).locked))}, [#FFFFFF]ID: [#AAAAAA]${houseId}/${getHouseData(houseId).databaseId}`); } @@ -572,33 +622,9 @@ function doesHouseHaveInterior(houseId) { // --------------------------------------------------------------------------- -function sendAllHouseLabelsToPlayer(client) { - let tempHouseLabels = []; - let totalHouses = getServerData().houses.length; - let housesPerNetworkEvent = 100; - let totalNetworkEvents = Math.ceil(totalHouses/housesPerNetworkEvent); - for(let i = 0 ; i < totalNetworkEvents ; i++) { - for(let j = 0 ; j < housesPerNetworkEvent ; j++) { - let tempHouseId = (i*housesPerNetworkEvent)+j; - if(typeof getServerData().houses[tempHouseId] != "undefined") { - tempHouseLabels.push([tempHouseId, getServerData().houses[tempHouseId].entrancePosition, getGameConfig().propertyLabelHeight[getServerGame()], getServerData().houses[tempHouseId].description, getServerData().houses[tempHouseId].locked, false]); - } - } - triggerNetworkEvent("ag.houselabel.all", client, tempHouseLabels); - tempHouseLabels = []; - } -} - -// --------------------------------------------------------------------------- - -function sendHouseLabelToPlayers(houseId) { - triggerNetworkEvent("ag.houselabel.add", null, houseId, getServerData().houses[houseId].entrancePosition, getGameConfig().propertyLabelHeight[getServerGame()], getServerData().houses[houseId].description, getServerData().houses[houseId].locked, false); -} - -// --------------------------------------------------------------------------- - function deleteHouseEntrancePickup(houseId) { if(getHouseData(houseId).entrancePickup != null) { + removeFromWorld(getHouseData(houseId).entrancePickup); destroyElement(getHouseData(houseId).entrancePickup); getHouseData(houseId).entrancePickup = null; } @@ -608,15 +634,17 @@ function deleteHouseEntrancePickup(houseId) { function deleteHouseExitPickup(houseId) { if(getHouseData(houseId).exitPickup != null) { + removeFromWorld(getHouseData(houseId).exitPickup); destroyElement(getHouseData(houseId).exitPickup); getHouseData(houseId).exitPickup = null; - } + } } // --------------------------------------------------------------------------- function deleteHouseEntranceBlip(houseId) { if(getHouseData(houseId).entranceBlip != null) { + removeFromWorld(getHouseData(houseId).entranceBlip); destroyElement(getHouseData(houseId).entranceBlip); getHouseData(houseId).entranceBlip = null; } @@ -626,9 +654,10 @@ function deleteHouseEntranceBlip(houseId) { function deleteHouseExitBlip(houseId) { if(getHouseData(houseId).exitBlip != null) { + removeFromWorld(getHouseData(houseId).exitBlip); destroyElement(getHouseData(houseId).exitBlip); getHouseData(houseId).exitBlip = null; - } + } } // --------------------------------------------------------------------------- @@ -647,16 +676,12 @@ function reloadAllHousesCommand(command, params, client) { deleteHouseExitPickup(i); deleteHouseEntrancePickup(i); } - + getServerData().houses = null; getServerData().houses = loadHouseFromDatabase(); createAllHousePickups(); createAllHouseBlips(); - for(let i in clients) { - sendAllHouseLabelsToPlayer(clients[i]); - } - messageAdminAction(`All houses have been reloaded by an admin!`); } diff --git a/scripts/server/job.js b/scripts/server/job.js index 21d2af9d..d7255764 100644 --- a/scripts/server/job.js +++ b/scripts/server/job.js @@ -16,8 +16,6 @@ function initJobScript() { createAllJobPickups(); createAllJobBlips(); - //addEvent("onJobPickupCollected", null, 2); - console.log("[Asshat.Job]: Job script initialized successfully!"); return true; } @@ -31,7 +29,7 @@ function loadJobsFromDatabase() { let dbConnection = connectToDatabase(); let dbQuery = null; let dbAssoc; - + if(dbConnection) { dbQuery = queryDatabase(dbConnection, `SELECT * FROM job_main WHERE job_enabled = 1 AND job_server = ${getServerId()}`); if(dbQuery) { @@ -87,7 +85,7 @@ function loadJobEquipmentsFromDatabase(jobDatabaseId) { let dbConnection = connectToDatabase(); let dbQuery = null; let dbAssoc; - + if(dbConnection) { dbQuery = queryDatabase(dbConnection, "SELECT * FROM `job_equip` WHERE `job_equip_enabled` = 1 AND `job_equip_job` = " + toString(jobDatabaseId)); if(dbQuery) { @@ -117,7 +115,7 @@ function loadJobLocationsFromDatabase(jobDatabaseId) { let dbConnection = connectToDatabase(); let dbQuery = null; let dbAssoc; - + if(dbConnection) { dbQuery = queryDatabase(dbConnection, "SELECT * FROM `job_loc` WHERE `job_loc_enabled` = 1 AND `job_loc_job` = " + toString(jobDatabaseId)); if(dbQuery) { @@ -146,7 +144,7 @@ function loadJobUniformsFromDatabase(jobDatabaseId) { let dbConnection = connectToDatabase(); let dbQuery = null; let dbAssoc; - + if(dbConnection) { dbQuery = queryDatabase(dbConnection, "SELECT * FROM `job_uniform` WHERE `job_uniform_enabled` = 1 AND `job_uniform_job` = " + toString(jobDatabaseId)); if(dbQuery) { @@ -175,7 +173,7 @@ function loadJobEquipmentWeaponsFromDatabase(jobEquipmentDatabaseId) { let dbConnection = connectToDatabase(); let dbQuery = null; let dbAssoc; - + if(dbConnection) { dbQuery = queryDatabase(dbConnection, "SELECT * FROM `job_equip_wep` WHERE `job_equip_wep_enabled` = 1 AND `job_equip_wep_equip` = " + toString(jobEquipmentDatabaseId)); if(dbQuery) { @@ -239,7 +237,7 @@ function createAllJobPickups() { // --------------------------------------------------------------------------- function showJobInformationToPlayer(client, jobType) { - if(!canPlayerUseJobs(client)){ + if(!canPlayerUseJobs(client)){ return false; } @@ -250,16 +248,16 @@ function showJobInformationToPlayer(client, jobType) { switch(jobType) { case AG_JOB_POLICE: - if(!canPlayerUsePoliceJob(client)) { + if(!canPlayerUsePoliceJob(client)) { return false; } messagePlayerInfo(client, "== Job Help ================================="); - messagePlayerInfo(client, "- Police Officers are enforcers of the law."); + messagePlayerInfo(client, "- Police Officers are enforcers of the law."); messagePlayerInfo(client, "- Use /startwork at a police station to work as a Police Officer."); messagePlayerInfo(client, "- Use /laws to see a list of laws."); messagePlayerInfo(client, "- Commands are: /cuff, /drag, /detain, /arrest, /search /tazer /radio"); - messagePlayerInfo(client, "- When finished, use /stopwork to stop working."); + messagePlayerInfo(client, "- When finished, use /stopwork to stop working."); break; case AG_JOB_MEDICAL: @@ -272,10 +270,10 @@ function showJobInformationToPlayer(client, jobType) { break; case AG_JOB_FIRE: - if(!canClientUseFireJob(client)){ + if(!canClientUseFireJob(client)){ return false; - } - messagePlayerInfo(client, "== Job Help ================================="); + } + messagePlayerInfo(client, "== Job Help ================================="); messagePlayerInfo(client, "- Firefighters put out vehicle and building fires."); messagePlayerInfo(client, "- Use /startwork at the fire station to work as a Firefighter."); messagePlayerInfo(client, "- Get in a firetruck and you will be told where to go."); @@ -299,7 +297,7 @@ function showJobInformationToPlayer(client, jobType) { messagePlayerInfo(client, "- Use /fare to set a fare. Fares start when a player gets in."); messagePlayerInfo(client, "- The meter will run until the player exits the vehicle."); messagePlayerInfo(client, "- You will automatically receive the fare money"); - messagePlayerInfo(client, "- When finished, use /stopwork to stop working."); + messagePlayerInfo(client, "- When finished, use /stopwork to stop working."); break; case AG_JOB_GARBAGE: @@ -328,7 +326,7 @@ function showJobInformationToPlayer(client, jobType) { function takeJobCommand(command, params, client) { if(!canPlayerUseJobs(client)) { - messagePlayerError(client, "You are not allowed to use any jobs!"); + messagePlayerError(client, "You are not allowed to use any jobs!"); return false; } @@ -342,14 +340,14 @@ function takeJobCommand(command, params, client) { if(getPlayerCurrentSubAccount(client).job > AG_JOB_NONE) { messagePlayerError(client, "You already have a job! Use /quitjob to quit your job."); - return false; + return false; } if(!canPlayerUseJob(client, closestJobLocation.job)) { messagePlayerError(client, "You can't use this job!"); return false; - } - + } + takeJob(client, closestJobLocation.job); messagePlayerSuccess(client, "You now have the " + toString(jobData.name) + " job"); return true; @@ -358,7 +356,7 @@ function takeJobCommand(command, params, client) { // --------------------------------------------------------------------------- function startWorkingCommand(command, params, client) { - if(!canPlayerUseJobs(client)){ + if(!canPlayerUseJobs(client)){ return false; } @@ -367,7 +365,7 @@ function startWorkingCommand(command, params, client) { if(closestJobLocation.position.distance(getPlayerPosition(client)) > getGlobalConfig().startWorkingDistance) { messagePlayerError(client, "There are no job points close enough!"); - return false; + return false; } if(getPlayerCurrentSubAccount(client).job == AG_JOB_NONE) { @@ -381,7 +379,7 @@ function startWorkingCommand(command, params, client) { messagePlayerInfo(client, `If you want this job, use /quitjob to quit your current job.`); return false; } - + messagePlayerSuccess(client, `You are now working as a ${jobData.name}`); startWorking(client); //showStartedWorkingTip(client); @@ -391,7 +389,7 @@ function startWorkingCommand(command, params, client) { // --------------------------------------------------------------------------- function stopWorkingCommand(command, params, client) { - if(!canPlayerUseJobs(client)) { + if(!canPlayerUseJobs(client)) { return false; } @@ -415,7 +413,7 @@ function stopWorkingCommand(command, params, client) { // --------------------------------------------------------------------------- function startWorking(client) { - if(!canPlayerUseJobs(client)){ + if(!canPlayerUseJobs(client)){ return false; } @@ -478,7 +476,7 @@ function getJobLocationInfoCommand(command, params, client) { //if(!getJobData(getJobIdFromDatabaseId(closestJobLocation.job))) { // messagePlayerError(client, "Job not found!"); // return false; - //} + //} messagePlayerInfo(client, `[#FFFF00][Job Location Info] [#FFFFFF]Job: [#AAAAAA]${getJobData(closestJobLocation.job).name} (${getJobData(closestJobLocation.job).id}/${closestJobLocation.job}), [#FFFFFF]Enabled: [#AAAAAA]${getYesNoFromBool(closestJobLocation.enabled)}, [#FFFFFF]Database ID: [#AAAAAA]${closestJobLocation.databaseId}`); } @@ -501,7 +499,7 @@ function givePlayerJobEquipment(client, equipmentId) { // --------------------------------------------------------------------------- function stopWorking(client) { - if(!canPlayerUseJobs(client)){ + if(!canPlayerUseJobs(client)){ return false; } @@ -531,8 +529,8 @@ function stopWorking(client) { getPlayerCurrentSubAccount(client).lastJobVehicle = false; } - - triggerNetworkEvent("ag.clearWeapons", client); + + triggerNetworkEvent("ag.clearWeapons", client); let jobId = getPlayerCurrentSubAccount(client).job; switch(getJobType(jobId)) { @@ -571,7 +569,7 @@ function stopWorking(client) { } updatePlayerNameTag(client); - triggerNetworkEvent("ag.working", client, false); + triggerNetworkEvent("ag.working", client, false); } // --------------------------------------------------------------------------- @@ -583,7 +581,7 @@ function jobUniformCommand(command, params, client) { if(areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerNormal(client, `0: No uniform (sets you back to your main skin)`); - + for(let i in uniforms) { messagePlayerNormal(client, `${toInteger(i)+1}: ${uniforms[i].name} (Requires rank ${uniforms[i].requiredRank})`); } @@ -602,8 +600,8 @@ function jobUniformCommand(command, params, client) { return false; } - messagePlayerSuccess(client, `You put on the ${uniforms[uniformId-1].name} uniform`); - triggerNetworkEvent("ag.pedSkin", null, client.player, uniforms[uniformId-1].skin); + messagePlayerSuccess(client, `You put on the [#AAAAAA]${uniforms[uniformId-1].name} [#FFFFFF]uniform`); + setPlayerSkin(client, uniforms[uniformId-1].skin); } // --------------------------------------------------------------------------- @@ -632,7 +630,7 @@ function jobEquipmentCommand(command, params, client) { messagePlayerError(client, "That equipment ID is invalid!"); return false; } - + givePlayerJobEquipment(client, equipmentId-1); messagePlayerSuccess(client, `You have been given the ${equipments[equipmentId-1].name} equipment`); } @@ -640,7 +638,7 @@ function jobEquipmentCommand(command, params, client) { // --------------------------------------------------------------------------- function quitJobCommand(command, params, client) { - if(!canPlayerUseJobs(client)){ + if(!canPlayerUseJobs(client)){ return false; } @@ -652,7 +650,7 @@ function quitJobCommand(command, params, client) { // --------------------------------------------------------------------------- function jobRadioCommand(command, params, client) { - if(!canPlayerUseJobs(client)){ + if(!canPlayerUseJobs(client)){ return false; } @@ -662,7 +660,7 @@ function jobRadioCommand(command, params, client) { // --------------------------------------------------------------------------- function jobDepartmentRadioCommand(command, params, client) { - if(!canPlayerUseJobs(client)){ + if(!canPlayerUseJobs(client)){ return false; } @@ -717,18 +715,13 @@ function reloadAllJobsCommand(command, params, client) { destroyElement(getServerData().jobs[i].locations[j].pickup); } } - + //forceAllPlayersToStopWorking(); getServerData().jobs = null; getServerData().jobs = loadJobsFromDatabase(); createAllJobPickups(); createAllJobBlips(); - let clients = getClients(); - for(let i in clients) { - sendAllJobLabelsToPlayer(clients[i]); - } - messageAdminAction(`All server jobs have been reloaded by an admin!`); } @@ -741,7 +734,7 @@ function createJobLocationCommand(command, params, client) { } let jobId = getJobFromParams(params); - + if(!getJobData(jobId)) { messagePlayerError(client, "That job was not found!"); return false; @@ -758,9 +751,10 @@ function deleteJobLocationCommand(command, params, client) { let closestJobLocation = getClosestJobLocation(getPlayerPosition(client)); let jobData = getJobData(closestJobLocation.job); - messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]${getEnabledDisabledFromBool(closestJobLocation.enabled)} location [#AAAAAA]${closestJobLocation.databaseId} [#FFFFFF]for the [#AAAAAA]${jobData.name} [#FFFFFF]job`); + messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]deleted location [#AAAAAA]${closestJobLocation.databaseId} [#FFFFFF]for the [#AAAAAA]${jobData.name} [#FFFFFF]job`); deleteJobLocation(closestJobLocation); + getJobData(closestJobLocation.job).locations.splice(getClosestJobLocation.index, 1); } // --------------------------------------------------------------------------- @@ -954,7 +948,7 @@ function forceAllPlayersToStopWorking() { // --------------------------------------------------------------------------- function jobStartRouteCommand(command, params, client) { - if(!canPlayerUseJobs(client)) { + if(!canPlayerUseJobs(client)) { messagePlayerError(client, "You are not allowed to use jobs."); return false; } @@ -971,9 +965,9 @@ function jobStartRouteCommand(command, params, client) { if(!isPlayerInJobVehicle(client)) { messagePlayerError(client, "You need to be in a vehicle that belongs to your job!"); - return false; + return false; } - + startJobRoute(client); return true; @@ -982,7 +976,7 @@ function jobStartRouteCommand(command, params, client) { // --------------------------------------------------------------------------- function jobStopRouteCommand(command, params, client) { - if(!canPlayerUseJobs(client)) { + if(!canPlayerUseJobs(client)) { messagePlayerError(client, "You are not allowed to use jobs."); return false; } @@ -999,7 +993,7 @@ function jobStopRouteCommand(command, params, client) { if(!isPlayerOnJobRoute(client)) { messagePlayerError(client, "You aren't on a job route!"); - return false; + return false; } stopJobRoute(client); @@ -1045,7 +1039,7 @@ function startJobRoute(client) { let garbageRoute = getRandomBusRoute(getPlayerIsland(client)); getPlayerData(client).jobRoute = garbageRoute; getPlayerData(client).jobRouteStop = 0; - getPlayerData(client).jobRouteIsland = getPlayerIsland(client); + getPlayerData(client).jobRouteIsland = getPlayerIsland(client); getPlayerData(client).jobRouteVehicle = getPlayerVehicle(client); getPlayerVehicle(client).colour1 = getGarbageRouteData(getPlayerIsland(client), garbageRoute).garbageTruckColour; getPlayerVehicle(client).colour2 = 1; @@ -1103,7 +1097,7 @@ function getPlayerJobRouteVehicle(client) { return getPlayerData(client).busRouteVehicle; } else if(doesPlayerHaveJobType(client, AG_JOB_GARBAGE)) { return getPlayerData(client).garbageRouteVehicle; - } + } } // --------------------------------------------------------------------------- @@ -1132,7 +1126,7 @@ function stopReturnToJobVehicleCountdown(client) { clearInterval(getPlayerData(client).returnToJobVehicleTimer); getPlayerData(client).returnToJobVehicleTimer = null; } - + //getPlayerData(client).returnToJobVehicleTick = 0; } @@ -1183,14 +1177,14 @@ function canPlayerUseJob(client, jobId) { if(!isPlayerOnJobWhiteList(client, jobId)) { return false } - } + } } // --------------------------------------------------------------------------- function deleteJobLocation(jobLocationData) { + removeFromWorld(jobLocationData.pickup); destroyElement(jobLocationData.pickup); - triggerNetworkEvent("ag.joblabel.del", jobLocationData.databaseId); } // --------------------------------------------------------------------------- @@ -1222,7 +1216,21 @@ function getJobIdFromDatabaseId(databaseId) { function setAllJobDataIndexes() { for(let i in getServerData().jobs) { - getServerData().jobs[i].id = i; + getServerData().jobs[i].index = i; + for(let j in getServerData().jobs[i].locations) { + getServerData().jobs[i].locations[j].index = j; + } + + for(let k in getServerData().jobs[i].uniforms) { + getServerData().jobs[i].uniforms[k].index = k; + } + + for(let m in getServerData().jobs[i].equipment) { + getServerData().jobs[i].equipment[m].index = m; + for(let n in getServerData().jobs[i].equipment[m].weapons) { + getServerData().jobs[i].equipment[m].weapons[n].index = n; + } + } } } @@ -1397,7 +1405,7 @@ function saveAllJobsToDatabase() { for(let k in getServerData().jobs[i].uniforms) { saveJobUniformToDatabase(getServerData().jobs[i].uniforms[k]); } - + for(let m in getServerData().jobs[i].equipment) { saveJobEquipmentToDatabase(getServerData().jobs[i].equipment[m]); diff --git a/scripts/server/job/bus.js b/scripts/server/job/bus.js index 096bbe53..9cff5e2c 100644 --- a/scripts/server/job/bus.js +++ b/scripts/server/job/bus.js @@ -14,13 +14,14 @@ let busRoutes = [ false, - + [ // GTA 3 (1) [ // PORTLAND ISLAND (0) { // RED ROUTE (0) - name: "Portland Red Line", - island: 0, + name: "Portland Red Line", + island: 0, busColour: 3, + payout: 175, positions: [ toVector3(1269, -1056.4, 14.75), toVector3(1088.7, -968.8, 14.91), @@ -45,135 +46,14 @@ let busRoutes = [ toVector3(1307.5, -995.54, 14.88), ], }, - { // BLUE ROUTE (1) - name: "Portland Blue Line", - island: 0, - busColour: 2, - positions: [ - toVector3(1269, -1056.4, 14.75), - toVector3(1088.7, -968.8, 14.91), - toVector3(1059.1, -870.9, 14.91), - toVector3(917.6, -815.9, 14.91), - toVector3(851.1, -766.1, 14.91), - toVector3(838.8, -598.7, 14.91), - toVector3(959.3, -581.6, 14.91), - toVector3(853.1, -485.9, 14.91), - toVector3(838.8, -312.68, 6.8), - toVector3(913.9, -177.4, 4.91), - toVector3(1123.3, -67.74, 7.41), - toVector3(1043.6, -191.63, 4.91), - toVector3(1213.2, -281.3, 25.76), - toVector3(1193.3, -474.3, 24.98), - toVector3(1335.4, -499.7, 45.28), - toVector3(1220.3, -341.4, 26.38), - toVector3(1122.6, -475.6, 19.91), - toVector3(1309.2, -642.4, 12.3), - toVector3(1350.5, -845, 14.91), - toVector3(1322.2, -1025.3, 14.76), - toVector3(1307.5, -995.54, 14.88), - ], - }, - { // YELLOW ROUTE (2) - name: "Portland Yellow Line", - island: 0, - busColour: 6, - positions: [ - toVector3(1269, -1056.4, 14.75), - toVector3(1088.7, -968.8, 14.91), - toVector3(1059.1, -870.9, 14.91), - toVector3(917.6, -815.9, 14.91), - toVector3(851.1, -766.1, 14.91), - toVector3(838.8, -598.7, 14.91), - toVector3(959.3, -581.6, 14.91), - toVector3(853.1, -485.9, 14.91), - toVector3(838.8, -312.68, 6.8), - toVector3(913.9, -177.4, 4.91), - toVector3(1123.3, -67.74, 7.41), - toVector3(1043.6, -191.63, 4.91), - toVector3(1213.2, -281.3, 25.76), - toVector3(1193.3, -474.3, 24.98), - toVector3(1335.4, -499.7, 45.28), - toVector3(1220.3, -341.4, 26.38), - toVector3(1122.6, -475.6, 19.91), - toVector3(1309.2, -642.4, 12.3), - toVector3(1350.5, -845, 14.91), - toVector3(1322.2, -1025.3, 14.76), - toVector3(1307.5, -995.54, 14.88), - ], - }, ], [ // STAUNTON ISLAND (1) { // RED ROUTE (0) - name: "Staunton Red Line", + name: "Staunton Red Line", island: 1, busColour: 3, - positions: [ - toVector3(-1.11, -388.4, 16.11), - toVector3(-15.75, -735.3, 26.15), - toVector3(33.63, -1029.4, 26.11), - toVector3(-53.92, -1233.4, 26.11), - toVector3(126.58, -1323.7, 26.11), - toVector3(189.39, -1285.6, 26.11), - toVector3(266.9, -1179.1, 26.11), - toVector3(283.93, -1370.2, 26.11), - toVector3(144.44, -1455.5, 26.11), - toVector3(34.5, -1511.7, 26.11), - toVector3(325.31, -1579, 26.03), - toVector3(302.33, -1417.7, 26.11), - toVector3(309.76, -1290, 26.11), - toVector3(378.5, -1235.1, 26.11), - toVector3(404, -1376.3, 26.11), - toVector3(189.07, -1159.3, 26.11), - toVector3(189.44, -956.9, 26.11), - toVector3(254.18, -722.3, 26.11), - toVector3(383.4, -704.2, 26.11), - toVector3(429.3, -420.6, 22.04), - toVector3(570.9, -336.4, 19.71), - toVector3(267.46, 91.12, 15.96), - toVector3(99.13, -31.96, 16.11), - toVector3(243.94, -187.01, 21.31), - toVector3(99.17, -263.44, 16.11), - toVector3(-26.92, -283.73, 16.11), - ], - }, - { // BLUE ROUTE (1) - name: "Staunton Blue Line", - island: 1, - busColour: 2, - positions: [ - toVector3(-1.11, -388.4, 16.11), - toVector3(-15.75, -735.3, 26.15), - toVector3(33.63, -1029.4, 26.11), - toVector3(-53.92, -1233.4, 26.11), - toVector3(126.58, -1323.7, 26.11), - toVector3(189.39, -1285.6, 26.11), - toVector3(266.9, -1179.1, 26.11), - toVector3(283.93, -1370.2, 26.11), - toVector3(144.44, -1455.5, 26.11), - toVector3(34.5, -1511.7, 26.11), - toVector3(325.31, -1579, 26.03), - toVector3(302.33, -1417.7, 26.11), - toVector3(309.76, -1290, 26.11), - toVector3(378.5, -1235.1, 26.11), - toVector3(404, -1376.3, 26.11), - toVector3(189.07, -1159.3, 26.11), - toVector3(189.44, -956.9, 26.11), - toVector3(254.18, -722.3, 26.11), - toVector3(383.4, -704.2, 26.11), - toVector3(429.3, -420.6, 22.04), - toVector3(570.9, -336.4, 19.71), - toVector3(267.46, 91.12, 15.96), - toVector3(99.13, -31.96, 16.11), - toVector3(243.94, -187.01, 21.31), - toVector3(99.17, -263.44, 16.11), - toVector3(-26.92, -283.73, 16.11), - ], - }, - { // YELLOW ROUTE (2) - name: "Staunton Yellow Line", - island: 1, - busColour: 6, + payout: 175, positions: [ toVector3(-1.11, -388.4, 16.11), toVector3(-15.75, -735.3, 26.15), @@ -206,13 +86,14 @@ let busRoutes = [ ], ], - + [ // GTA VC [ // WESTERN ISLAND (0) { // RED ROUTE (0) - name: "Vice City Red Line", + name: "Vice City Red Line", island: 0, busColour: 3, + payout: 100, positions: [ toVector3(-997.698, 175.8, 10.704), toVector3(-607.007, 659.024, 10.9994), @@ -228,9 +109,10 @@ let busRoutes = [ ], }, { // GREEN ROUTE (1) - name: "Vice City Green Line", + name: "Vice City Green Line", island: 0, busColour: 46, + payout: 250, positions: [ toVector3(-1106.57, -300.12, 11.189), toVector3(-1012.97, -372.445, 10.8688), @@ -259,46 +141,13 @@ let busRoutes = [ toVector3(-748.054, 198.243, 11.2455), toVector3(-850, -110.625, 11.0203), toVector3(-898.862, -280.373, 10.6645), - toVector3(-1082.1, -294.416, 11.2065), - ], - }, - { // YELLOW ROUTE (2) - name: "Staunton Yellow Line", - island: 1, - busColour: 6, - positions: [ - toVector3(-1.11, -388.4, 16.11), - toVector3(-15.75, -735.3, 26.15), - toVector3(33.63, -1029.4, 26.11), - toVector3(-53.92, -1233.4, 26.11), - toVector3(126.58, -1323.7, 26.11), - toVector3(189.39, -1285.6, 26.11), - toVector3(266.9, -1179.1, 26.11), - toVector3(283.93, -1370.2, 26.11), - toVector3(144.44, -1455.5, 26.11), - toVector3(34.5, -1511.7, 26.11), - toVector3(325.31, -1579, 26.03), - toVector3(302.33, -1417.7, 26.11), - toVector3(309.76, -1290, 26.11), - toVector3(378.5, -1235.1, 26.11), - toVector3(404, -1376.3, 26.11), - toVector3(189.07, -1159.3, 26.11), - toVector3(189.44, -956.9, 26.11), - toVector3(254.18, -722.3, 26.11), - toVector3(383.4, -704.2, 26.11), - toVector3(429.3, -420.6, 22.04), - toVector3(570.9, -336.4, 19.71), - toVector3(267.46, 91.12, 15.96), - toVector3(99.13, -31.96, 16.11), - toVector3(243.94, -187.01, 21.31), - toVector3(99.17, -263.44, 16.11), - toVector3(-26.92, -283.73, 16.11), + toVector3(-1082.1, -294.416, 11.2065), ], }, ], ], - + [ // GTA SA [ // LOS SANTOS ISLAND (0) { // RED ROUTE (0) @@ -310,14 +159,15 @@ let busRoutes = [ * Unity Station (Yellow, Blue, Green) * Ganton (Green) * Airport Gate (Yellow) - + Notable Stops: * Docks * Airport Gate */ - name: "Los Santos Yellow Line", + name: "Los Santos Yellow Line", island: 0, busColour: 6, + payout: 200, positions: [ toVector3(1823.79, -1852.66, 13.5144), toVector3(1804.12, -1609.59, 13.4419), @@ -340,7 +190,7 @@ let busRoutes = [ toVector3(1963.51, -1969.6, 13.5867), toVector3(1824.2, -1886.48, 13.4287), ] - }, + }, { // BLUE ROUTE (1) /* Serves: @@ -352,7 +202,7 @@ let busRoutes = [ * Glen Park (Yellow, Green) * Alhambra Club (Yellow, Green) * All Saints General Hospital (Yellow) - + Notable Stops: * Madd Doggs Mansion * All Saints General Hospital @@ -360,11 +210,12 @@ let busRoutes = [ * Vinewood Blvd * Vinewood Hills * Santa Maria Beach/Pier - */ - name: "Los Santos Blue Line", + */ + name: "Los Santos Blue Line", island: 0, busColour: 2, - positions: [ + payout: 250, + positions: [ toVector3(1824.17, -1851.5, 13.5134), toVector3(1853.95, -1395.48, 13.4882), toVector3(1659.33, -1158.59, 23.8368), @@ -405,17 +256,18 @@ let busRoutes = [ * Glen Park (Blue, Yellow) * Ganton (Red) * Alhambra Club (Yellow, Blue) - + Notable Stops: * County General Hospital * Glen Park * Skate Park * Stadium */ - name: "Los Santos Green Line", + name: "Los Santos Green Line", island: 0, busColour: 86, - positions: [ + payout: 175, + positions: [ toVector3(1823.94, -1853.88, 13.5103), toVector3(1823.97, -1655.31, 13.4738), toVector3(1854.81, -1409.54, 13.4829), @@ -460,16 +312,17 @@ let busRoutes = [ * All Saints General Hospital (Blue) * Alhambra Club (Yellow, Blue) * Airport Gate (Red) - + Notable Stops: * All Saints General Hospital * Bank * Star Tower * Airport Gate */ - name: "Los Santos Red Line", + name: "Los Santos Red Line", island: 0, busColour: 3, + payout: 150, positions: [ toVector3(1823.79, -1852.66, 13.5144), toVector3(1804.12, -1609.59, 13.4419), @@ -492,7 +345,7 @@ let busRoutes = [ toVector3(1963.51, -1969.6, 13.5867), toVector3(1824.2, -1886.48, 13.4287), ] - } + } ], ], @@ -504,7 +357,7 @@ let busRoutes = [ // GTA IV [ - ], + ], ]; // --------------------------------------------------------------------------- @@ -523,7 +376,7 @@ function getNextStopOnBusRoute(island, busRoute, busRouteStop) { return busRouteStop+1; } else { return busRoutes[getServerGame()][island][busRoute].positions.length-1; - } + } } // --------------------------------------------------------------------------- diff --git a/scripts/server/job/garbage.js b/scripts/server/job/garbage.js index 4a68879c..69fd8502 100644 --- a/scripts/server/job/garbage.js +++ b/scripts/server/job/garbage.js @@ -13,8 +13,8 @@ let garbageRoutes = [ [ // GTA 3 [ // PORTLAND ISLAND (0) { // ROUTE 0 - name: "Portland #1", - island: 0, + name: "Portland #1", + island: 0, positions: [ toVector3(1169.8, -45.54, 10.4), toVector3(928, -59.1, 8.61), @@ -31,21 +31,21 @@ let garbageRoutes = [ toVector3(1128.9, -446.1, 20.41), toVector3(1226.5, -52.41, 10.42) , ], - }, + }, ], [ // STAUNTON ISLAND (1) { // ROUTE 0 - name: "Staunton #1", - island: 1, + name: "Staunton #1", + island: 1, positions: [ - toVector3(49.85, -1539.9, 26.6), - toVector3(49.71, -1458.1, 26.6), - toVector3(170.78, -1403.8, 26.59), - toVector3(183.48, -1485.9, 26.6), - toVector3(320.43, -1452.4, 26.6), - toVector3(310.13, -1311.8, 26.6), - toVector3(134.76, -1097.7, 26.6), - toVector3(55.63, -1058.6, 26.6), + toVector3(49.85, -1539.9, 26.6), + toVector3(49.71, -1458.1, 26.6), + toVector3(170.78, -1403.8, 26.59), + toVector3(183.48, -1485.9, 26.6), + toVector3(320.43, -1452.4, 26.6), + toVector3(310.13, -1311.8, 26.6), + toVector3(134.76, -1097.7, 26.6), + toVector3(55.63, -1058.6, 26.6), toVector3(-0.02, -790.9, 26.64), ], }, @@ -67,7 +67,7 @@ let garbageRoutes = [ // GTA IV [ - ], + ], ]; // --------------------------------------------------------------------------- @@ -86,7 +86,7 @@ function getNextStopOnGarbageRoute(island, garbageRoute, garbageRouteStop) { return garbageRouteStop+1; } else { return garbageRoutes[getServerGame()][island][garbageRoute].positions.length-1; - } + } } // --------------------------------------------------------------------------- diff --git a/scripts/server/job/police.js b/scripts/server/job/police.js index d8617ae2..43b36d00 100644 --- a/scripts/server/job/police.js +++ b/scripts/server/job/police.js @@ -9,12 +9,12 @@ // =========================================================================== function policeTazerCommand(command, params, client) { - if(!canPlayerUseJobs(client)) { + if(!canPlayerUseJobs(client)) { messagePlayerError(client, "You are not allowed to use jobs."); return false; } - if(!canPlayerUsePoliceJob(client)) { + if(!canPlayerUsePoliceJob(client)) { messagePlayerError(client, "You are not allowed to use the police job."); return false; } @@ -35,12 +35,12 @@ function policeTazerCommand(command, params, client) { // --------------------------------------------------------------------------- function policeCuffCommand(command, params, client) { - if(!canPlayerUseJobs(client)) { + if(!canPlayerUseJobs(client)) { messagePlayerError(client, "You are not allowed to use jobs."); return false; } - if(!canPlayerUsePoliceJob(client)) { + if(!canPlayerUsePoliceJob(client)) { messagePlayerError(client, "You are not allowed to use the police job."); return false; } @@ -53,7 +53,7 @@ function policeCuffCommand(command, params, client) { if(!doesPlayerHaveJobType(client, AG_JOB_POLICE)) { messagePlayerError(client, "You don't have a police job."); return false; - } + } return true; } @@ -61,12 +61,12 @@ function policeCuffCommand(command, params, client) { // --------------------------------------------------------------------------- function policeArrestCommand(command, params, client) { - if(!canPlayerUseJobs(client)) { + if(!canPlayerUseJobs(client)) { messagePlayerError(client, "You are not allowed to use jobs."); return false; } - if(!canPlayerUsePoliceJob(client)) { + if(!canPlayerUsePoliceJob(client)) { messagePlayerError(client, "You are not allowed to use the police job."); return false; } @@ -79,7 +79,7 @@ function policeArrestCommand(command, params, client) { if(!doesPlayerHaveJobType(client, AG_JOB_POLICE)) { messagePlayerError(client, "You don't have a police job."); return false; - } + } return true; } @@ -87,12 +87,12 @@ function policeArrestCommand(command, params, client) { // --------------------------------------------------------------------------- function policeSearchCommand(command, params, client) { - if(!canPlayerUseJobs(client)) { + if(!canPlayerUseJobs(client)) { messagePlayerError(client, "You are not allowed to use jobs."); return false; } - if(!canPlayerUsePoliceJob(client)) { + if(!canPlayerUsePoliceJob(client)) { messagePlayerError(client, "You are not allowed to use the police job."); return false; } @@ -105,7 +105,7 @@ function policeSearchCommand(command, params, client) { if(!doesPlayerHaveJobType(client, AG_JOB_POLICE)) { messagePlayerError(client, "You don't have a police job."); return false; - } + } return true; } @@ -113,12 +113,12 @@ function policeSearchCommand(command, params, client) { // --------------------------------------------------------------------------- function policeDragCommand(command, params, client) { - if(!canPlayerUseJobs(client)) { + if(!canPlayerUseJobs(client)) { messagePlayerError(client, "You are not allowed to use jobs."); return false; } - if(!canPlayerUsePoliceJob(client)) { + if(!canPlayerUsePoliceJob(client)) { messagePlayerError(client, "You are not allowed to use the police job."); return false; } @@ -131,7 +131,7 @@ function policeDragCommand(command, params, client) { if(!doesPlayerHaveJobType(client, AG_JOB_POLICE)) { messagePlayerError(client, "You don't have a police job."); return false; - } + } return true; } @@ -139,12 +139,12 @@ function policeDragCommand(command, params, client) { // --------------------------------------------------------------------------- function policeDetainCommand(command, params, client) { - if(!canPlayerUseJobs(client)) { + if(!canPlayerUseJobs(client)) { messagePlayerError(client, "You are not allowed to use jobs."); return false; } - if(!canPlayerUsePoliceJob(client)) { + if(!canPlayerUsePoliceJob(client)) { messagePlayerError(client, "You are not allowed to use the police job."); return false; } @@ -157,7 +157,7 @@ function policeDetainCommand(command, params, client) { if(!doesPlayerHaveJobType(client, AG_JOB_POLICE)) { messagePlayerError(client, "You don't have a police job."); return false; - } + } return true; } diff --git a/scripts/server/job/taxi.js b/scripts/server/job/taxi.js index 2ccd2f24..9225de24 100644 --- a/scripts/server/job/taxi.js +++ b/scripts/server/job/taxi.js @@ -9,12 +9,12 @@ // =========================================================================== function taxiSetFareCommand(command, params, client) { - if(!canPlayerUseJobs(client)) { + if(!canPlayerUseJobs(client)) { messagePlayerError(client, "You are not allowed to use jobs."); return false; } - if(!canPlayerUseTaxiJob(client)) { + if(!canPlayerUseTaxiJob(client)) { messagePlayerError(client, "You are not allowed to use the taxi job."); return false; } diff --git a/scripts/server/keybind.js b/scripts/server/keybind.js index 52948bf0..8e16c985 100644 --- a/scripts/server/keybind.js +++ b/scripts/server/keybind.js @@ -263,7 +263,7 @@ function playerUsedKeyBind(client, key) { if(!isPlayerSpawned(client)) { return false; - } + } console.log(`[Asshat.KeyBind] ${getPlayerDisplayForConsole(client)} used keybind ${sdl.getKeyName(key)} (${key})`); if(doesPlayerHaveKeyBindForKey(client, key)) { diff --git a/scripts/server/messaging.js b/scripts/server/messaging.js index 522a51b4..40580225 100644 --- a/scripts/server/messaging.js +++ b/scripts/server/messaging.js @@ -115,7 +115,7 @@ function messagePlayerInfo(client, messageText) { console.log(`[INFO] ${messageText}`); return true; } - + if(!isClientFromDiscord(client)) { messagePlayerNormal(client, `ℹ️ [#FFFFFF] ${messageText}`, getColourByName("white")); } else { @@ -130,7 +130,7 @@ function messagePlayerTip(client, messageText) { console.log(`[TIP] ${messageText}`); return true; } - + if(!isClientFromDiscord(client)) { messagePlayerNormal(client, `ℹ️ [#FFFFFF] ${messageText}`, getColourByName("white")); } else { diff --git a/scripts/server/misc.js b/scripts/server/misc.js index 2a141863..4f584f73 100644 --- a/scripts/server/misc.js +++ b/scripts/server/misc.js @@ -149,7 +149,7 @@ function enterExitPropertyCommand(command, params, client) { if(inBusiness.locked) { meActionToNearbyPlayers(client, "tries to open the business door but fails because it's locked"); return false; - } + } meActionToNearbyPlayers(client, "opens the door and exits the business"); fadeCamera(client, false, 1.0); setTimeout(function() { @@ -163,7 +163,7 @@ function enterExitPropertyCommand(command, params, client) { }, 1100); removeEntityData(client, "ag.inBusiness"); } - return true; + return true; } if(getServerData().businesses.length > 0) { @@ -180,7 +180,7 @@ function enterExitPropertyCommand(command, params, client) { meActionToNearbyPlayers(client, "tries to open the business door but fails because it's locked"); return false; } - + meActionToNearbyPlayers(client, "opens the door and enters the business"); fadeCamera(client, false, 1.0); @@ -215,7 +215,7 @@ function enterExitPropertyCommand(command, params, client) { } meActionToNearbyPlayers(client, "opens the door and enters the house"); - + fadeCamera(client, false, 1.0); setTimeout(function() { @@ -234,7 +234,7 @@ function enterExitPropertyCommand(command, params, client) { } //messagePlayerError(client, "You aren't close enough to a door!"); - + return true; } diff --git a/scripts/server/moderation.js b/scripts/server/moderation.js index ab811924..735dd1b2 100644 --- a/scripts/server/moderation.js +++ b/scripts/server/moderation.js @@ -13,12 +13,12 @@ function initModerationScript() { // --------------------------------------------------------------------------- -function kickClientCommand(command, params, client) { +function kickClientCommand(command, params, client) { if(areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - + let targetClient = getPlayerFromParams(params); if(!targetClient) { messagePlayerError(client, "That player is not connected!"); @@ -32,19 +32,19 @@ function kickClientCommand(command, params, client) { return false; } } - + messageAdminAction(`${targetClient.name} has been kicked from the server.`); targetClient.disconnect(); } // --------------------------------------------------------------------------- -function setClientStaffTitleCommand(command, params, client) { +function setClientStaffTitleCommand(command, params, client) { if(areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - + let splitParams = params.split(" "); let targetClient = getPlayerFromParams(splitParams[0]); let staffTitle = splitParams.slice(1).join(" "); @@ -61,7 +61,7 @@ function setClientStaffTitleCommand(command, params, client) { return false; } } - + getPlayerData(targetClient).accountData.staffTitle = staffTitle; messagePlayerSuccess(client, `You set ${targetClient.name}'s staff title to ${staffTitle}`); messagePlayerAlert(client, `${client.name} set your staff title to ${staffTitle}`); @@ -70,12 +70,12 @@ function setClientStaffTitleCommand(command, params, client) { // --------------------------------------------------------------------------- -function muteClientCommand(command, params, client) { +function muteClientCommand(command, params, client) { if(areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - + let targetClient = getPlayerFromParams(params); if(!targetClient) { messagePlayerError(client, "That player is not connected!"); @@ -89,7 +89,7 @@ function muteClientCommand(command, params, client) { return false; } } - + messageAdminAction(`${targetClient.name} has been muted by an admin!`); setEntityData(targetClient, "ag.muted", true, false); } @@ -97,12 +97,12 @@ function muteClientCommand(command, params, client) { // --------------------------------------------------------------------------- function unMuteClientCommand(command, params, client) { - + if(areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - + let targetClient = getPlayerFromParams(params); if(!targetClient) { messagePlayerError(client, "That player is not connected!"); @@ -115,20 +115,20 @@ function unMuteClientCommand(command, params, client) { messagePlayerError(client, "You cannot unmute this person!"); return false; } - } - + } + messageAdminAction(`${targetClient.name} has been unmuted by an admin!`); removeEntityData(targetClient, "ag.muted"); } // --------------------------------------------------------------------------- -function freezeClientCommand(command, params, client) { +function freezeClientCommand(command, params, client) { if(areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - + let targetClient = getPlayerFromParams(params); if(!targetClient) { messagePlayerError(client, "That player is not connected!"); @@ -142,7 +142,7 @@ function freezeClientCommand(command, params, client) { return false; } } - + messageAdminAction(`${toString(targetClient.name)} has been frozen by an admin!`); triggerNetworkEvent("ag.frozen", client, true); } @@ -154,7 +154,7 @@ function unFreezeClientCommand(command, params, client) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - + let targetClient = getPlayerFromParams(params); if(!targetClient) { messagePlayerError(client, "That player is not connected!"); @@ -168,7 +168,7 @@ function unFreezeClientCommand(command, params, client) { return false; } } - + messageAdminAction(`${toString(targetClient.name)} has been un-frozen by an admin!`); triggerNetworkEvent("ag.frozen", client, false); } @@ -180,18 +180,18 @@ function gotoPlayerCommand(command, params, client) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - + let targetClient = getPlayerFromParams(params); if(!targetClient) { messagePlayerError(client, "That player is not connected!"); return false; } - + //message(`[#996600][ADMIN]: [#FFFFFF]${toString(targetClient.name)} has been un-frozen by an admin!`); client.player.velocity = toVector3(0.0, 0.0, 0.0); setPlayerPosition(client, getPosBehindPos(getPlayerPosition(targetClient), getPlayerHeading(targetClient), 2)); setPlayerHeading(client, getPlayerHeading(targetClient)); - + if(isPlayerInAnyBusiness(targetClient)) { let businessData = getBusinessData(getPlayerBusiness(targetClient)); triggerNetworkEvent("ag.interior", client, businessData.exitInterior); @@ -221,14 +221,14 @@ function gotoVehicleCommand(command, params, client) { } let vehicle = getServerData().vehicles[toInteger(params)].vehicle; - + client.player.velocity = toVector3(0.0, 0.0, 0.0); setTimeout(function() { setPlayerPosition(client, getPosAbovePos(getVehiclePosition(vehicle), 3.0)); setPlayerInterior(client, 0); setPlayerVirtualWorld(client, vehicle.dimension); }, 500); - + messagePlayerSuccess(client, `You teleported to a [#CC22CC]${getVehicleName(vehicle)} [#AAAAAA](ID ${vehicle.id})`); } @@ -246,14 +246,14 @@ function gotoBusinessCommand(command, params, client) { messagePlayerError(client, "That business doesn't exist!"); return false; } - + client.player.velocity = toVector3(0.0, 0.0, 0.0); setTimeout(function() { setPlayerPosition(client, getBusinessData(businessId).entrancePosition); setPlayerInterior(client, getBusinessData(businessId).entranceInterior); setPlayerVirtualWorld(client, getBusinessData(businessId).entranceDimension); }, 500); - + messagePlayerSuccess(client, `You teleported to business [#0099FF]${getBusinessData(businessId).name} [#AAAAAA](ID ${businessId})`); } @@ -271,14 +271,14 @@ function gotoHouseCommand(command, params, client) { messagePlayerError(client, "That house doesn't exist!"); return false; } - + client.player.velocity = toVector3(0.0, 0.0, 0.0); setTimeout(function() { setPlayerPosition(client, getHouseData(houseId).entrancePosition); setPlayerInterior(client, getHouseData(houseId).entranceInterior); setPlayerVirtualWorld(client, getHouseData(houseId).entranceDimension); }, 500); - + messagePlayerSuccess(client, `You teleported to business [#0099FF]${getHouseData(houseId).description} [#AAAAAA](ID ${houseId})`); } @@ -304,13 +304,13 @@ function gotoJobLocationCommand(command, params, client) { if(typeof getJobData(jobId).locations[jobLocationId] == "undefined") { messagePlayerError(client, `That location ID does not exist!`); return false; - } + } client.player.velocity = toVector3(0.0, 0.0, 0.0); setPlayerPosition(client, getJobData(jobId).locations[jobLocationId].position); setPlayerInterior(client, getJobData(jobId).locations[jobLocationId].interior); setPlayerVirtualWorld(client, getJobData(jobId).locations[jobLocationId].dimension); - + messagePlayerSuccess(client, `You teleported to location [#AAAAAA]${jobLocationId} [#FFFFFF]for the [#AAAAAA]${getJobData(jobId).name} [#FFFFFF]job`); } @@ -337,7 +337,7 @@ function gotoPositionCommand(command, params, client) { setPlayerPosition(client, newPosition); setPlayerInterior(client, Number(int)); setPlayerVirtualWorld(client, Number(vw)); - + messagePlayerSuccess(client, `You teleported to coordinates [#AAAAAA]${x}, ${y}, ${z} with interior ${int} and dimension ${vw}`); } @@ -348,9 +348,9 @@ function teleportForwardCommand(command, params, client) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - + setPlayerPosition(client, getPosInFrontOfPos(getPlayerPosition(client), getPlayerHeading(client), params)); - + messagePlayerSuccess(client, `You teleported forward ${params} meters`); } @@ -361,9 +361,9 @@ function teleportBackwardCommand(command, params, client) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - + setPlayerPosition(client, getPosBehindPos(getPlayerPosition(client), getPlayerHeading(client), params)); - + messagePlayerSuccess(client, `You teleported backward [#AAAAAA]${params} [#FFFFFF]meters`); } @@ -374,9 +374,9 @@ function teleportLeftCommand(command, params, client) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - + setPlayerPosition(client, getPosToLeftOfPos(getPlayerPosition(client), getPlayerHeading(client), params)); - + messagePlayerSuccess(client, `You teleported left [#AAAAAA]${params} [#FFFFFF]meters`); } @@ -387,9 +387,9 @@ function teleportUpCommand(command, params, client) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - + setPlayerPosition(client, getPosAbovePos(getPlayerPosition(client), params)); - + messagePlayerSuccess(client, `You teleported up [#AAAAAA]${params} [#FFFFFF]meters`); } @@ -400,9 +400,9 @@ function teleportDownCommand(command, params, client) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - + triggerNetworkEvent("ag.position", client, getPosBelowPos(getPlayerPosition(client), params)); - + messagePlayerSuccess(client, `You teleported down [#AAAAAA]${params} [#FFFFFF]meters`); } @@ -413,9 +413,9 @@ function teleportRightCommand(command, params, client) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - + setPlayerPosition(client, getPosToRightOfPos(getPlayerPosition(client), getPlayerHeading(client), params)); - + messagePlayerSuccess(client, `You teleported right [#AAAAAA]${params} [#FFFFFF]meters`); } @@ -476,7 +476,7 @@ function getPlayerCommand(command, params, client) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - + let targetClient = getPlayerFromParams(params); if(!targetClient) { messagePlayerError(client, "That player is not connected!"); @@ -486,7 +486,7 @@ function getPlayerCommand(command, params, client) { removePlayerFromVehicle(targetClient); setPlayerPosition(targetClient, getPosBehindPos(getPlayerPosition(client), getPlayerHeading(client), 2)); setPlayerHeading(targetClient, getPlayerHeading(client)); - + if(isPlayerInAnyBusiness(client)) { let businessData = getBusinessData(getPlayerBusiness(client)); setPlayerInterior(targetClient, businessData.exitInterior); @@ -510,7 +510,7 @@ function addStaffFlagCommand(command, params, client) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - + let splitParams = params.split(""); let targetClient = getPlayerFromParams(splitParams[0]); let flagName = splitParams[1] || "none"; @@ -544,7 +544,7 @@ function takeStaffFlagCommand(command, params, client) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - + let splitParams = params.split(""); let targetClient = getPlayerFromParams(splitParams[0]); let flagName = splitParams[1] || "none"; @@ -564,7 +564,7 @@ function takeStaffFlagCommand(command, params, client) { if(!getStaffFlagValue(flagName)) { messagePlayerError(client, "That staff flag doesn't exist!"); - return false; + return false; } takePlayerStaffFlag(targetClient, flagName); @@ -578,7 +578,7 @@ function clearStaffFlagsCommand(command, params, client) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - + let splitParams = params.split(""); let targetClient = getPlayerFromParams(splitParams[0]); let flagName = splitParams[1] || "none"; @@ -598,7 +598,7 @@ function clearStaffFlagsCommand(command, params, client) { if(!getStaffFlagValue(flagName)) { messagePlayerError(client, "That staff flag doesn't exist!"); - return false; + return false; } clearPlayerStaffFlags(targetClient); @@ -619,12 +619,12 @@ function getStaffFlagsCommand(command, params, client) { messagePlayerError(client, "You do not have permission to use this command!"); return false; } - + if(areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - + let splitParams = params.split(""); let targetClient = getPlayerFromParams(splitParams[0]); let flagName = splitParams[1] || "none"; @@ -633,7 +633,7 @@ function getStaffFlagsCommand(command, params, client) { messagePlayerError(client, "That player is not connected!"); return false; } - + let tempStaffFlags = []; let serverBitFlagKeys = getServerBitFlagKeys(); for(let i in serverBitFlagKeys) { @@ -648,12 +648,12 @@ function getStaffFlagsCommand(command, params, client) { // --------------------------------------------------------------------------- -function allStaffFlagsCommand(command, params, client) { +function allStaffFlagsCommand(command, params, client) { if(areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - + let splitParams = params.split(""); let targetClient = getPlayerFromParams(splitParams[0]); let flagName = splitParams[1] || "none"; @@ -668,12 +668,12 @@ function allStaffFlagsCommand(command, params, client) { // --------------------------------------------------------------------------- -function givePlayerMoneyCommand(command, params, client) { +function givePlayerMoneyCommand(command, params, client) { if(areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - + let splitParams = params.split(" "); let targetClient = getPlayerFromParams(splitParams[0]); let amount = toInteger(splitParams[1]); @@ -682,7 +682,7 @@ function givePlayerMoneyCommand(command, params, client) { messagePlayerError(client, "That player is not connected!"); return false; } - + getPlayerCurrentSubAccount(targetClient).cash += amount; updatePlayerCash(targetClient); messagePlayerSuccess(client, `You gave [#AAAAAA]$${amount} [#FFFFFF]to [#AAAAAA]${getCharacterFullName(targetClient)}`); diff --git a/scripts/server/native.js b/scripts/server/native.js index 61c0a245..5708794d 100644 --- a/scripts/server/native.js +++ b/scripts/server/native.js @@ -12,30 +12,6 @@ // --------------------------------------------------------------------------- -function agSpawnPlayer(client, subAccountData) { - return spawnPlayer(client, subAccountData.spawnPosition, subAccountData.spawnRotation, subAccountData.skin); -} - -// --------------------------------------------------------------------------- - -function agCreateVehicle(vehicleData) { - return createVehicle(vehicleData.model, vehicleData.spawnPosition); -} - -// --------------------------------------------------------------------------- - -function agSetVehiclePosition(vehicle, position) { - vehicle.position = position; -} - -// --------------------------------------------------------------------------- - -function agSetVehicleRotation(vehicle, heading) { - vehicle.heading = heading; -} - -// --------------------------------------------------------------------------- - function getServerGame() { return server.game; } @@ -200,4 +176,10 @@ function removePlayerFromVehicle(client) { return true; } +// --------------------------------------------------------------------------- + +function setPlayerSkin(client, skin) { + client.player.modelIndex = skin; +} + // --------------------------------------------------------------------------- \ No newline at end of file diff --git a/scripts/server/startup.js b/scripts/server/startup.js index 59307425..f46d8dd8 100644 --- a/scripts/server/startup.js +++ b/scripts/server/startup.js @@ -12,6 +12,8 @@ function initServerScripts() { checkForAllRequiredModules(); + initConfigScript(); + initClassScript(); initDatabaseScript(); initBitFlagScript(); @@ -27,7 +29,6 @@ function initServerScripts() { initJobScript(); initVehicleScript(); initDeveloperScript(); - initConfigScript(); initKeyBindScript(); initEventScript(); initAntiCheatScript(); @@ -46,7 +47,7 @@ function initServerScripts() { // --------------------------------------------------------------------------- function checkForHashingModule() { - if(module.hashing == "undefined") { + if(typeof module.hashing == "undefined") { return false; } return true; @@ -55,10 +56,10 @@ function checkForHashingModule() { // --------------------------------------------------------------------------- function checkForMySQLModule() { - if(module.mysql == "undefined") { + if(typeof module.mysql == "undefined") { return false; } - + return true; } @@ -72,7 +73,7 @@ function checkForAllRequiredModules() { console.warn("[Asshat.Startup]: This resource will now shutdown."); thisResource.stop(); } - + if(!checkForMySQLModule()) { console.warn("[Asshat.Startup]: MySQL module is not loaded!"); console.warn("[Asshat.Startup]: This resource will now shutdown."); @@ -85,8 +86,6 @@ function checkForAllRequiredModules() { // --------------------------------------------------------------------------- -serverConfig = loadServerConfigFromGameAndPort(server.game, server.port); -applyConfigToServer(serverConfig); initServerScripts(); // --------------------------------------------------------------------------- \ No newline at end of file diff --git a/scripts/server/subaccount.js b/scripts/server/subaccount.js index fd842561..91633502 100644 --- a/scripts/server/subaccount.js +++ b/scripts/server/subaccount.js @@ -221,7 +221,7 @@ addNetworkHandler("ag.nextCharacter", function(client) { // --------------------------------------------------------------------------- -async function selectCharacter(client, characterId = -1) { +function selectCharacter(client, characterId = -1) { if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { triggerNetworkEvent("ag.characterSelectSuccess", client); } @@ -230,51 +230,28 @@ async function selectCharacter(client, characterId = -1) { getPlayerData(client).currentSubAccount = characterId; } - let tempSubAccount = getPlayerCurrentSubAccount(client); - spawnPlayer(client, tempSubAccount.spawnPosition, tempSubAccount.spawnHeading, tempSubAccount.skin); + console.log(`[Asshat.SubAccount] Spawning ${getPlayerDisplayForConsole(client)} with skin ${getPlayerCurrentSubAccount(client).skin}`); + spawnPlayer(client, getPlayerCurrentSubAccount(client).spawnPosition, getPlayerCurrentSubAccount(client).spawnHeading, getPlayerCurrentSubAccount(client).skin); - tempSubAccount.lastLogin = new Date().getTime(); - - messagePlayerAlert(client, `You are now playing as: [#0099FF]${tempSubAccount.firstName} ${tempSubAccount.lastName}`, getColourByName("white")); - messagePlayerNormal(client, "This server is in early development and may restart at any time for updates.", getColourByName("orange")); - messagePlayerNormal(client, "Please report any bugs using /bug and suggestions using /idea", getColourByName("yellow")); - - triggerNetworkEvent("ag.restoreCamera", client); - setEntityData(client, "ag.spawned", true, true); - while(client.player == null) {}; - - setTimeout(function() { - setEntityData(client.player, "ag.spawned", true, true); - //triggerNetworkEvent("ag.restoreCamera", client); - setPlayerPosition(client, tempSubAccount.spawnPosition); - setPlayerHeading(client, tempSubAccount.spawnHeading); - setPlayerInterior(client, tempSubAccount.interior); - setPlayerVirtualWorld(client, tempSubAccount.dimension); - setTimeout(function() { - updatePlayerCash(client); - }, 1000); - }, client.ping+1000); - - updateAllPlayerNameTags(); - - getPlayerData(client).switchingCharacter = false; - triggerNetworkEvent("ag.jobType", client, tempSubAccount.job); + getPlayerCurrentSubAccount(client).lastLogin = new Date().getTime(); } addNetworkHandler("ag.selectCharacter", selectCharacter); // --------------------------------------------------------------------------- function switchCharacterCommand(command, params, client) { - getPlayerCurrentSubAccount(client).spawnPosition = getPlayerPosition(client); - getPlayerCurrentSubAccount(client).spawnHeading = getPlayerHeading(client); - //getPlayerCurrentSubAccount(client).interior = getPlayerInterior(client); - //getPlayerCurrentSubAccount(client).dimension = getPlayerVirtualWorld(client); + if(isPlayerSpawned(client)) { + getPlayerCurrentSubAccount(client).spawnPosition = getPlayerPosition(client); + getPlayerCurrentSubAccount(client).spawnHeading = getPlayerHeading(client); + //getPlayerCurrentSubAccount(client).interior = getPlayerInterior(client); + //getPlayerCurrentSubAccount(client).dimension = getPlayerVirtualWorld(client); - saveSubAccountToDatabase(getPlayerCurrentSubAccount(client)); - - resetClientStuff(client); + saveSubAccountToDatabase(getPlayerCurrentSubAccount(client)); + + resetClientStuff(client); - client.despawnPlayer(); + client.despawnPlayer(); + } showConnectCameraToPlayer(client); showCharacterSelectToClient(client); } diff --git a/scripts/server/timers.js b/scripts/server/timers.js index a72a64e6..b61d2251 100644 --- a/scripts/server/timers.js +++ b/scripts/server/timers.js @@ -24,7 +24,7 @@ function saveAllServerDataToDatabase() { saveAllHousesToDatabase(); saveAllBusinessesToDatabase(); saveServerConfigToDatabase(getServerConfig()); - saveAllVehiclesToDatabase(); + saveAllVehiclesToDatabase(); saveAllClientsToDatabase(); console.log("[Asshat.Utilities]: Saved all server data to database!"); } diff --git a/scripts/server/translate.js b/scripts/server/translate.js index 4499a5fa..fdbbf4dc 100644 --- a/scripts/server/translate.js +++ b/scripts/server/translate.js @@ -12,7 +12,7 @@ function translateMessage(messageText, fromLanguageId, toLanguageId) { let translatedText = ""; - + let thisTranslationURL = formatTranslationURL(messageText, fromLanguageId, toLanguageId); httpGet( thisTranslationURL, @@ -27,7 +27,7 @@ function translateMessage(messageText, fromLanguageId, toLanguageId) { function(data) { } ); - + return this.translatedText; } diff --git a/scripts/server/utilities.js b/scripts/server/utilities.js index 88c435ac..53850bc5 100644 --- a/scripts/server/utilities.js +++ b/scripts/server/utilities.js @@ -31,11 +31,11 @@ let policeStations = [ [340.25, -1123.375, 25.98], // Staunton Island [-1253.0, -138.1875, 58.75], // Shoreside Vale ], - + [ // GTA Vice City [399.77, -468.90, 11.73], // Washington Beach [508.96, 512.07, 12.10], // Vice Point - [-657.43, 762.31, 11.59], // Downtown + [-657.43, 762.31, 11.59], // Downtown [-885.08, -470.44, 13.11], // Little Havana ], ]; @@ -49,7 +49,7 @@ let fireStations = [ [-78.48, -436.80, 16.17], // Staunton Island [-1202.10, -14.67, 53.20], // Shoreside Vale ], - + [ // GTA Vice City [-695.15, 912.58, 11.08], // Downtown ], @@ -60,9 +60,9 @@ let fireStations = [ let hospitals = [ [], [ // GTA III - + ], - + [ // GTA Vice City [-822.57, 1152.82, 12.41], // Downtown (Shuman Health Care Center) [-885.08, -470.44, 13.11], // Little Havana (West Haven Community Health Care Center) @@ -78,7 +78,7 @@ let payAndSprays = [ [925.4, -360.3, 10.83], // Portland [-1142.4, 35.01, 58.61], // Shoreside Vale ], - + [ // GTA Vice City [-869.95, -119.06, 10.63], // Little Haiti [-910.82, -1265.96, 11.79], // Viceport @@ -93,7 +93,7 @@ let ammuNations = [ [1068.3, -400.9, 15.24], // Portland [348.2, -717.9, 26.43], // Staunton Island ], - + [ // GTA Vice City [-676.32, 1204.98, 11.10], // Downtown ], @@ -103,27 +103,27 @@ let ammuNations = [ let hiddenPackages = [ [ - [1105.25, -1020, 25.0625], - [877.562, -788, 27.5625], - [1254, -611.188, 22.75], - [1045.75, -967.062, 16], + [1105.25, -1020, 25.0625], + [877.562, -788, 27.5625], + [1254, -611.188, 22.75], + [1045.75, -967.062, 16], [942.062, -793.375, 14.875], - [934, -718.875, 14.75], - [898.062, -414.688, 26.5], + [934, -718.875, 14.75], + [898.062, -414.688, 26.5], [846.875, -442.5, 23.1875], [927.062, -404.375, 29.0625], - [864.25, -171.5, 3.5], + [864.25, -171.5, 3.5], [1538.25, -174.375, 19.1875], [1213.06, -127.062, 15.0625], - [753.562, 137, 3.5], - [1162, -101.75, 12], - [1155.56, -191.5, 14.375], - [1285.5, -247.5, 42.375], + [753.562, 137, 3.5], + [1162, -101.75, 12], + [1155.56, -191.5, 14.375], + [1285.5, -247.5, 42.375], [1007.19, -219.562, 6.6875], - [1138.19, -250, 24.25], + [1138.19, -250, 24.25], [1023.56, -423.688, 14.875], [1237.5, -854.062, 20.5625], - [1478.25, -1150.69, 12], + [1478.25, -1150.69, 12], [1018.88, -56.75, 21], [1465.69, -166.5, 55.5], [1120.19, -926.188, 16], @@ -211,29 +211,29 @@ let hiddenPackages = [ // --------------------------------------------------------------------------- let weekDays = [ - "Sunday", - "Monday", - "Tuesday", - "Wednesday", - "Thursday", - "Friday", + "Sunday", + "Monday", + "Tuesday", + "Wednesday", + "Thursday", + "Friday", "Saturday" ]; // --------------------------------------------------------------------------- let months = [ - "January", - "February", - "March", - "April", - "May", - "June", - "July", - "August", - "September", - "October", - "November", + "January", + "February", + "March", + "April", + "May", + "June", + "July", + "August", + "September", + "October", + "November", "December" ]; @@ -241,13 +241,13 @@ let months = [ let cardinalDirections = [ "North", - "Northeast", - "East", - "Southeast", - "South", - "Southwest", - "West", - "Northwest", + "Northeast", + "East", + "Southeast", + "South", + "Southwest", + "West", + "Northwest", "Unknown" ]; @@ -257,7 +257,7 @@ function areParamsEmpty(params) { if(!params || params == "" || params.length == 0 || typeof params == "undefined") { return true; } - + return false; } @@ -314,7 +314,7 @@ function getWeaponModelId(weaponId) { function getIsland(position) { if(getServerGame() == GAME_GTA_III) { - if(position.x > 616) { + if(position.x > 616) { return 0; } else if(position.x < -283) { return 2; @@ -352,12 +352,12 @@ function makeReadableTime(hour, minute) { let hourStr = toString(hour); let minuteStr = toString(minute); let meridianStr = "AM"; - + if(hour < 10) { hourStr = "0" + toString(hour); meridianStr = "AM"; } - + if(hour > 12) { let actualHour = hour-12; if(actualHour < 10) { @@ -367,11 +367,11 @@ function makeReadableTime(hour, minute) { } meridianStr = "PM"; } - + if(minute < 10) { minuteStr = "0" + toString(minute); } - + return hourStr + ":" + minuteStr + " " + meridianStr; } @@ -380,9 +380,9 @@ function makeReadableTime(hour, minute) { function getPosToRightOfPos(pos, angle, distance) { let x = (pos.x+((Math.cos((-angle+1.57)+(Math.PI/2)))*distance)); let y = (pos.y+((Math.sin((-angle+1.57)+(Math.PI/2)))*distance)); - + let rightPos = toVector3(x, y, pos.z); - + return rightPos; } @@ -391,9 +391,9 @@ function getPosToRightOfPos(pos, angle, distance) { function getPosToLeftOfPos(pos, angle, distance) { let x = (pos.x+((Math.cos((angle+1.57)+(Math.PI/2)))*distance)); let y = (pos.y+((Math.sin((angle+1.57)+(Math.PI/2)))*distance)); - + let leftPos = toVector3(x, y, pos.z); - + return leftPos; } @@ -403,7 +403,7 @@ function getPosInFrontOfPos(pos, angle, distance) { let x = (pos.x+((Math.cos(angle+(Math.PI/2)))*distance)); let y = (pos.y+((Math.sin(angle+(Math.PI/2)))*distance)); let z = pos.z; - + return toVector3(x, y, z); } @@ -413,7 +413,7 @@ function getPosBehindPos(pos, angle, distance) { let x = (pos.x+((Math.cos(angle-(Math.PI/2)))*distance)); let y = (pos.y+((Math.sin(angle-(Math.PI/2)))*distance)); let z = pos.z; - + return toVector3(x,y,z); } @@ -458,7 +458,7 @@ function radToDeg(rad) { function getAngleInCircleFromCenter(center, total, current) { let gap = 360 / total; let deg = Math.floor(gap*current); - + if(deg <= 0) { deg = 1; } else { @@ -466,7 +466,7 @@ function getAngleInCircleFromCenter(center, total, current) { deg = 359; } } - + return degToRad(deg); } @@ -586,15 +586,15 @@ function isParamsInvalid(params) { if(params == null) { return true; } - + if(params == "") { return true; } - + if(params.length == 0) { - return true; + return true; } - + return false; } @@ -605,22 +605,22 @@ function isValidVehicleModel(modelId) { if(modelId < 90 || modelId > 150) { return false; } - + return true; } - + if(getServerGame() == GAME_GTA_VC) { if(modelId < 130 || modelId > 236) { return false; } - + return true; } if(getServerGame() == GAME_GTA_SA) { return true; } - + if(getServerGame() == GAME_GTA_IV) { return true; } @@ -633,24 +633,24 @@ function isValidVehicleModel(modelId) { function getVehicleModelIdFromParams(params) { if(isNaN(params)) { let modelId = getVehicleModelIdFromName(params); - + if(!modelId) { return false; } - + if(isValidVehicleModel(toInteger(modelId))) { return toInteger(modelId); } - - return false; + + return false; } else { if(isValidVehicleModel(toInteger(params))) { return toInteger(params); } - + return false; } - + return false; } @@ -662,15 +662,15 @@ function getVehicleModelIdFromName(params) { if(toLowerCase(getGameData().gtaivVehicleModels[i][0]).indexOf(toLowerCase(params)) != -1) { return getGameData().gtaivVehicleModels[i][1]; } - } + } } else { let vehicleNames = getGameData().vehicleNames[getServerGame()]; for(let i in vehicleNames) { if(toLowerCase(vehicleNames[i]).indexOf(toLowerCase(params)) != -1) { return toInteger(i)+toInteger(getGameData().vehicleModelIdStart[getServerGame()]); } - } - } + } + } return false; } @@ -685,11 +685,11 @@ function doesWordStartWithVowel(word) { case "o": case "u": return true; - + default: return false; } - + return false; } @@ -740,7 +740,7 @@ function getClientFromName(clientName) { return clients[i]; } } - + return false; } @@ -753,7 +753,7 @@ function getClientFromPlayer(player) { return clients[i]; } } - + return false; } @@ -771,14 +771,14 @@ function getPlayerFromParams(params) { if(toLowerCase(getCharacterFullName(clients[i])).indexOf(toLowerCase(params)) != -1) { return clients[i]; } - } + } } } else { if(typeof clients[toInteger(params)] != "undefined") { return clients[toInteger(params)]; - } + } } - + return false; } @@ -792,7 +792,7 @@ function getFirstEmptyEffectSlot(isServer = false) { } } } - + return false; } @@ -826,7 +826,7 @@ function createBitwiseTable(tableKeys) { let bitVal = 0; let bitTable = {}; let incVal = 1; - + for(let i in tableKeys) { let key = tableKeys[i]; bitTable[key] = bitVal; @@ -860,11 +860,11 @@ function getCardinalDirection(pos1, pos2) { let a = pos1.x - pos2.x; let b = pos1.y - pos2.y; let c = pos1.z - pos2.z; - + let x = Math.abs(a); let y = Math.abs(b); let z = Math.abs(c); - + let no = 0; let ne = 1; let ea = 2; @@ -874,7 +874,7 @@ function getCardinalDirection(pos1, pos2) { let we = 6; let nw = 7; let na = 8; - + if(b < 0 && a < 0){ if(x < (y/2)){ return no; @@ -921,19 +921,19 @@ function getTimeDifferenceDisplay(unixTimeOne, unixTimeTwo) { let minutes = floor(timeDifference/60); let hourString = ""; let minuteString = ""; - + if(hours == 1) { hourString = "1 hour"; } else { hourString = toString(hours) + " hours"; } - + if(minutes == 1) { minuteString = "1 minute"; } else { minuteString = toString(minutes) + " minute"; } - + return hourString + " and " + minuteString; } @@ -1027,16 +1027,16 @@ function getRandomRGB() { function breakText(text, maxLength) { let lines = []; let j = Math.floor(text.length / maxLength); - + for(let i = 0; i < j; i++) { lines.push(text.substr(i*maxLength,maxLength)); } - + let line = text.substr(j*maxLength, text.length % maxLength); if(line.length > 0) { lines.push(line); } - + return lines; } @@ -1059,7 +1059,7 @@ function getArrayOfElementId(elements) { for(let i in elements) { tempArray.push(elements[i].id); } - + return tempArray; } @@ -1082,7 +1082,7 @@ function isValidSkin(skin, game = GAME_GTA_III) { switch(skin) { case 111: return false; - + default: return true; } @@ -1252,11 +1252,11 @@ function sendAllPoliceStationBlips(client) { let tempBlips = []; for(let i in getServerData().policeStations[getServerGame()]) { tempBlips.push([ - getGameConfig().blipSprites[getServerGame()].policeStation, - getServerData().policeStations[getServerGame()][i].position.x, - getServerData().policeStations[getServerGame()][i].position.y, - getServerData().policeStations[getServerGame()][i].position.z, - 3, + getGameConfig().blipSprites[getServerGame()].policeStation, + getServerData().policeStations[getServerGame()][i].position.x, + getServerData().policeStations[getServerGame()][i].position.y, + getServerData().policeStations[getServerGame()][i].position.z, + 3, getColourByName("policeBlue"), ]); } @@ -1271,11 +1271,11 @@ function sendAllFireStationBlips(client) { let tempBlips = []; for(let i in getServerData().fireStations[getServerGame()]) { tempBlips.push([ - getGameConfig().blipSprites[getServerGame()].fireStation, - getServerData().fireStations[getServerGame()][i].position.x, - getServerData().fireStations[getServerGame()][i].position.y, - getServerData().fireStations[getServerGame()][i].position.z, - 3, + getGameConfig().blipSprites[getServerGame()].fireStation, + getServerData().fireStations[getServerGame()][i].position.x, + getServerData().fireStations[getServerGame()][i].position.y, + getServerData().fireStations[getServerGame()][i].position.z, + 3, getColourByName("firefighterRed"), ]); } @@ -1290,11 +1290,11 @@ function sendAllHospitalBlips(client) { let tempBlips = []; for(let i in getServerData().hospitals[getServerGame()]) { tempBlips.push([ - getGameConfig().blipSprites[getServerGame()].hospital, - getServerData().hospitals[getServerGame()][i].position.x, - getServerData().hospitals[getServerGame()][i].position.y, - getServerData().hospitals[getServerGame()][i].position.z, - 3, + getGameConfig().blipSprites[getServerGame()].hospital, + getServerData().hospitals[getServerGame()][i].position.x, + getServerData().hospitals[getServerGame()][i].position.y, + getServerData().hospitals[getServerGame()][i].position.z, + 3, getColourByName("medicPink"), ]); } @@ -1309,11 +1309,11 @@ function sendAllAmmunationBlips(client) { let tempBlips = []; for(let i in getServerData().ammunations[getServerGame()]) { tempBlips.push([ - getGameConfig().blipSprites[getServerGame()].ammunation, - getServerData().ammunations[getServerGame()][i].position.x, - getServerData().ammunations[getServerGame()][i].position.y, - getServerData().ammunations[getServerGame()][i].position.z, - 3, + getGameConfig().blipSprites[getServerGame()].ammunation, + getServerData().ammunations[getServerGame()][i].position.x, + getServerData().ammunations[getServerGame()][i].position.y, + getServerData().ammunations[getServerGame()][i].position.z, + 3, 0 ]); } @@ -1328,11 +1328,11 @@ function sendAllPayAndSprayBlips(client) { let tempBlips = []; for(let i in getServerData().payAndSprays[getServerGame()]) { tempBlips.push([ - getGameConfig().blipSprites[getServerGame()].payAndSpray, - getServerData().payAndSprays[getServerGame()][i].position.x, - getServerData().payAndSprays[getServerGame()][i].position.y, - getServerData().payAndSprays[getServerGame()][i].position.z, - 3, + getGameConfig().blipSprites[getServerGame()].payAndSpray, + getServerData().payAndSprays[getServerGame()][i].position.x, + getServerData().payAndSprays[getServerGame()][i].position.y, + getServerData().payAndSprays[getServerGame()][i].position.z, + 3, 0 ]); } @@ -1347,11 +1347,11 @@ function sendAllFuelStationBlips(client) { let tempBlips = []; for(let i in getServerData().fuelStations[getServerGame()]) { tempBlips.push([ - getGameConfig().blipSprites[getServerGame()].fuelStation, - getServerData().fuelStations[getServerGame()][i].position.x, - getServerData().fuelStations[getServerGame()][i].position.y, - getServerData().fuelStations[getServerGame()][i].position.z, - 3, + getGameConfig().blipSprites[getServerGame()].fuelStation, + getServerData().fuelStations[getServerGame()][i].position.x, + getServerData().fuelStations[getServerGame()][i].position.y, + getServerData().fuelStations[getServerGame()][i].position.z, + 3, getColourByName("burntOrange"), ]); } @@ -1480,10 +1480,10 @@ function processHoldActionKey(client) { function processPressActionKey(client) { // Check job stuff let closestJob = getClosestJob(client.player.position); - + if(getPlayerCurrentSubAccount(client).job == AG_JOB_NONE) { if(closestJob.position.distance(client.player.position) <= getGlobalConfig().takeJobDistance) { - + } } } @@ -1503,7 +1503,7 @@ function processHoldVehicleLockKey(client) { // --------------------------------------------------------------------------- function processHoldVehicleEngineKey(client) { - + } // --------------------------------------------------------------------------- @@ -1522,7 +1522,7 @@ function getClientChatColour(client) { function showConnectCameraToPlayer(client) { triggerNetworkEvent("ag.connectCamera", client, getServerConfig().connectCameraPosition, getServerConfig().connectCameraLookAt); - //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); } // --------------------------------------------------------------------------- @@ -1732,7 +1732,7 @@ function getSkinIdFromName(params, gameId = getServerGame()) { function getClosestHospital(position) { let closest = 0; for(let i in getServerData().hospitals[getServerGame()]) { - if(getServerData().hospitals[getServerGame()][i].position.distance(position) < getServerData().hospitals[getServerGame()][closest].position) { + if(getDistance(getServerData().hospitals[getServerGame()][i].position, position) < getDistance(getServerData().hospitals[getServerGame()][closest].position, position)) { closest = i; } } diff --git a/scripts/server/vehicle.js b/scripts/server/vehicle.js index 6e6986e2..168dcf7c 100644 --- a/scripts/server/vehicle.js +++ b/scripts/server/vehicle.js @@ -35,7 +35,7 @@ function loadVehiclesFromDatabase() { } disconnectFromDatabase(dbConnection); } - + console.log(`[Asshat.Vehicle]: ${tempVehicles.length} vehicles loaded from database successfully!`); return tempVehicles; } @@ -66,7 +66,7 @@ function saveVehicleToDatabase(vehicleData) { return false; } - console.log(`[Asshat.Vehicle]: Saving vehicle ${vehicleData.vehicle.id} to database ...`); + console.log(`[Asshat.Vehicle]: Saving vehicle ${vehicleData.databaseId} to database ...`); let dbConnection = connectToDatabase(); if(dbConnection) { if(!vehicleData.spawnLocked) { @@ -75,7 +75,7 @@ function saveVehicleToDatabase(vehicleData) { vehicleData.spawnRotation = vehicleData.vehicle.heading; } else { vehicleData.spawnPosition = vehicleData.syncPosition; - vehicleData.spawnRotation = vehicleData.syncHeading; + vehicleData.spawnRotation = vehicleData.syncHeading; } } @@ -142,10 +142,10 @@ function createVehicleCommand(command, params, client) { if(!vehicle) { messagePlayerError(client, "The vehicle could not be created!"); return false; - } + } vehicle.heading = getPlayerHeading(client); addToWorld(vehicle); - + let tempVehicleData = new serverClasses.vehicleData(false, vehicle); setEntityData(vehicle, "ag.dataSlot", vehicleDataSlot, true); @@ -168,7 +168,7 @@ function createTemporaryVehicleCommand(command, params, client) { let frontPos = getPosInFrontOfPos(getPlayerPosition(client), getPlayerHeading(client), getGlobalConfig().spawnCarDistance); let vehicleDataSlot = getServerData().vehicles.length; - + let vehicle = gta.createVehicle(modelId, frontPos, getPlayerHeading(client)); if(!vehicle) { messagePlayerError(client, "The vehicle could not be created!"); @@ -229,18 +229,18 @@ function vehicleLockCommand(command, params, client) { function vehicleLightsCommand(command, params, client) { if(!getPlayerVehicle(client)) { messagePlayerError(client, "You need to be in a vehicle!"); - return false; + return false; } let vehicle = getPlayerVehicle(client); if(getPlayerVehicleSeat(client) > 1) { messagePlayerError(client, "You need to be in the front seat!"); - return false; - } + return false; + } triggerNetworkEvent("ag.veh.lights", getVehicleSyncer(vehicle), getVehicleForNetworkEvent(vehicle), getVehicleData(vehicle).lights); - + getVehicleData(vehicle).lights = !getVehicleData(vehicle).lights; meActionToNearbyPlayers(client, `turned the ${getVehicleName(vehicle)}'s lights ${getOnOffFromBool(vehicle)}`); @@ -251,7 +251,7 @@ function vehicleLightsCommand(command, params, client) { function deleteVehicleCommand(command, params, client) { if(!getPlayerVehicle(client)) { messagePlayerError(client, "You need to be in a vehicle!"); - return false; + return false; } let vehicle = getPlayerVehicle(client); @@ -269,12 +269,12 @@ function deleteVehicleCommand(command, params, client) { function vehicleEngineCommand(command, params, client) { if(!getPlayerVehicle(client)) { messagePlayerError(client, "You need to be in a vehicle!"); - return false; + return false; } if(getPlayerVehicleSeat(client) > 0) { messagePlayerError(client, "You need to be the driver!"); - return false; + return false; } let vehicle = getPlayerVehicle(client); @@ -296,12 +296,12 @@ function vehicleEngineCommand(command, params, client) { function vehicleSirenCommand(command, params, client) { if(!getPlayerVehicle(client)) { messagePlayerError(client, "You need to be in a vehicle!"); - return false; + return false; } if(getPlayerVehicleSeat(client) > 1) { messagePlayerError(client, "You need to be in the front seat!"); - return false; + return false; } let vehicle = getPlayerVehicle(client); @@ -322,8 +322,8 @@ function vehicleSirenCommand(command, params, client) { function setVehicleColourCommand(command, params, client) { if(!getPlayerVehicle(client)) { messagePlayerError(client, "You need to be in a vehicle!"); - return false; - } + return false; + } let vehicle = getPlayerVehicle(client); @@ -342,14 +342,14 @@ function setVehicleColourCommand(command, params, client) { let splitParams = params.split(" "); let colour1 = toInteger(splitParams[0]) || 0; let colour2 = toInteger(splitParams[1]) || 0; - + getPlayerCurrentSubAccount(client).cash -= getGlobalConfig().resprayVehicleCost; updatePlayerCash(client); vehicle.colour1 = colour1; vehicle.colour2 = colour2; getVehicleData(vehicle).colour1 = colour1; getVehicleData(vehicle).colour2 = colour1; - + meActionToNearbyPlayers(client, `resprays the ${getVehicleName(vehicle)}'s colours`); } @@ -358,10 +358,10 @@ function setVehicleColourCommand(command, params, client) { function vehicleRepairCommand(command, params, client) { if(!isPlayerInAnyVehicle(client)) { messagePlayerError(client, "You need to be in a vehicle!"); - return false; + return false; } - - let vehicle = getPlayerVehicle(client); + + let vehicle = getPlayerVehicle(client); if(!isAtPayAndSpray(getVehiclePosition(vehicle))) { if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("manageVehicles"))) { @@ -375,10 +375,10 @@ function vehicleRepairCommand(command, params, client) { return false; } - + getPlayerCurrentSubAccount(client).cash -= getGlobalConfig().repairVehicleCost; repairVehicle(vehicle); - + meActionToNearbyPlayers(client, `repairs the ${getVehicleName(vehicle)}!`); } @@ -387,14 +387,14 @@ function vehicleRepairCommand(command, params, client) { function buyVehicleCommand(command, params, client) { if(!isPlayerInAnyVehicle(client)) { messagePlayerError(client, "You need to be in a vehicle!"); - return false; + return false; } - - let vehicle = getPlayerVehicle(client); + + let vehicle = getPlayerVehicle(client); if(getVehicleData(vehicle).buyPrice <= 0) { messagePlayerError(client, `This ${getVehicleName(vehicle)} is not for sale!`); - return false; + return false; } if(getPlayerCurrentSubAccount(client).cash < getVehicleData(vehicle).buyPrice) { @@ -403,13 +403,13 @@ function buyVehicleCommand(command, params, client) { } getPlayerData(client).buyingVehicle = vehicle; - + //getPlayerCurrentSubAccount(client).cash -= getVehicleData(vehicle).buyPrice; //getVehicleData(vehicle).buyPrice = 0; //getVehicleData(vehicle).rentPrice = 0; getVehicleData(vehicle).engine = true; vehicle.engine = true; - + meActionToNearbyPlayers(client, `receives a set of keys to test drive the ${getVehicleName(vehicle)} and starts the engine`); messagePlayerInfo(client, `Drive the vehicle away from the dealership to buy it, or get out to cancel.`); } @@ -419,20 +419,20 @@ function buyVehicleCommand(command, params, client) { function rentVehicleCommand(command, params, client) { if(!isPlayerInAnyVehicle(client)) { messagePlayerError(client, "You need to be in a vehicle!"); - return false; + return false; } - - let vehicle = getPlayerVehicle(client); + + let vehicle = getPlayerVehicle(client); if(getVehicleData(vehicle).rentPrice <= 0) { messagePlayerError(client, `This ${getVehicleName(vehicle)} is not for rent!`); - return false; - } + return false; + } getVehicleData(vehicle).rentedBy = client; getPlayerCurrentSubAccount(client).rentingVehicle = vehicle; getVehicleData(vehicle).rentStart = new Date().getTime(); - + meActionToNearbyPlayers(client, `rents the ${getVehicleName(vehicle)} and receives a set of vehicle keys!`); messagePlayerAlert(client, `You will be charged ${getVehicleData(vehicle).rentPrice} per minute to use this vehicle. To stop renting this vehicle, use /vehrent again.`); } @@ -449,7 +449,7 @@ function stopRentingVehicleCommand(command, params, client) { //getPlayerCurrentSubAccount(client).cash -= getVehicleData(vehicle).rentPrice; let vehicle = getPlayerCurrentSubAccount(client).rentingVehicle; stopRentingVehicle(client); - + messagePlayerAlert(client, `You are no longer renting the ${getVehicleName(vehicle)}`); } @@ -464,7 +464,7 @@ function doesClientHaveVehicleKeys(client, vehicle) { if(vehicleData.ownerType == AG_VEHOWNER_PUBLIC) { return true; - } + } if(vehicleData.ownerType == AG_VEHOWNER_PLAYER) { if(vehicleData.ownerId == getPlayerData(client).accountData.databaseId) { @@ -534,10 +534,10 @@ function getVehicleName(vehicle) { function setVehicleJobCommand(command, params, client) { if(!isPlayerInAnyVehicle(client)) { messagePlayerError(client, "You need to be in a vehicle!"); - return false; + return false; } - - let vehicle = getPlayerVehicle(client); + + let vehicle = getPlayerVehicle(client); let closestJobLocation = getClosestJobLocation(getVehiclePosition(vehicle)); let jobId = closestJobLocation.job; @@ -565,13 +565,13 @@ function setVehicleRankCommand(command, params, client) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - + if(!isPlayerInAnyVehicle(client)) { messagePlayerError(client, "You need to be in a vehicle!"); - return false; + return false; } - - let vehicle = getPlayerVehicle(client); + + let vehicle = getPlayerVehicle(client); let rankId = params; @@ -585,7 +585,7 @@ function setVehicleRankCommand(command, params, client) { messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]set their [#AAAAAA]${getVehicleName(vehicle)} [#FFFFFF]rank to [#AAAAAA]${getClanRankData(getVehicleData(vehicle).ownerId, rankId).name} [#FFFFFF]of the [#FF9900]${getClanData(getVehicleData(vehicle).ownerId).name} [#FFFFFFclan!`); } else if(getVehicleData(vehicle).ownerType == AG_VEHOWNER_JOB) { getVehicleData(vehicle).rank = rankId; - messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]set their [#AAAAAA]${getVehicleName(vehicle)} [#FFFFFF]rank to [#AAAAAA]${rankId} [#FFFFFF]of the [#FFFF00]${getJobData(getVehicleData(vehicle).ownerId).name} [#FFFFFF]job!`); + messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]set their [#AAAAAA]${getVehicleName(vehicle)} [#FFFFFF]rank to [#AAAAAA]${rankId} [#FFFFFF]of the [#FFFF00]${getJobData(getVehicleData(vehicle).ownerId).name} [#FFFFFF]job!`); } } @@ -594,9 +594,9 @@ function setVehicleRankCommand(command, params, client) { function setVehicleClanCommand(command, params, client) { if(!isPlayerInAnyVehicle(client)) { messagePlayerError(client, "You need to be in a vehicle!"); - return false; + return false; } - + let vehicle = getPlayerVehicle(client); let clanId = getClanFromParams(params); @@ -616,9 +616,9 @@ function setVehicleClanCommand(command, params, client) { function setVehicleToBusinessCommand(command, params, client) { if(!isPlayerInAnyVehicle(client)) { messagePlayerError(client, "You need to be in a vehicle!"); - return false; + return false; } - + let vehicle = getPlayerVehicle(client); let businessId = toInteger(isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client)); @@ -633,9 +633,9 @@ function setVehicleToBusinessCommand(command, params, client) { function setVehicleOwnerCommand(command, params, client) { if(!isPlayerInAnyVehicle(client)) { messagePlayerError(client, "You need to be in a vehicle!"); - return false; + return false; } - + let vehicle = getPlayerVehicle(client); let targetClient = getPlayerFromParams(params); @@ -655,9 +655,9 @@ function setVehicleOwnerCommand(command, params, client) { function setVehicleRentPriceCommand(command, params, client) { if(!isPlayerInAnyVehicle(client)) { messagePlayerError(client, "You need to be in a vehicle!"); - return false; + return false; } - + let vehicle = getPlayerVehicle(client); if(!doesClientOwnVehicle(client, vehicle)) { @@ -678,9 +678,9 @@ function setVehicleRentPriceCommand(command, params, client) { function setVehicleBuyPriceCommand(command, params, client) { if(!isPlayerInAnyVehicle(client)) { messagePlayerError(client, "You need to be in a vehicle!"); - return false; + return false; } - + let vehicle = getPlayerVehicle(client); if(!doesClientOwnVehicle(client, vehicle)) { @@ -701,9 +701,9 @@ function setVehicleBuyPriceCommand(command, params, client) { function removeVehicleOwnerCommand(command, params, client) { if(!isPlayerInAnyVehicle(client)) { messagePlayerError(client, "You need to be in a vehicle!"); - return false; + return false; } - + let vehicle = getPlayerVehicle(client); let targetClient = getPlayerFromParams(params); @@ -724,15 +724,15 @@ function removeVehicleOwnerCommand(command, params, client) { function getVehicleInfoCommand(command, params, client) { if(!isPlayerInAnyVehicle(client)) { messagePlayerError(client, "You need to be in a vehicle!"); - return false; + return false; } - + let vehicle = getPlayerVehicle(client); if(!getVehicleData(vehicle)) { messagePlayerError(client, "This is a random traffic vehicle and doesn't have any info"); - return false; - } + return false; + } let vehicleData = getVehicleData(vehicle); @@ -759,8 +759,8 @@ function getVehicleInfoCommand(command, params, client) { case AG_VEHOWNER_BIZ: ownerName = getBusinessData(vehicleData.ownerId).name; ownerType = "business"; - break; - + break; + default: break; } @@ -773,9 +773,9 @@ function getVehicleInfoCommand(command, params, client) { function toggleVehicleSpawnLockCommand(command, params, client) { if(!isPlayerInAnyVehicle(client)) { messagePlayerError(client, "You need to be in a vehicle!"); - return false; + return false; } - + let vehicle = getPlayerVehicle(client); let spawnLocked = getVehicleData(vehicle).spawnLocked; @@ -825,7 +825,7 @@ function respawnAllVehiclesCommand(command, params, client) { function stopRentingVehicle(client) { let vehicleData = getPlayerData(client).rentingVehicle; getPlayerData(client).rentingVehicle = false; - vehicleData.rentedBy = false; + vehicleData.rentedBy = false; respawnVehicle(vehicleData); } @@ -861,11 +861,11 @@ function spawnVehicle(vehicleData) { vehicle.engine = intToBool(vehicleData.engine); //vehicle.lights = intToBool(vehicleData.lights); //vehicle.health = vehicleData.health; - + //vehicle.position = vehicleData.spawnPosition; vehicle.heading = vehicleData.spawnRotation; - vehicle.locked = intToBool(vehicleData.locked); + vehicle.locked = intToBool(vehicleData.locked); vehicleData.vehicle = vehicle; @@ -928,8 +928,8 @@ function getVehicleOwnerTypeText(ownerType) { return "player"; case AG_VEHOWNER_BIZ: - return "business"; - + return "business"; + default: return "unknown"; } @@ -966,9 +966,9 @@ function createNewDealershipVehicle(model, spawnPosition, spawnRotation, price, } vehicle.heading = spawnRotation; addToWorld(vehicle); - + let tempVehicleData = new serverClasses.vehicleData(false, vehicle); - + tempVehicleData.buyPrice = price; tempVehicleData.spawnLocked = true; tempVehicleData.spawnPosition = spawnPosition; diff --git a/scripts/shared/game-data.js b/scripts/shared/game-data.js index 84d17a91..5119e98a 100644 --- a/scripts/shared/game-data.js +++ b/scripts/shared/game-data.js @@ -275,7 +275,7 @@ let gameData = { COLOUR_ORANGE, // GTA San Andreas COLOUR_ORANGE, // GTA Underground COLOUR_SILVER, // GTA IV - COLOUR_SILVER // GTA IV (EFLC) + COLOUR_SILVER // GTA IV (EFLC) ], weatherNames: [ ["Unknown"], @@ -360,26 +360,26 @@ let gameData = { "Thunderstorm", "Extra Sunny", "Sunny/Windy", - ], + ], ], gameNames: [ - "Unknown", - "GTA III", - "GTA Vice City", - "GTA San Andreas", + "Unknown", + "GTA III", + "GTA Vice City", + "GTA San Andreas", "GTA Underground", "GTA IV", "GTA IV: Episodes from Liberty City", ], vehicleWheelStateNames: [ - "normal", - "flat", + "normal", + "flat", "gone" ], vehicleDoorStateNames: [ - "closed", "closed", - "swinging", + "closed", + "swinging", "open" ], vehicleWheelNames: [ @@ -400,7 +400,7 @@ let gameData = { "Head Radio", "Double Cleff FM", "Jah Radio", - "Rise FM", + "Rise FM", "Lips 106", "Flashback FM", "Chatterbox 109", @@ -410,7 +410,7 @@ let gameData = { "Wildstyle", "Flash FM", "K CHAT", - "Fever 105", + "Fever 105", "VROCK", "VCPR", "Espantoso", @@ -422,7 +422,7 @@ let gameData = { "KROSE", "KDST", "Bounce FM", - "SFUR", + "SFUR", "Radio Los Santos", "Radio X", "CSR Radio", @@ -433,7 +433,7 @@ let gameData = { ] ], vehicleModelIdStart: [ - 0, + 0, 90, // GTA III 130, // GTA Vice City 400, // GTA San Andreas @@ -502,7 +502,7 @@ let gameData = { "Escape", "Borgnine Taxi", "Toyz Van", - "Ghost" + "Ghost" ], [ // GTA Vice City "Landstalker", @@ -611,7 +611,7 @@ let gameData = { "Hotring Racer 3", "Bloodring Banger 1", "Bloodring Banger 2", - "VCPD Cheetah" + "VCPD Cheetah" ], [ // GTA San Andreas "Landstalker", @@ -1153,7 +1153,7 @@ let gameData = { "#1B376D", "#EC6AAE", "#000000" - ], + ], [ // GTA Underground "#000000", "#F5F5F5", @@ -1931,45 +1931,45 @@ let gameData = { 292 ], [ // GTA San Andreas - + ], ], locations: [ [], - + [ // GTA III // Police Stations ["Portland Police Station", [1143.875, -675.1875, 14.97], 0.0], ["Staunton Island Police Station", [340.25, -1123.375, 25.98], 0.0], ["Shoreside Vale Police Station", [-1253.0, -138.1875, 58.75], 0.0], - + // Hospitals ["Portland Hospital", [1144.25, -596.875, 14.97], 0.0], ["Staunton Island Hospital", [183.5, -17.75, 16.21], 0.0], ["Shoreside Vale Hospital", [-1259.5, -44.5, 58.89], 0.0], - + // Fire Stations ["Portland Fire Station", [1103.70, -52.45, 7.49], 0.0], ["Staunton Island Fire Station", [-78.48, -436.80, 16.17], 0.0], - ["Shoreside Vale Fire Station", [-1202.10, -14.67, 53.20], 0.0], - + ["Shoreside Vale Fire Station", [-1202.10, -14.67, 53.20], 0.0], + // Pay and Sprays - ["Portland Pay and Spray", [925.4, -360.3, 10.83], 0.0], - ["Staunton Island Pay and Spray", [381.8, -493.8, 25.95], 0.0], - ["Shoreside Vale Pay and Spray", [-1142.4, 35.01, 58.61], 0.0], + ["Portland Pay and Spray", [925.4, -360.3, 10.83], 0.0], + ["Staunton Island Pay and Spray", [381.8, -493.8, 25.95], 0.0], + ["Shoreside Vale Pay and Spray", [-1142.4, 35.01, 58.61], 0.0], // Ammunations - ["Portland Ammunation", [1068.3, -400.9, 15.24], 0.0], - ["Staunton Island Ammunation", [348.2, -717.9, 26.43], 0.0], - + ["Portland Ammunation", [1068.3, -400.9, 15.24], 0.0], + ["Staunton Island Ammunation", [348.2, -717.9, 26.43], 0.0], + // Train Stations ["Bedford Point Train Station", [178.52, -1551.40, 26.162], -3.105], ["Francis International Airport Train Station", [-633.42, -760.06, 18.919], 1.586], ["Rockford Train Station", [225.66, -69.07, 20.998], -3.115], ["Saint Marks Train Station", [1306.69, -512.38, 40.078], -2.458], ["Hepburn Heights Train Station", [1029.07, -164.18, 4.972], 0.005], - ["Chinatown Train Station", [775.27, -622.28, 14.747], 0.006], - + ["Chinatown Train Station", [775.27, -622.28, 14.747], 0.006], + // Safehouses ["Portland Safehouse", [885.52, -308.47, 8.615], -1.532], @@ -1993,44 +1993,44 @@ let gameData = { ["Fuzz Ball", [1000.03, -877.82, 14.547], -3.136], ["Portland Docks Entrance", [1360.55, -818.08, 14.415], -1.574], ["Punk Noodle Diner", [1040.10, -653.10, 14.973], 1.551], - ["Greasy Joe's Diner", [864.45, -999.86, 4.646], -0.020], + ["Greasy Joe's Diner", [864.45, -999.86, 4.646], -0.020], ], - + [ // GTA VC // Police Stations ["Washington Beach Police Station", [399.77, -468.90, 11.73], 0.0], ["Vice Point Police Station", [508.96, 512.07, 12.10], 0.0], ["Downtown Police Station", [-657.43, 762.31, 11.59], 0.0], ["Little Havana Police Station", [-885.08, -470.44, 13.11], 0.0], - - // Hospitals + + // Hospitals ["Downtown Hospital", [-822.57, 1152.82, 12.41], 0.0], ["Little Havana Medical Center", [-885.08, -470.44, 13.11], 0.0], ["Ocean Beach Hospital", [-133.19, -980.76, 10.46], 0.0], - ], - + ], + [ // GTA SA // Coming Soon! - ], - + ], + [ // GTA UG // Coming Soon! - ], - + ], + [ // GTA IV // Police Stations ["Broker Police Station", [894.99, -357.39, 18.185], 2.923], ["South Bohan Police Station", [435.40, 1592.29, 17.353], 3.087], - ["Northern Gardens Police Station", [974.93, 1870.45, 23.073], -1.621], + ["Northern Gardens Police Station", [974.93, 1870.45, 23.073], -1.621], ["South Slopes Police Station", [1233.25, -89.13, 28.034], 1.568], ["Middle Part East Police Station", [50.12, 679.88, 15.316], 1.569], - ["East Holland Police Station", [85.21, 1189.82, 14.755], 3.127], + ["East Holland Police Station", [85.21, 1189.82, 14.755], 3.127], ["Francis International Airport Police Station", [2170.87, 448.87, 6.085], 1.501], ["Chinatown Police Station", [213.12, -211.70, 10.752], 0.200], ["Acter Police Station", [-1714.95, 276.31, 22.134], 1.127], ["Port Tudor Police Station", [-1220.73, -231.53, 3.024], 2.210], - ["Leftwood Police Station", [-927.66, 1263.63, 24.587], -0.913], - + ["Leftwood Police Station", [-927.66, 1263.63, 24.587], -0.913], + // Fire Stations ["Broker Fire Station", [953.13, 95.90, 35.004], 1.595], ["Northwood Fire Station", [-271.02, 1542.15, 20.420], -1.160], @@ -2039,53 +2039,53 @@ let gameData = { ["Chinatown Fire Station", [295.40, -336.88, 4.963], 2.887], ["Berchem Fire Station", [-1574.90, 546.54, 25.449], -0.509], ["Tudor Fire Station", [-2144.97, 164.15, 12.051], -2.149], - + // Safehouses ["Hove Beach Safehouse Parking", [904.27, -498.00, 14.522], 3.127], ["South Bohan Safehouse", [589.42, 1402.15, 10.364], 0.007], - + // Hospitals ["Schottler Medical Center", [1199.59, 196.78, 33.554], 1.633], ["Northern Gardens Medical Center", [980.71, 1831.61, 23.898], -0.049], ["Leftwood Hospital", [-1317.27, 1277.20, 22.370], 2.246], - ["Acter Medical Center", [-1538.43, 344.58, 20.943], -0.156], - + ["Acter Medical Center", [-1538.43, 344.58, 20.943], -0.156], + // Fuel Stations ["Hove Beach Fuel Station", [1128.51, -359.55, 18.441], -0.052], ["Lancaster Fuel Station", [108.37, 1135.13, 13.975], 0.007], - ["The Meat Quarter Fuel Station", [-434.30, -19.47, 9.864], 1.469], + ["The Meat Quarter Fuel Station", [-434.30, -19.47, 9.864], 1.469], ["Cerveza Heights Fuel Station", [1123.50, 328.84, 29.245], -0.154], - ["Tudor Fuel Station", [-1389.91, 29.19, 6.875], 0.982], - + ["Tudor Fuel Station", [-1389.91, 29.19, 6.875], 0.982], + // Restaurants ["Star Junction Burger Shot", [-174.00, 276.96, 14.818], -0.029], ["South Bohan Burger Shot", [441.95, 1516.64, 16.289], -2.682], ["Industrial Burger Shot", [1096.93, 1598.33, 16.721], -2.289], - + // Night Clubs/Strip Clubs/Bars ["Perestroika Club", [957.58, -292.58, 19.644], -0.009], ["Triangle Club", [1210.90, 1718.18, 16.667], 1.819], - + // TW@ Cafes ["Outlook Internet Cafe", [977.42, -169.11, 24.013], 1.844], ["Berchem Internet Cafe", [-1584.46, 466.05, 25.398], -2.441], - + // Pay-n-Sprays ["Hove Beach Pay-n-Spray", [1058.57, -282.58, 20.760], -3.135], ["Leftwood Pay-n-Spray", [-1148.69, 1171.52, 16.457], -0.059], - + // Clothes Shops ["Hove Beach Russian Clothes Shop", [896.31, -442.59, 15.888], 1.500], - + // Car Wash ["Willis Car Wash", [1831.02, 360.20, 22.061], -1.515], ["Tudor Car Wash", [-1371.68, 35.13, 7.028], 1.029], - + // Gun Shops ["Downtown Broker Gun Shop", [1054.11, 86.84, 33.408], -1.574], ["Chinatown Gun Shop", [65.43, -342.36, 14.767], -1.589], - ["Port Tudor Gun Shop", [-1338.77, 307.61, 13.378], -1.530], - + ["Port Tudor Gun Shop", [-1338.77, 307.61, 13.378], -1.530], + // Train Stations ["Hove Beach Train Station", [1000.41, -544.82, 14.854], -1.576], ["Schottler Train Station", [1303.93, -37.75, 28.377], 3.065], @@ -2112,7 +2112,7 @@ let gameData = { ["San Quentin Ave Train Station", [373.12, 1625.93, 16.347], -2.249], ["Windmill Street Train Station", [749.97, 1447.44, 14.252], -0.120], ["Francis International Airport Train Station", [2297.57, 474.62, 6.086], 0.066], - + // Misc ["Hove Beach Laundromat", [1011.74, -325.33, 20.339], -1.402], ["The Exchange Docks", [-354.68, -661.62, 4.791], 2.066], @@ -2122,24 +2122,24 @@ let gameData = { ["Alderney State Correctional Facility", [-1155.21, -374.34, 2.885], -1.680], ["Chinatown Bank of Liberty", [-34.92, -466.80, 14.75], -1.52], ["Suffolk Church", [-274.30, -281.63, 14.36], 1.56], - + // More will be added soon! - ], - + ], + [ // GTA EFLC // Police Stations ["Broker Police Station", [894.99, -357.39, 18.185], 2.923], ["South Bohan Police Station", [435.40, 1592.29, 17.353], 3.087], - ["Northern Gardens Police Station", [974.93, 1870.45, 23.073], -1.621], + ["Northern Gardens Police Station", [974.93, 1870.45, 23.073], -1.621], ["South Slopes Police Station", [1233.25, -89.13, 28.034], 1.568], ["Middle Part East Police Station", [50.12, 679.88, 15.316], 1.569], - ["East Holland Police Station", [85.21, 1189.82, 14.755], 3.127], + ["East Holland Police Station", [85.21, 1189.82, 14.755], 3.127], ["Francis International Airport Police Station", [2170.87, 448.87, 6.085], 1.501], ["Chinatown Police Station", [213.12, -211.70, 10.752], 0.200], ["Acter Police Station", [-1714.95, 276.31, 22.134], 1.127], ["Port Tudor Police Station", [-1220.73, -231.53, 3.024], 2.210], - ["Leftwood Police Station", [-927.66, 1263.63, 24.587], -0.913], - + ["Leftwood Police Station", [-927.66, 1263.63, 24.587], -0.913], + // Fire Stations ["Broker Fire Station", [953.13, 95.90, 35.004], 1.595], ["Northwood Fire Station", [-271.02, 1542.15, 20.420], -1.160], @@ -2148,53 +2148,53 @@ let gameData = { ["Chinatown Fire Station", [295.40, -336.88, 4.963], 2.887], ["Berchem Fire Station", [-1574.90, 546.54, 25.449], -0.509], ["Tudor Fire Station", [-2144.97, 164.15, 12.051], -2.149], - + // Safehouses ["Hove Beach Safehouse Parking", [904.27, -498.00, 14.522], 3.127], ["South Bohan Safehouse", [589.42, 1402.15, 10.364], 0.007], - + // Hospitals ["Schottler Medical Center", [1199.59, 196.78, 33.554], 1.633], ["Northern Gardens Medical Center", [980.71, 1831.61, 23.898], -0.049], ["Leftwood Hospital", [-1317.27, 1277.20, 22.370], 2.246], - ["Acter Medical Center", [-1538.43, 344.58, 20.943], -0.156], - + ["Acter Medical Center", [-1538.43, 344.58, 20.943], -0.156], + // Fuel Stations ["Hove Beach Fuel Station", [1128.51, -359.55, 18.441], -0.052], ["Lancaster Fuel Station", [108.37, 1135.13, 13.975], 0.007], - ["The Meat Quarter Fuel Station", [-434.30, -19.47, 9.864], 1.469], + ["The Meat Quarter Fuel Station", [-434.30, -19.47, 9.864], 1.469], ["Cerveza Heights Fuel Station", [1123.50, 328.84, 29.245], -0.154], - ["Tudor Fuel Station", [-1389.91, 29.19, 6.875], 0.982], - + ["Tudor Fuel Station", [-1389.91, 29.19, 6.875], 0.982], + // Restaurants ["Star Junction Burger Shot", [-174.00, 276.96, 14.818], -0.029], ["South Bohan Burger Shot", [441.95, 1516.64, 16.289], -2.682], ["Industrial Burger Shot", [1096.93, 1598.33, 16.721], -2.289], - + // Night Clubs/Strip Clubs/Bars ["Perestroika Club", [957.58, -292.58, 19.644], -0.009], ["Triangle Club", [1210.90, 1718.18, 16.667], 1.819], - + // TW@ Cafes ["Outlook Internet Cafe", [977.42, -169.11, 24.013], 1.844], ["Berchem Internet Cafe", [-1584.46, 466.05, 25.398], -2.441], - + // Pay-n-Sprays ["Hove Beach Pay-n-Spray", [1058.57, -282.58, 20.760], -3.135], ["Leftwood Pay-n-Spray", [-1148.69, 1171.52, 16.457], -0.059], - + // Clothes Shops ["Hove Beach Russian Clothes Shop", [896.31, -442.59, 15.888], 1.500], - + // Car Wash ["Willis Car Wash", [1831.02, 360.20, 22.061], -1.515], ["Tudor Car Wash", [-1371.68, 35.13, 7.028], 1.029], - + // Gun Shops ["Downtown Broker Gun Shop", [1054.11, 86.84, 33.408], -1.574], ["Chinatown Gun Shop", [65.43, -342.36, 14.767], -1.589], - ["Port Tudor Gun Shop", [-1338.77, 307.61, 13.378], -1.530], - + ["Port Tudor Gun Shop", [-1338.77, 307.61, 13.378], -1.530], + // Train Stations ["Hove Beach Train Station", [1000.41, -544.82, 14.854], -1.576], ["Schottler Train Station", [1303.93, -37.75, 28.377], 3.065], @@ -2221,7 +2221,7 @@ let gameData = { ["San Quentin Ave Train Station", [373.12, 1625.93, 16.347], -2.249], ["Windmill Street Train Station", [749.97, 1447.44, 14.252], -0.120], ["Francis International Airport Train Station", [2297.57, 474.62, 6.086], 0.066], - + // Misc ["Hove Beach Laundromat", [1011.74, -325.33, 20.339], -1.402], ["The Exchange Docks", [-354.68, -661.62, 4.791], 2.066], @@ -2231,9 +2231,9 @@ let gameData = { ["Alderney State Correctional Facility", [-1155.21, -374.34, 2.885], -1.680], ["Chinatown Bank of Liberty", [-34.92, -466.80, 14.75], -1.52], ["Suffolk Church", [-274.30, -281.63, 14.36], 1.56], - + // More will be added soon! - ], + ], ], gtaivSkinModels: [ //["Nico Bellic", 1862763509], @@ -2711,7 +2711,7 @@ let gameData = { ["Cablecar", -960289747], ["Subway", 800869680], ["El Train", -1953988645], - ] + ] }; // --------------------------------------------------------------------------- diff --git a/third-party/mexui/mexui.js b/third-party/mexui/mexui.js index 26119884..094d0a80 100644 --- a/third-party/mexui/mexui.js +++ b/third-party/mexui/mexui.js @@ -43,7 +43,7 @@ mexui.bindEvents = function() { if(isAbsolute) return; - + mexui.triggerEvent('onMouseMove', new Vec2(position.x, position.y), true); }); @@ -55,7 +55,7 @@ mexui.bindEvents = function() addEventHandler('onKeyDown', function(event, key, pkey, mods) { mexui.triggerEvent('onKeyDown', key, mods); - + if(key == SDLK_TAB) { mexui.cycleFocusedControl(); @@ -65,7 +65,7 @@ mexui.bindEvents = function() addEventHandler('onCharacter', function(event, character) { mexui.triggerEvent('onCharacter', character); - + if(character == 't' || character == 'T') { var textInput = mexui.getFocusedTextInput(); @@ -118,10 +118,10 @@ mexui.render = function() mexui.triggerEvent = function(eventName, data, callBaseMethodFirst) { var e = new mexui.Component.Event(); - + if(data.button !== undefined) e.button = data.button; - + var windows = mexui.windows.slice(0, mexui.windows.length).reverse(); for(var i in windows) { @@ -135,7 +135,7 @@ mexui.triggerEvent = function(eventName, data, callBaseMethodFirst) if(e.used) break; } - + windows[i][eventName].call(windows[i], e, data); if(e.used) break; @@ -145,7 +145,7 @@ mexui.triggerEvent = function(eventName, data, callBaseMethodFirst) windows[i][eventName].call(windows[i], e, data); if(e.used) break; - + if(mexui.Entity.Component.prototype[eventName]) { mexui.Entity.Component.prototype[eventName].call(windows[i], e, data); @@ -182,15 +182,15 @@ mexui.getShownWindows = function() mexui.getNextShownWindows = function(afterWindow) { var shownWindows = mexui.getShownWindows(); - + var windowIndex = shownWindows.indexOf(afterWindow); - + var windows2 = shownWindows.splice(0, windowIndex + 1); var args = windows2; args.unshift(0); args.unshift(shownWindows.length); shownWindows.splice.apply(shownWindows, args); - + return shownWindows; }; @@ -199,18 +199,18 @@ mexui.cycleFocusedControl = function() // no windows are created if(mexui.windows.length == 0) return; - + // no control is focused if(!mexui.focusedControl) { var topWindow = mexui.getTopWindow(); if(!topWindow) return; - + mexui.focusedControl = topWindow.getFirstShownControl(); return; } - + // a control is focused var focusedControlWindow = mexui.focusedControl.window; var nextControl = focusedControlWindow.getNextShownControl(mexui.focusedControl); @@ -219,7 +219,7 @@ mexui.cycleFocusedControl = function() mexui.focusedControl = nextControl; return; } - + // set focus to first control on next window that has a control shown var shownWindows = mexui.getNextShownWindows(focusedControlWindow); for(var i in shownWindows) @@ -238,10 +238,10 @@ mexui.getFocusedTextInput = function() { if(!mexui.focusedControl) return null; - + if(!(mexui.focusedControl instanceof mexui.Control.TextInput)) return null; - + return mexui.focusedControl; }; @@ -250,7 +250,7 @@ mexui.toggleTextInputCaretShownForBlink = function() var textInput = mexui.getFocusedTextInput(); if(!textInput) return; - + textInput.caretShownForBlink = !textInput.caretShownForBlink; }; @@ -287,12 +287,12 @@ mexui.isAnyWindowShown = function() mexui.setInput = function(showInput) { gui.showCursor(showInput, !showInput); - if(localPlayer) - { - if(showInput) - gta.setCameraLookAtEntity(new Vec3(gta.cameraMatrix.m41, gta.cameraMatrix.m42, gta.cameraMatrix.m43), localPlayer, false); - else - gta.restoreCamera(false); - } + //if(localPlayer) + //{ + // if(showInput) + // gta.setCameraLookAtEntity(new Vec3(gta.cameraMatrix.m41, gta.cameraMatrix.m42, gta.cameraMatrix.m43), localPlayer, false); + // else + // gta.restoreCamera(false); + //} };