diff --git a/scripts/server/class.js b/scripts/server/class.js index 2d3d7cd1..b86f0978 100644 --- a/scripts/server/class.js +++ b/scripts/server/class.js @@ -96,6 +96,7 @@ function initClassTable() { this.client = client; this.currentSubAccount = -1; this.loggedIn = false; + this.index = -1; this.busRoute = null; this.busRouteStop = null; @@ -217,38 +218,68 @@ function initClassTable() { }, subAccountData: class { constructor(subAccountAssoc) { - if(!subAccountAssoc) { - return; - } + this.databaseId = 0; + this.server = 0; + this.firstName = "John"; + this.lastName = "Doe"; + this.account = 0; + this.skin = 0; + this.cash = 0; + this.placeOfOrigin = ""; + this.dateOfBirth = ""; + this.spawnPosition = toVector3(0.0, 0.0, 0.0); + this.spawnHeading = 0.0; + this.lastLogin = 0; - this.databaseId = subAccountAssoc["sacct_id"]; - this.server = subAccountAssoc["sacct_server"]; - this.firstName = subAccountAssoc["sacct_name_first"]; - this.lastName = subAccountAssoc["sacct_name_last"]; - this.account = subAccountAssoc["sacct_acct"]; - this.skin = subAccountAssoc["sacct_skin"]; - this.cash = subAccountAssoc["sacct_cash"]; - this.placeOfOrigin = subAccountAssoc["sacct_origin"]; - this.dateOfBirth = subAccountAssoc["sacct_when_born"]; - this.spawnPosition = toVector3(subAccountAssoc["sacct_pos_x"], subAccountAssoc["sacct_pos_y"], subAccountAssoc["sacct_pos_z"]); - this.spawnHeading = toFloat(subAccountAssoc["sacct_angle"]); - this.lastLogin = toInteger(subAccountAssoc["sacct_last_login"]); - - this.clan = toInteger(subAccountAssoc["sacct_clan"]); - this.clanFlags = toInteger(subAccountAssoc["sacct_clan_flags"]); - this.clanRank = toInteger(subAccountAssoc["sacct_clan_rank"]); - this.clanTitle = toInteger(subAccountAssoc["sacct_clan_title"]); + this.clan = 0; + this.clanFlags = 0; + this.clanRank = 0; + this.clanTitle = 0; this.isWorking = false; this.jobUniform = this.skin; this.lastJobVehicle = null; - this.job = subAccountAssoc["sacct_job"]; + this.job = 0; this.weapons = []; this.inJail = false; this.interior = 0; this.dimension = 0; + + if(subAccountAssoc) { + this.databaseId = subAccountAssoc["sacct_id"]; + this.server = subAccountAssoc["sacct_server"]; + this.firstName = subAccountAssoc["sacct_name_first"]; + this.lastName = subAccountAssoc["sacct_name_last"]; + this.account = subAccountAssoc["sacct_acct"]; + this.skin = subAccountAssoc["sacct_skin"]; + this.cash = subAccountAssoc["sacct_cash"]; + this.placeOfOrigin = subAccountAssoc["sacct_origin"]; + this.dateOfBirth = subAccountAssoc["sacct_when_born"]; + this.spawnPosition = toVector3(subAccountAssoc["sacct_pos_x"], subAccountAssoc["sacct_pos_y"], subAccountAssoc["sacct_pos_z"]); + this.spawnHeading = toFloat(subAccountAssoc["sacct_angle"]); + this.lastLogin = toInteger(subAccountAssoc["sacct_last_login"]); + + this.clan = toInteger(subAccountAssoc["sacct_clan"]); + this.clanFlags = toInteger(subAccountAssoc["sacct_clan_flags"]); + this.clanRank = toInteger(subAccountAssoc["sacct_clan_rank"]); + this.clanTitle = toInteger(subAccountAssoc["sacct_clan_title"]); + + this.isWorking = false; + this.jobUniform = this.skin; + this.lastJobVehicle = null; + this.job = subAccountAssoc["sacct_job"]; + + this.weapons = []; + this.inJail = false; + + this.interior = subAccountAssoc["sacct_int"]; + this.dimension = subAccountAssoc["sacct_vw"]; + return; + } + + } }, businessData: class { @@ -260,6 +291,7 @@ function initClassTable() { this.buyPrice = 0; this.locked = false; this.hasInterior = false; + this.index = -1; this.entrancePosition = false; this.entranceRotation = 0.0; @@ -311,20 +343,30 @@ function initClassTable() { } }, businessLocationData: class { - constructor(businessLocationAssoc) { - if(!businessLocationAssoc) { - return; + constructor(dbAssoc) { + this.databaseId = 0; + this.name = ""; + this.type = 0; + this.business = 0; + this.enabled = false; + this.index = -1; + + this.position = toVector3(0.0, 0.0, 0.0); + this.interior = 0; + this.dimension = 0; + + if(dbAssoc) { + this.databaseId = toInteger(dbAssoc("biz_loc_id")); + this.name = toString(dbAssoc("biz_loc_name")); + this.type = toInteger(dbAssoc("biz_loc_type")); + this.business = toInteger(dbAssoc("biz_loc_biz")); + this.enabled = intToBool(toInteger(dbAssoc("biz_loc_enabled"))); + this.index = -1; + + this.position = toVector3(toFloat(dbAssoc("biz_loc_pos_x")), toFloat(dbAssoc("biz_loc_pos_y")), toFloat(dbAssoc("biz_loc_pos_z"))); + this.interior = toInteger(dbAssoc["biz_loc_int"]); + this.dimension = toInteger(dbAssoc["biz_loc_vw"]); } - - this.databaseId = toInteger(businessLocationAssoc("biz_loc_id")); - this.name = toString(businessLocationAssoc("biz_loc_name")); - this.type = toInteger(businessLocationAssoc("biz_loc_type")); - this.business = toInteger(businessLocationAssoc("biz_loc_biz")); - this.enabled = intToBool(toInteger(businessLocationAssoc("biz_loc_enabled"))); - - this.position = toVector3(toFloat(businessLocationAssoc("biz_loc_pos_x")), toFloat(businessLocationAssoc("biz_loc_pos_y")), toFloat(businessLocationAssoc("biz_loc_pos_z"))); - this.interior = toInteger(businessLocationAssoc["biz_loc_int"]); - this.dimension = toInteger(businessLocationAssoc["biz_loc_vw"]); } }, houseData: class { @@ -336,6 +378,7 @@ function initClassTable() { this.buyPrice = 0; this.locked = false; this.hasInterior = false; + this.index = -1; this.entrancePosition = false; this.entranceRotation = 0.0; @@ -393,6 +436,7 @@ function initClassTable() { this.server = getServerId(); this.model = (vehicle != false) ? vehicle.modelIndex : 0; this.vehicle = vehicle; + this.index = -1; // Ownership this.ownerType = AG_VEHOWNER_NONE; @@ -511,7 +555,7 @@ function initClassTable() { } }, jobData: class { - constructor(jobAssoc) { + constructor(dbAssoc) { this.databaseId = 0; this.type = AG_JOB_NONE; this.name = "Unnamed"; @@ -521,7 +565,7 @@ function initClassTable() { this.colour = toColour(0, 0, 0, 255); this.whiteListEnabled = false; this.blackListEnabled = false; - this.id = -1; + this.index = -1; this.equipment = []; this.uniforms = []; @@ -529,16 +573,16 @@ function initClassTable() { this.whiteList = []; this.blackList = []; - if(jobAssoc) { - this.databaseId = jobAssoc["job_id"]; - this.type = jobAssoc["job_type"]; - this.name = jobAssoc["job_name"]; - this.enabled = jobAssoc["job_enabled"]; - this.blipModel = jobAssoc["job_blip"]; - this.pickupModel = jobAssoc["job_pickup"]; - 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"]; + if(dbAssoc) { + this.databaseId = dbAssoc["job_id"]; + this.type = dbAssoc["job_type"]; + this.name = dbAssoc["job_name"]; + this.enabled = dbAssoc["job_enabled"]; + this.blipModel = dbAssoc["job_blip"]; + this.pickupModel = dbAssoc["job_pickup"]; + this.colour = toColour(dbAssoc["job_colour_r"], dbAssoc["job_colour_g"], dbAssoc["job_colour_b"], 255); + this.whiteListEnabled = dbAssoc["job_whitelist"]; + this.blackListEnabled = dbAssoc["job_blacklist"]; this.equipment = []; this.uniforms = []; @@ -549,60 +593,63 @@ function initClassTable() { } }, jobEquipmentData: class { - constructor(jobEquipmentAssoc) { + constructor(dbAssoc) { this.databaseId = 0; this.job = 0; this.name = "Unnamed"; this.requiredRank = 0; this.enabled = false; + this.index = -1; - if(jobEquipmentAssoc) { - this.databaseId = jobEquipmentAssoc["job_equip_id"]; - this.job = jobEquipmentAssoc["job_equip_job"]; - this.name = jobEquipmentAssoc["job_equip_name"]; - this.requiredRank = jobEquipmentAssoc["job_equip_minrank"]; - this.enabled = jobEquipmentAssoc["job_equip_enabled"]; + if(dbAssoc) { + this.databaseId = dbAssoc["job_equip_id"]; + this.job = dbAssoc["job_equip_job"]; + this.name = dbAssoc["job_equip_name"]; + this.requiredRank = dbAssoc["job_equip_minrank"]; + this.enabled = dbAssoc["job_equip_enabled"]; } } }, jobEquipmentWeaponData: class { - constructor(jobEquipmentWeaponAssoc) { + constructor(dbAssoc) { this.databaseId = 0; this.equipmentId = 0; this.weaponId = 0; this.ammo = 0; this.enabled = false; + this.index = -1; - if(jobEquipmentWeaponAssoc) { - this.databaseId = jobEquipmentWeaponAssoc["job_equip_wep_id"]; - this.equipmentId = jobEquipmentWeaponAssoc["job_equip_wep_equip"]; - this.weaponId = jobEquipmentWeaponAssoc["job_equip_wep_wep"]; - this.ammo = jobEquipmentWeaponAssoc["job_equip_wep_ammo"]; - this.enabled = jobEquipmentWeaponAssoc["job_equip_wep_enabled"]; + if(dbAssoc) { + this.databaseId = dbAssoc["job_equip_wep_id"]; + this.equipmentId = dbAssoc["job_equip_wep_equip"]; + this.weaponId = dbAssoc["job_equip_wep_wep"]; + this.ammo = dbAssoc["job_equip_wep_ammo"]; + this.enabled = dbAssoc["job_equip_wep_enabled"]; } } }, jobUniformData: class { - constructor(jobUniformAssoc) { + constructor(dbAssoc) { this.databaseId = 0; this.job = 0; this.name = "Unnamed"; this.requiredRank = 0 this.skin = -1; this.enabled = false; + this.index = -1; - if(jobUniformAssoc) { - this.databaseId = jobUniformAssoc["job_uniform_id"]; - this.job = jobUniformAssoc["job_uniform_job"]; - this.name = jobUniformAssoc["job_uniform_name"]; - this.requiredRank = jobUniformAssoc["job_uniform_minrank"]; - this.skin = jobUniformAssoc["job_uniform_skin"]; - this.enabled = jobUniformAssoc["job_uniform_skin"]; + if(dbAssoc) { + this.databaseId = dbAssoc["job_uniform_id"]; + this.job = dbAssoc["job_uniform_job"]; + this.name = dbAssoc["job_uniform_name"]; + this.requiredRank = dbAssoc["job_uniform_minrank"]; + this.skin = dbAssoc["job_uniform_skin"]; + this.enabled = dbAssoc["job_uniform_skin"]; } } }, jobLocationData: class { - constructor(jobLocationAssoc) { + constructor(dbAssoc) { this.databaseId = 0; this.job = 0; this.position = toVector3(0.0, 0.0, 0.0); @@ -611,46 +658,49 @@ function initClassTable() { this.enabled = false; this.interior = 0; this.dimension = 0; + this.index = -1; - if(jobLocationAssoc) { - this.databaseId = jobLocationAssoc["job_loc_id"]; - this.job = jobLocationAssoc["job_loc_job"]; - this.position = toVector3(jobLocationAssoc["job_loc_pos_x"], jobLocationAssoc["job_loc_pos_y"], jobLocationAssoc["job_loc_pos_z"]); + if(dbAssoc) { + this.databaseId = dbAssoc["job_loc_id"]; + this.job = dbAssoc["job_loc_job"]; + this.position = toVector3(dbAssoc["job_loc_pos_x"], dbAssoc["job_loc_pos_y"], dbAssoc["job_loc_pos_z"]); this.blip = false; this.pickup = false; - this.enabled = jobLocationAssoc["job_loc_enabled"]; - this.interior = jobLocationAssoc["job_loc_int"]; - this.dimension = jobLocationAssoc["job_loc_vw"]; + this.enabled = dbAssoc["job_loc_enabled"]; + this.interior = dbAssoc["job_loc_int"]; + this.dimension = dbAssoc["job_loc_vw"]; } } }, jobWhiteListData: class { - constructor(jobWhiteListAssoc) { + constructor(dbAssoc) { this.databaseId = 0; this.job = 0; this.subAccount = 0 this.enabled = false; + this.index = -1; - if(jobWhiteListAssoc) { - this.databaseId = jobWhiteListAssoc["job_wl_id"]; - this.job = jobWhiteListAssoc["job_wl_job"]; - this.subAccount = jobWhiteListAssoc["job_wl_sacct"] - this.enabled = jobWhiteListAssoc["job_wl_enabled"]; + if(dbAssoc) { + this.databaseId = dbAssoc["job_wl_id"]; + this.job = dbAssoc["job_wl_job"]; + this.subAccount = dbAssoc["job_wl_sacct"] + this.enabled = dbAssoc["job_wl_enabled"]; } } }, jobBlackListData: class { - constructor(jobBlackListAssoc) { + constructor(dbAssoc) { this.databaseId = 0; this.job = 0; this.subAccount = 0 this.enabled = false; + this.index = -1; - if(jobBlackListAssoc) { - this.databaseId = jobBlackListAssoc["job_bl_id"]; - this.job = jobBlackListAssoc["job_bl_job"]; - this.subAccount = jobBlackListAssoc["job_bl_sacct"] - this.enabled = jobBlackListAssoc["job_bl_enabled"]; + if(dbAssoc) { + this.databaseId = dbAssoc["job_bl_id"]; + this.job = dbAssoc["job_bl_job"]; + this.subAccount = dbAssoc["job_bl_sacct"] + this.enabled = dbAssoc["job_bl_enabled"]; } } }, @@ -663,39 +713,49 @@ function initClassTable() { this.whenAdded = 0; this.enabled = true; this.keyState = false; + this.index = -1; - if(keyBindAssoc) { - this.databaseId = keyBindAssoc["acct_hotkey_id"]; - this.key = toInteger(keyBindAssoc["acct_hotkey_key"]); - this.account = toInteger(keyBindAssoc["acct_hotkey_acct"]); - this.commandString = keyBindAssoc["acct_hotkey_cmdstr"]; - this.whenAdded = keyBindAssoc["acct_hotkey_when_added"]; - this.enabled = intToBool(keyBindAssoc["acct_hotkey_enabled"]); - this.keyState = intToBool(keyBindAssoc["acct_hotkey_down"]); + if(dbAssoc) { + this.databaseId = dbAssoc["acct_hotkey_id"]; + this.key = toInteger(dbAssoc["acct_hotkey_key"]); + this.account = toInteger(dbAssoc["acct_hotkey_acct"]); + this.commandString = dbAssoc["acct_hotkey_cmdstr"]; + this.whenAdded = dbAssoc["acct_hotkey_when_added"]; + this.enabled = intToBool(dbAssoc["acct_hotkey_enabled"]); + this.keyState = intToBool(dbAssoc["acct_hotkey_down"]); } } }, blackListedGameScriptData: class { constructor(dbAssoc) { - if(!dbAssoc) { - return; + this.databaseId = 0; + this.enabled = false + this.server = 0; + this.scriptName = ""; + this.index = -1; + + if(dbAssoc) { + this.databaseId = dbAssoc["ac_script_bl_id"]; + this.enabled = intToBool(dbAssoc["ac_script_bl_enabled"]); + this.server = dbAssoc["ac_script_bl_server"]; + this.scriptName = dbAssoc["ac_script_bl_name"]; } - this.databaseId = dbAssoc["ac_script_bl_id"]; - this.enabled = intToBool(dbAssoc["ac_script_bl_enabled"]); - this.server = dbAssoc["ac_script_bl_server"]; - this.scriptName = dbAssoc["ac_script_bl_name"]; } }, whiteListedGameScriptData: class { constructor(dbAssoc) { - if(!dbAssoc) { - return; - } + this.databaseId = 0; + this.enabled = false + this.server = 0; + this.scriptName = ""; + this.index = -1; - this.databaseId = dbAssoc["ac_script_wl_id"]; - this.enabled = intToBool(dbAssoc["ac_script_wl_enabled"]); - this.server = dbAssoc["ac_script_wl_server"]; - this.scriptName = dbAssoc["ac_script_wl_name"]; + if(dbAssoc) { + this.databaseId = dbAssoc["ac_script_wl_id"]; + this.enabled = intToBool(dbAssoc["ac_script_wl_enabled"]); + this.server = dbAssoc["ac_script_wl_server"]; + this.scriptName = dbAssoc["ac_script_wl_name"]; + } } }, removedWorldObjectData: class { @@ -706,9 +766,9 @@ function initClassTable() { } }, interiorTemplateData: class { - constructor(exitPosition, interior) { + constructor(exitPosition, exitInterior) { this.exitPosition = exitPosition; - this.interior = interior; + this.exitInterior = exitInterior; } }, } diff --git a/scripts/server/client.js b/scripts/server/client.js index 1f12a7d1..1fa6ef0a 100644 --- a/scripts/server/client.js +++ b/scripts/server/client.js @@ -50,18 +50,8 @@ addNetworkHandler("ag.promptAnswerYes", function(client) { // --------------------------------------------------------------------------- addNetworkHandler("ag.onPlayerEnterSphere", function(client, sphere) { - let ownerType = sphere.getData("ag.ownerType"); - let ownerId = sphere.getData("ag.ownerId"); - - switch(ownerType) { - case AG_PICKUP_JOB: - let jobData = getJobData(ownerId); - showJobInformationToPlayer(client, jobData.jobType); - break; - - default: - break; - } + //let ownerType = getEntityData(sphere, "ag.ownerType"); + //let ownerId = getEntityData(sphere, "ag.ownerId"); }); // --------------------------------------------------------------------------- @@ -76,29 +66,6 @@ addNetworkHandler("ag.afk", function(client, afkState) { // --------------------------------------------------------------------------- -// Not implemented yet -addNetworkHandler("ag.heldKey", function(client, key) { - switch(key) { - case getGlobalConfig().keybinds.actionKey: - processHoldActionKey(client); - break; - - case getGlobalConfig().keybinds.vehicleLightsKey: - processHoldVehicleLightsKey(client); - break; - - case getGlobalConfig().keybinds.vehicleLockKey: - processHoldVehicleLockKey(client); - break; - - case getGlobalConfig().keybinds.vehicleEngineKey: - processHoldVehicleEngineKey(client); - break; - } -}); - -// --------------------------------------------------------------------------- - addNetworkHandler("ag.player.death", function(client, position) { processPlayerDeath(client, position); }); @@ -166,3 +133,21 @@ function showGameMessage(client, text, colour, duration) { // --------------------------------------------------------------------------- +function enableCityAmbienceForPlayer(client) { + triggerNetworkEvent("ag.ambience", client, true); +} + +// --------------------------------------------------------------------------- + +function disableCityAmbienceForPlayer(client) { + triggerNetworkEvent("ag.ambience", client, false); +} + +// --------------------------------------------------------------------------- + +function clearPlayerOwnedPeds(client) { + console.log(`[Asshat.Utilities] Clearing peds owned by ${getPlayerDisplayForConsole(client)}`); + triggerNetworkEvent("ag.clearPeds", client); +} + +// --------------------------------------------------------------------------- \ No newline at end of file diff --git a/scripts/server/command.js b/scripts/server/command.js index 0154e79c..b9b6bec9 100644 --- a/scripts/server/command.js +++ b/scripts/server/command.js @@ -8,281 +8,273 @@ // TYPE: Server (JavaScript) // =========================================================================== -let serverCommands = {}; +let serverCommands = { + account: [ + commandData("login", loginCommand, "", getStaffFlagValue("none"), false, false), + commandData("register", registerCommand, "", getStaffFlagValue("none"), false, false), + commandData("changepass", changePasswordCommand, "", getStaffFlagValue("none"), true, false), + commandData("iplogin", autoLoginByIPCommand, "", getStaffFlagValue("none"), true, false), + commandData("autolastchar", autoSelectLastCharacterCommand, "", getStaffFlagValue("none"), true, false), + commandData("gui", toggleAccountGUICommand, "", getStaffFlagValue("none"), false, false), + commandData("2fa", toggleAccountTwoFactorAuthCommand, "", getStaffFlagValue("none"), true, false), + commandData("setemail", setAccountEmailCommand, "", getStaffFlagValue("none"), true, false), + commandData("setdiscord", setAccountDiscordCommand, "", getStaffFlagValue("none"), true, false), + ], + ammunation: [], + ban: [ + commandData("aban", accountBanCommand, " ", getStaffFlagValue("manageBans"), true, true), + commandData("saban", subAccountBanCommand, " ", getStaffFlagValue("manageBans"), true, true), + commandData("ipban", ipBanCommand, " ", getStaffFlagValue("manageBans"), true, true), + ], + bitFlag: [], + business: [ + commandData("addbiz", createBusinessCommand, "", getStaffFlagValue("manageBusinesses"), true, false), + commandData("delbiz", deleteBusinessCommand, "[id]", getStaffFlagValue("manageBusinesses"), true, true), + commandData("addbizloc", createBusinessLocationCommand, " ", getStaffFlagValue("manageBusinesses"), true, false), + commandData("delbizloc", deleteBusinessLocationCommand, "[id]", getStaffFlagValue("manageBusinesses"), true, false), + commandData("bizreloadall", reloadAllBusinessesCommand, "", getStaffFlagValue("manageBusinesses"), true, false), + + commandData("bizlock", lockBusinessCommand, "", getStaffFlagValue("none"), true, true), + commandData("bizfee", setBusinessEntranceFeeCommand, "", getStaffFlagValue("none"), true, true), + commandData("biztill", viewBusinessTillAmountCommand, "", getStaffFlagValue("none"), true, true), + commandData("bizwithdraw", withdrawFromBusinessCommand, "", getStaffFlagValue("none"), true, true), + commandData("bizdeposit", depositIntoBusinessCommand, "", getStaffFlagValue("none"), true, true), + commandData("bizname", setBusinessNameCommand, "", getStaffFlagValue("none"), true, true), + commandData("bizowner", setBusinessOwnerCommand, "", getStaffFlagValue("none"), true, true), + commandData("bizblip", setBusinessBlipCommand, "", getStaffFlagValue("manageBusinesses"), true, true), + commandData("bizpickup", setBusinessPickupCommand, "", getStaffFlagValue("manageBusinesses"), true, true), + 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), + commandData("do", doActionCommand, "", getStaffFlagValue("none"), true, false), + commandData("s", shoutCommand, "", getStaffFlagValue("none"), true, false), + commandData("shout", shoutCommand, "", getStaffFlagValue("none"), true, false), + commandData("talk", talkCommand, "", getStaffFlagValue("none"), true, false), + 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("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("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), + commandData("clanranktitle", setClanRankTitleCommand, " ", getStaffFlagValue("none"), true, true), + commandData("clanmembertitle", setClanMemberTitleCommand, "<player name/id> <title>", 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), + ], + class: [], + client: [], + colour: [], + command: [ + commandData("cmdenabletype", enableAllCommandsByType, "<type>", getStaffFlagValue("developer"), true, true), + commandData("cmddisabletype", disableAllCommandsByType, "<type>", getStaffFlagValue("developer"), true, true), + commandData("cmdenable", enableCommand, "<command>", getStaffFlagValue("developer"), true, true), + commandData("cmddisable", disableCommand, "<command>", getStaffFlagValue("developer"), true, true), + ], + config: [ + 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("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), + ], + core: [], + database: [], + developer: [ + 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), + commandData("docmd", simulateCommandForPlayer, "<player name/id> <command> [params]", getStaffFlagValue("developer"), true, true), + commandData("docmdall", simulateCommandForAllPlayers, "<command> [params]", getStaffFlagValue("developer"), true, true), + ], + discord: [], + faction: [], + help: [ + commandData("help", helpCommand, "", getStaffFlagValue("none"), false, false), + ], + house: [ + commandData("addhouse", createHouseCommand, "<description>", getStaffFlagValue("manageHouses"), true, false), + commandData("delhouse", deleteHouseCommand, "", getStaffFlagValue("manageHouses"), true, false), + commandData("housereloadall", reloadAllHousesCommand, "", getStaffFlagValue("manageHouses"), true, false), + + commandData("houseinfo", getHouseInfoCommand, "", getStaffFlagValue("none"), true, false), + commandData("housedesc", setHouseDescriptionCommand, "", getStaffFlagValue("none"), true, false), + commandData("houselock", lockUnlockHouseCommand, "", getStaffFlagValue("none"), true, false), + commandData("houseowner", setHouseOwnerCommand, "", getStaffFlagValue("none"), true, false), + commandData("houseblip", setHouseBlipCommand, "<type name/model id>", getStaffFlagValue("manageHouses"), true, true), + 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("houseinttype", setHouseInteriorTypeCommand, "<interior template name/business id>", getStaffFlagValue("manageHouses"), true, true), + ], + item: [], + job: [ + commandData("takejob", takeJobCommand, "", getStaffFlagValue("none"), true, false), + 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("quitjob", quitJobCommand, "", getStaffFlagValue("none"), true, false), + commandData("uniform", jobUniformCommand, "[uniform]", getStaffFlagValue("none"), true, false), + commandData("equip", jobEquipmentCommand, "[equipment]", getStaffFlagValue("none"), true, false), + + commandData("radio", jobRadioCommand, "", getStaffFlagValue("none"), true, false), + commandData("r", jobRadioCommand, "", getStaffFlagValue("none"), true, false), + commandData("department", jobDepartmentRadioCommand, "", getStaffFlagValue("none"), true, false), + commandData("d", jobDepartmentRadioCommand, "", getStaffFlagValue("none"), true, false), + + // Taxi + commandData("fare", taxiSetFareCommand, "", getStaffFlagValue("none"), true, false), + + // Police + commandData("tazer", policeTazerCommand, "", getStaffFlagValue("none"), true, false), + commandData("cuff", policeCuffCommand, "", getStaffFlagValue("none"), true, false), + 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), + + // Admin Job Stuff + commandData("addjobloc", createJobLocationCommand, "<job name/id>", getStaffFlagValue("manageJobs"), true, false), + commandData("deljobloc", deleteJobLocationCommand, "", getStaffFlagValue("manageJobs"), true, false), + //commandData("jobloctoggle", toggleJobLocationCommand, "", getStaffFlagValue("manageJobs"), true, false), + commandData("jobwhitelist", toggleJobWhiteListCommand, "[job id]", getStaffFlagValue("manageJobs"), true, false), + commandData("jobblacklist", toggleJobBlackListCommand, "[job id]", getStaffFlagValue("manageJobs"), true, false), + commandData("jobtoggle", toggleJobEnabledCommand, "[job id]", getStaffFlagValue("manageJobs"), true, false), + commandData("jobaddplayerwl", addPlayerToJobWhiteListCommand, "<player name/id> [job id]", getStaffFlagValue("manageJobs"), true, false), + commandData("jobaddplayerbl", addPlayerToJobBlackListCommand, "<player name/id> [job id]", getStaffFlagValue("manageJobs"), true, false), + commandData("jobdelplayerbl", removePlayerFromJobBlackListCommand, "<player name/id> [job id]", getStaffFlagValue("manageJobs"), true, false), + commandData("jobdelplayerbl", removePlayerFromJobWhiteListCommand, "<player name/id> [job id]", getStaffFlagValue("manageJobs"), true, false), + commandData("jobreloadall", reloadAllJobsCommand, "", getStaffFlagValue("manageJobs"), true, false), + ], + keybind: [ + commandData("bindkey", addKeyBindCommand, "<key id/name> <command> [params]", getStaffFlagValue("none"), true, false), + commandData("unbindkey", removeKeyBindCommand, "<key id/name>", getStaffFlagValue("none"), true, false), + //commandData("keybinds", showKeyBindCommands, "", getStaffFlagValue("none"), true, false), + ], + locale: [], + messaging: [], + misc: [ + commandData("pos", getPositionCommand, "", getStaffFlagValue("basicModeration"), true, false), + commandData("idea", submitIdeaCommand, "<message>", getStaffFlagValue("none"), true, true), + commandData("bug", submitBugReportCommand, "<message>", getStaffFlagValue("none"), true, true), + commandData("enter", enterExitPropertyCommand, "", getStaffFlagValue("none"), true, true), + commandData("exit", enterExitPropertyCommand, "", getStaffFlagValue("none"), true, false), + commandData("cursor", toggleMouseCursorCommand, "", getStaffFlagValue("none"), true, false), + commandData("mousecam", toggleMouseCameraCommand, "", getStaffFlagValue("none"), true, false), + ], + moderation: [ + commandData("kick", kickClientCommand, "<player name/id> [reason]", getStaffFlagValue("basicModeration"), true, true), + 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("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("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), + commandData("clearstaffflags", clearStaffFlagsCommand, "<player name/id>", getStaffFlagValue("manageAdmins"), true, true), + commandData("staffflags", allStaffFlagsCommand, "", getStaffFlagValue("manageAdmins"), true, true), + + commandData("givemoney", givePlayerMoneyCommand, "<player name/id> <amount>", getStaffFlagValue("giveMoney"), true, true), + ], + security: [], + startup: [], + 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), + ], + translate: [], + utilities: [], + vehicle: [ + 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("vehowner", setVehicleOwnerCommand, "<player id/name>", getStaffFlagValue("manageVehicles"), true, true), + commandData("vehclan", setVehicleClanCommand, "<clan id/name>", getStaffFlagValue("manageVehicles"), true, true), + commandData("vehbiz", setVehicleToBusinessCommand, "", getStaffFlagValue("manageVehicles"), true, true), + commandData("vehjob", setVehicleJobCommand, "[job id/name]", getStaffFlagValue("manageVehicles"), true, true), + commandData("vehdelowner", removeVehicleOwnerCommand, "", getStaffFlagValue("manageVehicles"), true, true), + commandData("vehrank", setVehicleRankCommand, "<rank id/name>", getStaffFlagValue("none"), true, true), + + commandData("vehinfo", getVehicleInfoCommand, "", getStaffFlagValue("none"), true, true), + commandData("vehpark", toggleVehicleSpawnLockCommand, "", getStaffFlagValue("manageVehicles"), true, true), + commandData("vehrespawnall", respawnAllVehiclesCommand, "", getStaffFlagValue("manageVehicles"), true, true), + commandData("vehreloadall", reloadAllVehiclesCommand, "", getStaffFlagValue("manageVehicles"), true, true), + + commandData("vehrent", rentVehicleCommand, "", getStaffFlagValue("none"), true, true), + commandData("vehrentprice", setVehicleRentPriceCommand, "", getStaffFlagValue("none"), true, true), + commandData("vehbuyprice", setVehicleBuyPriceCommand, "", getStaffFlagValue("none"), true, true), + commandData("stoprent", stopRentingVehicleCommand, "", getStaffFlagValue("none"), true, true), + commandData("vehbuy", buyVehicleCommand, "", getStaffFlagValue("none"), true, true), + commandData("vehcolour", setVehicleColourCommand, "<colour1> <colour2>", getStaffFlagValue("none"), true, true), + commandData("vehrepair", vehicleRepairCommand, "", getStaffFlagValue("none"), true, true), + commandData("passenger", enterVehicleAsPassengerCommand, "", getStaffFlagValue("none"), true, true), + + ], +}; // --------------------------------------------------------------------------- function initCommandScript() { console.log("[Asshat.Command]: Initializing commands script ..."); - serverCommands = loadCommandData(); console.log("[Asshat.Command]: Initialized commands script!"); } // --------------------------------------------------------------------------- -function loadCommandData() { - let tempCommands = { - account: [ - commandData("login", loginCommand, "<password>", getStaffFlagValue("none"), false, false), - commandData("register", registerCommand, "<password>", getStaffFlagValue("none"), false, false), - commandData("changepass", changePasswordCommand, "<password>", getStaffFlagValue("none"), true, false), - commandData("iplogin", autoLoginByIPCommand, "", getStaffFlagValue("none"), true, false), - commandData("autolastchar", autoSelectLastCharacterCommand, "", getStaffFlagValue("none"), true, false), - commandData("gui", toggleAccountGUICommand, "", getStaffFlagValue("none"), false, false), - commandData("2fa", toggleAccountTwoFactorAuthCommand, "", getStaffFlagValue("none"), true, false), - commandData("setemail", setAccountEmailCommand, "<email address>", getStaffFlagValue("none"), true, false), - commandData("setdiscord", setAccountDiscordCommand, "<Name#0000 - discord name and id>", getStaffFlagValue("none"), true, false), - ], - ammunation: [], - ban: [ - commandData("aban", accountBanCommand, "<player name/id> <reason>", getStaffFlagValue("manageBans"), true, true), - commandData("saban", subAccountBanCommand, "<player name/id> <reason>", getStaffFlagValue("manageBans"), true, true), - commandData("ipban", ipBanCommand, "<player name/id> <reason>", getStaffFlagValue("manageBans"), true, true), - ], - bitFlag: [], - business: [ - commandData("addbiz", createBusinessCommand, "<name>", getStaffFlagValue("manageBusinesses"), true, false), - commandData("delbiz", deleteBusinessCommand, "[id]", getStaffFlagValue("manageBusinesses"), true, true), - commandData("addbizloc", createBusinessLocationCommand, "<type> <business id> <name>", getStaffFlagValue("manageBusinesses"), true, false), - commandData("delbizloc", deleteBusinessLocationCommand, "[id]", getStaffFlagValue("manageBusinesses"), true, false), - commandData("bizreloadall", reloadAllBusinessesCommand, "", getStaffFlagValue("manageBusinesses"), true, false), - - commandData("bizlock", lockBusinessCommand, "", getStaffFlagValue("none"), true, true), - commandData("bizfee", setBusinessEntranceFeeCommand, "<amount>", getStaffFlagValue("none"), true, true), - commandData("biztill", viewBusinessTillAmountCommand, "", getStaffFlagValue("none"), true, true), - commandData("bizwithdraw", withdrawFromBusinessCommand, "<amount>", getStaffFlagValue("none"), true, true), - commandData("bizdeposit", depositIntoBusinessCommand, "<amount>", getStaffFlagValue("none"), true, true), - commandData("bizname", setBusinessNameCommand, "<name>", getStaffFlagValue("none"), true, true), - commandData("bizowner", setBusinessOwnerCommand, "<player name/id>", getStaffFlagValue("none"), true, true), - commandData("bizblip", setBusinessBlipCommand, "<type name/model id>", getStaffFlagValue("manageBusinesses"), true, true), - commandData("bizpickup", setBusinessPickupCommand, "<type name/model id>", getStaffFlagValue("manageBusinesses"), true, true), - 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, "<interior template name/business id>", getStaffFlagValue("manageBusinesses"), true, true), - ], - chat: [ - commandData("me", meActionCommand, "<message>", getStaffFlagValue("none"), true, false), - commandData("do", doActionCommand, "<message>", getStaffFlagValue("none"), true, false), - commandData("s", shoutCommand, "<message>", getStaffFlagValue("none"), true, false), - commandData("shout", shoutCommand, "<message>", getStaffFlagValue("none"), true, false), - commandData("talk", talkCommand, "<message>", getStaffFlagValue("none"), true, false), - commandData("local", talkCommand, "<message>", getStaffFlagValue("none"), true, false), - commandData("l", talkCommand, "<message>", getStaffFlagValue("none"), true, false), - commandData("w", whisperCommand, "<message>", getStaffFlagValue("none"), true, false), - commandData("whisper", whisperCommand, "<message>", getStaffFlagValue("none"), true, false), - commandData("clanchat", clanChatCommand, "<message>", getStaffFlagValue("none"), true, false), - commandData("clan", clanChatCommand, "<message>", getStaffFlagValue("none"), true, false), - commandData("c", clanChatCommand, "<message>", getStaffFlagValue("none"), true, false), - commandData("adminchat", adminChatCommand, "<message>", getStaffFlagValue("basicModeration"), true, true), - commandData("a", adminChatCommand, "<message>", getStaffFlagValue("basicModeration"), true, true), - commandData("achat", adminChatCommand, "<message>", getStaffFlagValue("basicModeration"), true, true), - ], - clan: [ - commandData("addclan", createClanCommand, "<name>", getStaffFlagValue("manageClans"), true, true), - commandData("delclan", deleteClanCommand, "<clan id>", getStaffFlagValue("manageClans"), true, true), - - commandData("clanowner", setClanOwnerCommand, "<clan id> <player name/id>", getStaffFlagValue("none"), true, true), - commandData("clantag", setClanTagCommand, "<tag>", getStaffFlagValue("none"), true, true), - commandData("clanranktag", setClanRankTagCommand, "<rank id> <tag>", getStaffFlagValue("none"), true, true), - commandData("clanmembertag", setClanMemberTagCommand, "<player name/id> <tag>", getStaffFlagValue("none"), true, true), - commandData("clanranktitle", setClanRankTitleCommand, "<rank id> <title>", getStaffFlagValue("none"), true, true), - commandData("clanmembertitle", setClanMemberTitleCommand, "<player name/id> <title>", 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), - ], - class: [], - client: [], - colour: [], - command: [ - commandData("cmdenabletype", enableAllCommandsByType, "<type>", getStaffFlagValue("developer"), true, true), - commandData("cmddisabletype", disableAllCommandsByType, "<type>", getStaffFlagValue("developer"), true, true), - commandData("cmdenable", enableCommand, "<command>", getStaffFlagValue("developer"), true, true), - commandData("cmddisable", disableCommand, "<command>", getStaffFlagValue("developer"), true, true), - ], - config: [ - 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("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), - ], - core: [], - database: [], - developer: [ - 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), - commandData("docmd", simulateCommandForPlayer, "<player name/id> <command> [params]", getStaffFlagValue("developer"), true, true), - commandData("docmdall", simulateCommandForAllPlayers, "<command> [params]", getStaffFlagValue("developer"), true, true), - ], - discord: [], - faction: [], - help: [ - commandData("help", helpCommand, "", getStaffFlagValue("none"), false, false), - ], - house: [ - commandData("addhouse", createHouseCommand, "<description>", getStaffFlagValue("manageHouses"), true, false), - commandData("delhouse", deleteHouseCommand, "", getStaffFlagValue("manageHouses"), true, false), - commandData("housereloadall", reloadAllHousesCommand, "", getStaffFlagValue("manageHouses"), true, false), - - commandData("houseinfo", getHouseInfoCommand, "", getStaffFlagValue("none"), true, false), - commandData("housedesc", setHouseDescriptionCommand, "", getStaffFlagValue("none"), true, false), - commandData("houselock", lockUnlockHouseCommand, "", getStaffFlagValue("none"), true, false), - commandData("houseowner", setHouseOwnerCommand, "", getStaffFlagValue("none"), true, false), - commandData("houseblip", setHouseBlipCommand, "<type name/model id>", getStaffFlagValue("manageHouses"), true, true), - 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("houseinttype", setHouseInteriorTypeCommand, "<interior template name/business id>", getStaffFlagValue("manageHouses"), true, true), - ], - item: [], - job: [ - commandData("takejob", takeJobCommand, "", getStaffFlagValue("none"), true, false), - 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("quitjob", quitJobCommand, "", getStaffFlagValue("none"), true, false), - commandData("uniform", jobUniformCommand, "[uniform]", getStaffFlagValue("none"), true, false), - commandData("equip", jobEquipmentCommand, "[equipment]", getStaffFlagValue("none"), true, false), - - commandData("radio", jobRadioCommand, "", getStaffFlagValue("none"), true, false), - commandData("r", jobRadioCommand, "", getStaffFlagValue("none"), true, false), - commandData("department", jobDepartmentRadioCommand, "", getStaffFlagValue("none"), true, false), - commandData("d", jobDepartmentRadioCommand, "", getStaffFlagValue("none"), true, false), - - // Taxi - commandData("fare", taxiSetFareCommand, "", getStaffFlagValue("none"), true, false), - - // Police - commandData("tazer", policeTazerCommand, "", getStaffFlagValue("none"), true, false), - commandData("cuff", policeCuffCommand, "", getStaffFlagValue("none"), true, false), - 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), - - // Admin Job Stuff - commandData("addjobloc", createJobLocationCommand, "<job name/id>", getStaffFlagValue("manageJobs"), true, false), - commandData("deljobloc", deleteJobLocationCommand, "", getStaffFlagValue("manageJobs"), true, false), - //commandData("jobloctoggle", toggleJobLocationCommand, "", getStaffFlagValue("manageJobs"), true, false), - commandData("jobwhitelist", toggleJobWhiteListCommand, "[job id]", getStaffFlagValue("manageJobs"), true, false), - commandData("jobblacklist", toggleJobBlackListCommand, "[job id]", getStaffFlagValue("manageJobs"), true, false), - commandData("jobtoggle", toggleJobEnabledCommand, "[job id]", getStaffFlagValue("manageJobs"), true, false), - commandData("jobaddplayerwl", addPlayerToJobWhiteListCommand, "<player name/id> [job id]", getStaffFlagValue("manageJobs"), true, false), - commandData("jobaddplayerbl", addPlayerToJobBlackListCommand, "<player name/id> [job id]", getStaffFlagValue("manageJobs"), true, false), - commandData("jobdelplayerbl", removePlayerFromJobBlackListCommand, "<player name/id> [job id]", getStaffFlagValue("manageJobs"), true, false), - commandData("jobdelplayerbl", removePlayerFromJobWhiteListCommand, "<player name/id> [job id]", getStaffFlagValue("manageJobs"), true, false), - commandData("jobreloadall", reloadAllJobsCommand, "", getStaffFlagValue("manageJobs"), true, false), - ], - keybind: [ - commandData("bindkey", addKeyBindCommand, "<key id/name> <command> [params]", getStaffFlagValue("none"), true, false), - commandData("unbindkey", removeKeyBindCommand, "<key id/name>", getStaffFlagValue("none"), true, false), - //commandData("keybinds", showKeyBindCommands, "", getStaffFlagValue("none"), true, false), - ], - locale: [], - messaging: [], - misc: [ - commandData("pos", getPositionCommand, "", getStaffFlagValue("basicModeration"), true, false), - commandData("idea", submitIdeaCommand, "<message>", getStaffFlagValue("none"), true, true), - commandData("bug", submitBugReportCommand, "<message>", getStaffFlagValue("none"), true, true), - commandData("enter", enterExitPropertyCommand, "", getStaffFlagValue("none"), true, true), - commandData("exit", enterExitPropertyCommand, "", getStaffFlagValue("none"), true, false), - commandData("cursor", toggleMouseCursorCommand, "", getStaffFlagValue("none"), true, false), - commandData("mousecam", toggleMouseCameraCommand, "", getStaffFlagValue("none"), true, false), - ], - moderation: [ - commandData("kick", kickClientCommand, "<player name/id> [reason]", getStaffFlagValue("basicModeration"), true, true), - 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("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("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), - commandData("clearstaffflags", clearStaffFlagsCommand, "<player name/id>", getStaffFlagValue("manageAdmins"), true, true), - commandData("staffflags", allStaffFlagsCommand, "", getStaffFlagValue("manageAdmins"), true, true), - - commandData("givemoney", givePlayerMoneyCommand, "<player name/id> <amount>", getStaffFlagValue("giveMoney"), true, true), - ], - security: [], - startup: [], - 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), - ], - translate: [], - utilities: [], - vehicle: [ - 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("vehowner", setVehicleOwnerCommand, "<player id/name>", getStaffFlagValue("manageVehicles"), true, true), - commandData("vehclan", setVehicleClanCommand, "<clan id/name>", getStaffFlagValue("manageVehicles"), true, true), - commandData("vehbiz", setVehicleToBusinessCommand, "", getStaffFlagValue("manageVehicles"), true, true), - commandData("vehjob", setVehicleJobCommand, "[job id/name]", getStaffFlagValue("manageVehicles"), true, true), - commandData("vehdelowner", removeVehicleOwnerCommand, "", getStaffFlagValue("manageVehicles"), true, true), - commandData("vehrank", setVehicleRankCommand, "<rank id/name>", getStaffFlagValue("none"), true, true), - - commandData("vehinfo", getVehicleInfoCommand, "", getStaffFlagValue("none"), true, true), - commandData("vehpark", toggleVehicleSpawnLockCommand, "", getStaffFlagValue("manageVehicles"), true, true), - commandData("vehrespawnall", respawnAllVehiclesCommand, "", getStaffFlagValue("manageVehicles"), true, true), - commandData("vehreloadall", reloadAllVehiclesCommand, "", getStaffFlagValue("manageVehicles"), true, true), - - commandData("vehrent", rentVehicleCommand, "", getStaffFlagValue("none"), true, true), - commandData("vehrentprice", setVehicleRentPriceCommand, "", getStaffFlagValue("none"), true, true), - commandData("vehbuyprice", setVehicleBuyPriceCommand, "", getStaffFlagValue("none"), true, true), - commandData("stoprent", stopRentingVehicleCommand, "", getStaffFlagValue("none"), true, true), - commandData("vehbuy", buyVehicleCommand, "", getStaffFlagValue("none"), true, true), - commandData("vehcolour", setVehicleColourCommand, "<colour1> <colour2>", getStaffFlagValue("none"), true, true), - commandData("vehrepair", vehicleRepairCommand, "", getStaffFlagValue("none"), true, true), - commandData("passenger", enterVehicleAsPassengerCommand, "", getStaffFlagValue("none"), true, true), - - ], - } - return tempCommands; -} - -// --------------------------------------------------------------------------- - function getCommand(command) { let commandGroups = getCommands() for(let i in commandGroups) { @@ -422,14 +414,25 @@ function enableAllCommandsByType(command, params, client) { // --------------------------------------------------------------------------- function onPlayerCommand(event, client, command, params) { - let commandData = getCommand(command); + processPlayerCommand(command, params, client) +} +addEventHandler("OnPlayerCommand", onPlayerCommand); + +// --------------------------------------------------------------------------- + +function processPlayerCommand(command, params, client) { + if(builtInCommands.indexOf(toLowerCase(command)) != -1) { + return true; + } + + let commandData = getCommand(toLowerCase(command)); let paramsDisplay = params; if(areParamsEmpty(params)) { - paramsDisplay = "" + paramsDisplay = ""; } - if(!commandData) { + if(!doesCommandExist(toLowerCase(command))) { console.warn(`[Asshat.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (invalid command): /${command} ${paramsDisplay}`); messagePlayerError(client, `The command [#AAAAAA]/${command} [#FFFFFF]does not exist! Use /help for commands and information.`); return false; @@ -441,7 +444,7 @@ function onPlayerCommand(event, client, command, params) { return false; } - if(doesCommandRequireLogin(command)) { + if(doesCommandRequireLogin(toLowerCase(command))) { if(!isPlayerLoggedIn(client)) { console.warn(`[Asshat.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (requires login first): /${command} ${paramsDisplay}`); messagePlayerError(client, `You must be logged in to use the [#AAAAAA]/${command} [#FFFFFF]command!`); @@ -457,16 +460,15 @@ function onPlayerCommand(event, client, command, params) { // } //} - if(!doesPlayerHaveStaffPermission(client, getCommandRequiredPermissions(command))) { + if(!doesPlayerHaveStaffPermission(client, getCommandRequiredPermissions(toLowerCase(command)))) { console.warn(`[Asshat.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (no permission): /${command} ${paramsDisplay}`); - messagePlayerError(client, `You do not have permission to use the [#AAAAAA]/${command} [#FFFFFF]command!`); + messagePlayerError(client, `You do not have permission to use the [#AAAAAA]/${toLowerCase(command)} [#FFFFFF]command!`); return false; } console.log(`[Asshat.Command] ${getPlayerDisplayForConsole(client)} used command: /${command} ${paramsDisplay}`); - commandData.handlerFunction(command, params, client); + commandData.handlerFunction(toLowerCase(command), params, client); } -addEventHandler("OnPlayerCommand", onPlayerCommand); // --------------------------------------------------------------------------- @@ -492,4 +494,14 @@ function listAllCommands() { } } +// --------------------------------------------------------------------------- + +function doesCommandExist(command) { + if(getCommandData(command)) { + return true; + } + + return false; +} + // --------------------------------------------------------------------------- \ No newline at end of file diff --git a/scripts/server/developer.js b/scripts/server/developer.js index 044c3714..01018892 100644 --- a/scripts/server/developer.js +++ b/scripts/server/developer.js @@ -10,6 +10,13 @@ function initDeveloperScript() { console.log("[Asshat.Developer]: Initializing developer script ..."); + + // Use GTAC command handlers for these since they need to be available on console + addCommandHandler("sc", executeServerCodeCommand); + addCommandHandler("cc", executeServerCodeCommand); + addCommandHandler("docmd", simulateCommandForPlayer); + addCommandHandler("allcmd", simulateCommandForAllPlayers); + console.log("[Asshat.Developer]: Developer script initialized successfully!"); return true; } diff --git a/scripts/server/discord.js b/scripts/server/discord.js index 9fc23e7b..06abf977 100644 --- a/scripts/server/discord.js +++ b/scripts/server/discord.js @@ -8,6 +8,7 @@ // TYPE: Server (JavaScript) // =========================================================================== +/* addEventHandler("OnDiscordCommand", function(command, params, discordUser) { let commandData = getCommand(command); @@ -28,6 +29,7 @@ addEventHandler("OnDiscordCommand", function(command, params, discordUser) { commandData.handlerFunction(command, params, discordUser); }); +*/ // --------------------------------------------------------------------------- diff --git a/scripts/server/event.js b/scripts/server/event.js index e28c54aa..dd7f1e94 100644 --- a/scripts/server/event.js +++ b/scripts/server/event.js @@ -253,7 +253,7 @@ function processPlayerDeath(client, position) { function processPedSpawn(ped) { if(ped.type == ELEMENT_PLAYER) { - setTimeout(processPlayerSpawn, 1000, ped); + setTimeout(processPlayerSpawn, 500, ped); } } @@ -272,7 +272,7 @@ function processPlayerSpawn(ped) { return false; } - if(!getPlayerData(client).switchingCharacter) { + if(!isPlayerSwitchingCharacter(client)) { return false; } @@ -289,9 +289,7 @@ function processPlayerSpawn(ped) { setPlayerHeading(client, tempSubAccount.spawnHeading); setPlayerInterior(client, tempSubAccount.interior); setPlayerVirtualWorld(client, tempSubAccount.dimension); - setTimeout(function() { - updatePlayerCash(client); - }, 1000); + updatePlayerCash(client); }, 500); updateAllPlayerNameTags(); @@ -300,4 +298,10 @@ function processPlayerSpawn(ped) { triggerNetworkEvent("ag.jobType", client, tempSubAccount.job); } +// --------------------------------------------------------------------------- + +addEventHandler("OnPedSpawn", function(event, ped) { + processPedSpawn(ped); +}); + // --------------------------------------------------------------------------- \ No newline at end of file diff --git a/scripts/server/house.js b/scripts/server/house.js index 0784574d..fd34cc01 100644 --- a/scripts/server/house.js +++ b/scripts/server/house.js @@ -13,6 +13,8 @@ function initHouseScript() { getServerData().houses = loadHousesFromDatabase(); createAllHousePickups(); createAllHouseBlips(); + + setAllHouseIndexes(); console.log("[Asshat.House]: House script initialized successfully!"); return true; } @@ -697,4 +699,12 @@ function exitHouse(client) { removeEntityData(client, "ag.inHouse"); } +// --------------------------------------------------------------------------- + +function setAllHouseIndexes() { + for(let i in getServerData().houses) { + getServerData().houses[i].index = i; + } +} + // --------------------------------------------------------------------------- \ No newline at end of file diff --git a/scripts/server/job.js b/scripts/server/job.js index d7255764..cc63d963 100644 --- a/scripts/server/job.js +++ b/scripts/server/job.js @@ -709,18 +709,19 @@ function takeJob(client, jobId) { // --------------------------------------------------------------------------- function reloadAllJobsCommand(command, params, client) { - for(let i in getServerData().jobs) { - for(let j in getServerData().jobs[i].locations) { - destroyElement(getServerData().jobs[i].locations[j].blip); - destroyElement(getServerData().jobs[i].locations[j].pickup); - } - } + forceAllPlayersToStopWorking(); - //forceAllPlayersToStopWorking(); getServerData().jobs = null; getServerData().jobs = loadJobsFromDatabase(); - createAllJobPickups(); - createAllJobBlips(); + + for(let i in getServerData().jobs) { + for(let j in getServerData().jobs[i].locations) { + deleteJobLocationPickup(i, j); + deleteJobLocationBlip(i, j); + createJobLocationPickup(i, j); + createJobLocationBlip(i, j); + } + } messageAdminAction(`All server jobs have been reloaded by an admin!`); } @@ -753,6 +754,7 @@ function deleteJobLocationCommand(command, params, client) { messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]deleted location [#AAAAAA]${closestJobLocation.databaseId} [#FFFFFF]for the [#AAAAAA]${jobData.name} [#FFFFFF]job`); + quickDatabaseQuery(`DELETE FROM job_loc WHERE job_loc_id = ${closestJobLocation.databaseId}`); deleteJobLocation(closestJobLocation); getJobData(closestJobLocation.job).locations.splice(getClosestJobLocation.index, 1); } @@ -1237,7 +1239,7 @@ function setAllJobDataIndexes() { // --------------------------------------------------------------------------- function createJobLocation(job, position, interior, dimension) { - let jobLocationData = serverClasses.jobLocationData(false); + let jobLocationData = new serverClasses.jobLocationData(false); jobLocationData.position = position; jobLocationData.job = job; jobLocationData.interior = interior; @@ -1416,4 +1418,61 @@ function saveAllJobsToDatabase() { } } +// --------------------------------------------------------------------------- + +function deleteJobLocationBlip(jobId, locationId) { + if(getJobData(jobId).locations[locationId].blip != null) { + removeFromWorld(getJobData(jobId).locations[locationId].blip); + destroyElement(getJobData(jobId).locations[locationId].blip); + getJobData(jobId).locations[locationId].blip = null; + } +} + +// --------------------------------------------------------------------------- + +function deleteJobLocationPickup(jobId, locationId) { + if(getJobData(jobId).locations[locationId].pickup != null) { + removeFromWorld(getJobData(jobId).locations[locationId].pickup); + destroyElement(getJobData(jobId).locations[locationId].pickup); + getJobData(jobId).locations[locationId].pickup = null; + } +} + +// --------------------------------------------------------------------------- + +function createJobLocationPickup(jobId, locationId) { + if(getJobData(jobId).pickupModel != -1) { + let pickupModelId = getGameConfig().pickupModels[getServerGame()].job; + + if(getJobData(jobId).pickupModel != 0) { + pickupModelId = getJobData(jobId).pickupModel; + } + + getJobData(jobId).locations[locationId].pickup = gta.createPickup(pickupModelId, getJobData(jobId).locations[locationId].position); + getJobData(jobId).locations[locationId].pickup.onAllDimensions = false; + getJobData(jobId).locations[locationId].pickup.dimension = getJobData(jobId).locations[locationId].dimension; + getJobData(jobId).locations[locationId].pickup.setData("ag.owner.type", AG_PICKUP_JOB, false); + getJobData(jobId).locations[locationId].pickup.setData("ag.owner.id", jobId, false); + getJobData(jobId).locations[locationId].pickup.setData("ag.label.type", AG_LABEL_JOB, true); + addToWorld(getJobData(jobId).locations[locationId].pickup); + } +} + +// --------------------------------------------------------------------------- + +function createJobLocationBlip(jobId, locationId) { + if(getJobData(jobId).blipModel != -1) { + let blipModelId = getGameConfig().blipSprites[getServerGame()].job; + + if(getJobData(jobId).blipModel != 0) { + blipModelId = getJobData(jobId).blipModel; + } + + getJobData(jobId).locations[locationId].blip = gta.createBlip(getJobData(jobId).locations[locationId].position, blipModelId, getColourByType("job")); + getJobData(jobId).locations[locationId].pickup.onAllDimensions = false; + getJobData(jobId).locations[locationId].pickup.dimension = getJobData(jobId).locations[locationId].dimension; + addToWorld(getJobData(jobId).locations[locationId].pickup); + } +} + // --------------------------------------------------------------------------- \ No newline at end of file diff --git a/scripts/server/job/bus.js b/scripts/server/job/bus.js index 9cff5e2c..f0a7a2a0 100644 --- a/scripts/server/job/bus.js +++ b/scripts/server/job/bus.js @@ -406,11 +406,13 @@ function showCurrentBusStop(client) { function arrivedAtBusStop(client) { if(isLastStopOnBusRoute(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute, getPlayerData(client).jobRouteStop)) { respawnVehicle(getPlayerData(client).jobRouteVehicle); - messagePlayerNormal(client, `You finished the ${getBusRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).name} bus route! Your bus has been returned to the bus depot.`, getColourByName("yellow")); + messagePlayerNormal(client, `You finished the ${getBusRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).name} bus route! You earned $${getBusRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).payout} and your bus has been returned to the bus depot.`, getColourByName("yellow")); + getPlayerCurrentSubAccount(client).cash += getBusRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).payout; + updatePlayerCash(client); getPlayerData(client).jobRouteVehicle = false; getPlayerData(client).jobRoute = 0; getPlayerData(client).jobRouteStop = 0; - getPlayerData(client).jobRouteIsland = 0; + getPlayerData(client).jobRouteIsland = 0; return false; } diff --git a/scripts/server/job/garbage.js b/scripts/server/job/garbage.js index 69fd8502..18c74d46 100644 --- a/scripts/server/job/garbage.js +++ b/scripts/server/job/garbage.js @@ -116,7 +116,9 @@ function showCurrentGarbageStop(client) { function arrivedAtGarbageStop(client) { if(isLastStopOnGarbageRoute(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute, getPlayerData(client).jobRouteStop)) { respawnVehicle(getPlayerData(client).jobRouteVehicle); - messagePlayerNormal(client, `You finished the ${getGarbageRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).name} garbage route! Your trashmaster has been returned to the garbage depot.`, getColourByName("yellow")); + messagePlayerNormal(client, `You finished the ${getGarbageRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).name} garbage route! You earned $${getGarbageRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).payout} and your trashmaster has been returned to the garbage depot.`, getColourByName("yellow")); + getPlayerCurrentSubAccount(client).cash += getGarbageRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).payout; + updatePlayerCash(client); getPlayerData(client).jobRouteVehicle = false; getPlayerData(client).jobRoute = 0; getPlayerData(client).jobRouteStop = 0; diff --git a/scripts/server/misc.js b/scripts/server/misc.js index 4f584f73..b17d0e7a 100644 --- a/scripts/server/misc.js +++ b/scripts/server/misc.js @@ -136,9 +136,14 @@ function enterExitPropertyCommand(command, params, client) { setPlayerInterior(client, inHouse.entranceInterior); setTimeout(function() { fadeCamera(client, true, 1.0); + setTimeout(function() { + enableCityAmbienceForPlayer(client); + clearPlayerOwnedPeds(client); + }, 2000); }, 1000); }, 1100); removeEntityData(client, "ag.inHouse"); + } return true; } @@ -159,9 +164,14 @@ function enterExitPropertyCommand(command, params, client) { setPlayerInterior(client, inBusiness.entranceInterior); setTimeout(function() { fadeCamera(client, true, 1.0); + setTimeout(function() { + enableCityAmbienceForPlayer(client); + clearPlayerOwnedPeds(client); + }, 2000); }, 1000); }, 1100); removeEntityData(client, "ag.inBusiness"); + console.log(`[Asshat.Misc] ${getPlayerDisplayForConsole(client)} entered business ${inBusiness.name}[${inBusiness.index}/${inBusiness.databaseId}]`); } return true; } @@ -184,6 +194,7 @@ function enterExitPropertyCommand(command, params, client) { meActionToNearbyPlayers(client, "opens the door and enters the business"); fadeCamera(client, false, 1.0); + disableCityAmbienceForPlayer(client); setTimeout(function() { setPlayerPosition(client, closestBusiness.exitPosition); setPlayerHeading(client, closestBusiness.exitRotation); @@ -218,6 +229,7 @@ function enterExitPropertyCommand(command, params, client) { fadeCamera(client, false, 1.0); + disableCityAmbienceForPlayer(client); setTimeout(function() { setPlayerPosition(client, closestHouse.exitPosition); setPlayerHeading(client, closestHouse.exitRotation); @@ -228,7 +240,6 @@ function enterExitPropertyCommand(command, params, client) { }, 1000); }, 1100); setEntityData(client, "ag.inHouse", closestHouseId); - return true; } } diff --git a/scripts/server/native.js b/scripts/server/native.js index 5708794d..c4f65e3e 100644 --- a/scripts/server/native.js +++ b/scripts/server/native.js @@ -113,7 +113,7 @@ function getPlayerVehicleSeat(client) { if(!getPlayerVehicle(client)) { return false; } - + for(let i = 0 ; i <= 8 ; i++) { if(getPlayerVehicle(client).getOccupant(i) == client.player) { return i; diff --git a/scripts/server/subaccount.js b/scripts/server/subaccount.js index 91633502..764c6bd3 100644 --- a/scripts/server/subaccount.js +++ b/scripts/server/subaccount.js @@ -29,7 +29,7 @@ function loadSubAccountFromName(firstName, lastName) { } disconnectFromDatabase(dbConnection); } - + return false; } @@ -47,7 +47,7 @@ function loadSubAccountFromId(subAccountId) { } disconnectFromDatabase(dbConnection); } - + return false; } @@ -71,7 +71,7 @@ function loadSubAccountsFromAccount(accountId) { disconnectFromDatabase(dbConnection); } } - + return tempSubAccounts; } @@ -128,7 +128,7 @@ function showCharacterSelectToClient(client) { let tempSubAccount = getPlayerData(client).subAccounts[0]; triggerNetworkEvent("ag.showCharacterSelect", client, tempSubAccount.firstName, tempSubAccount.lastName, tempSubAccount.placeOfOrigin, tempSubAccount.dateOfBirth, tempSubAccount.skin); console.log(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the character select GUI`); - } else { + } else { //let emojiNumbers = ["➊", "➋", "➌", "➍", "➎", "➏", "➐", "➑", "➒"]; //let emojiNumbers = ["①", "②", "③", "④", "⑤", "⑥", "⑦", "⑧", "⑨"]; //let emojiNumbers = ["1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣", "8️⃣", "9️⃣"]; @@ -247,7 +247,7 @@ function switchCharacterCommand(command, params, client) { //getPlayerCurrentSubAccount(client).dimension = getPlayerVirtualWorld(client); saveSubAccountToDatabase(getPlayerCurrentSubAccount(client)); - + resetClientStuff(client); client.despawnPlayer(); @@ -268,7 +268,7 @@ function newCharacterCommand(command, params, client) { let firstName = splitParams[0]; let lastName = splitParams[1]; - checkNewCharacter(client, firstName, lastName, "01/01/1901", "Liberty City", getServerConfig().newCharacter.skin); + checkNewCharacter(client, firstName, lastName, "01/01/1901", "Liberty City", getServerConfig().newCharacter.skin); } // --------------------------------------------------------------------------- @@ -314,4 +314,10 @@ function getCharacterFullName(client) { return `${getPlayerCurrentSubAccount(client).firstName} ${getPlayerCurrentSubAccount(client).lastName}`; } +// --------------------------------------------------------------------------- + +function isPlayerSwitchingCharacter(client) { + return getPlayerData(client).switchingCharacter; +} + // --------------------------------------------------------------------------- \ No newline at end of file diff --git a/scripts/server/timers.js b/scripts/server/timers.js index b61d2251..e98b8f2e 100644 --- a/scripts/server/timers.js +++ b/scripts/server/timers.js @@ -37,6 +37,7 @@ function initTimers() { serverTimers.updateTimeRuleTimer = setInterval(updateTimeRule, 1000); serverTimers.updatePingsTimer = setInterval(updatePings, 5000); serverTimers.vehicleRentTimer = setInterval(vehicleRentCheck, 60000); + serverTimers.garbageCollectorTimer = setInterval(collectAllGarbage, 60000); } } diff --git a/scripts/server/utilities.js b/scripts/server/utilities.js index 53850bc5..cf2cca70 100644 --- a/scripts/server/utilities.js +++ b/scripts/server/utilities.js @@ -1668,6 +1668,27 @@ function updatePlayerCash(client) { // --------------------------------------------------------------------------- +function setPlayerCash(client, amount) { + getPlayerCurrentSubAccount(client).cash = amount; + updatePlayerCash(client); +} + +// --------------------------------------------------------------------------- + +function givePlayerCash(client, amount) { + getPlayerCurrentSubAccount(client).cash += amount; + updatePlayerCash(client); +} + +// --------------------------------------------------------------------------- + +function takePlayerCash(client, amount) { + getPlayerCurrentSubAccount(client).cash -= amount; + updatePlayerCash(client); +} + +// --------------------------------------------------------------------------- + function clearChatBox(client) { //gta.messages.clear(); for(let i = 0; i <= 20; i++) { @@ -1834,6 +1855,12 @@ async function waitUntil(condition) { // ---------------------------------------------------------------------------- function resetClientStuff(client) { + console.log(`[Asshat.Utilities] Resetting client data for ${getPlayerDisplayForConsole(client)}`); + + if(!getPlayerData(client)) { + return false; + } + if(isPlayerOnJobRoute(client)) { stopJobRoute(client); } @@ -1845,4 +1872,4 @@ function resetClientStuff(client) { getPlayerData(client).lastVehicle = null; } -// ---------------------------------------------------------------------------- \ No newline at end of file +// ---------------------------------------------------------------------------- diff --git a/scripts/shared/native.js b/scripts/shared/native.js index 2abad04a..bda95355 100644 --- a/scripts/shared/native.js +++ b/scripts/shared/native.js @@ -8,6 +8,9 @@ // TYPE: Shared (JavaScript) // =========================================================================== +"use strict"; +setErrorMode(RESOURCEERRORMODE_STRICT); + // --------------------------------------------------------------------------- function toInteger(val) {