From 3298aabca358d51a54d9dcde77727d021322e8d4 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Tue, 7 Jun 2022 10:24:10 -0500 Subject: [PATCH] Add player blips --- scripts/server/class.js | 163 ++++++++--------- scripts/server/misc.js | 221 +++++++++++++---------- scripts/server/native/connected.js | 270 +++++++++++++++-------------- 3 files changed, 355 insertions(+), 299 deletions(-) diff --git a/scripts/server/class.js b/scripts/server/class.js index aa8f7ea4..1fc5f203 100644 --- a/scripts/server/class.js +++ b/scripts/server/class.js @@ -91,7 +91,7 @@ class ServerConfigData { sendAdmin: true, }; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = dbAssoc["svr_id"]; this.newCharacter = { spawnPosition: toVector3(dbAssoc["svr_newchar_pos_x"], dbAssoc["svr_newchar_pos_y"], dbAssoc["svr_newchar_pos_z"]), @@ -101,7 +101,7 @@ class ServerConfigData { skin: dbAssoc["svr_newchar_skin"], }, - this.connectCameraPosition = toVector3(dbAssoc["svr_connectcam_pos_x"], dbAssoc["svr_connectcam_pos_y"], dbAssoc["svr_connectcam_pos_z"]); + 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"]); @@ -118,6 +118,7 @@ class ServerConfigData { this.createJobBlips = intToBool(toInteger(dbAssoc["svr_job_blips"])); this.createBusinessBlips = intToBool(toInteger(dbAssoc["svr_biz_blips"])); this.createHouseBlips = intToBool(toInteger(dbAssoc["svr_house_blips"])); + this.createPlayerBlips = intToBool(toInteger(dbAssoc["svr_player_blips"])); this.guiColourPrimary = [toInteger(dbAssoc["svr_gui_col1_r"]), toInteger(dbAssoc["svr_gui_col1_g"]), toInteger(dbAssoc["svr_gui_col1_b"])]; this.guiColourSecondary = [toInteger(dbAssoc["svr_gui_col2_r"]), toInteger(dbAssoc["svr_gui_col2_g"]), toInteger(dbAssoc["svr_gui_col2_b"])]; this.guiTextColourPrimary = [toInteger(dbAssoc["svr_gui_textcol1_r"]), toInteger(dbAssoc["svr_gui_textcol1_g"]), toInteger(dbAssoc["svr_gui_textcol1_b"])]; @@ -276,11 +277,11 @@ class AccountData { this.staffTitle = ""; this.ircAccount = ""; this.discordAccount = 0, - this.settings = 0, - this.emailAddress = ""; + this.settings = 0, + this.emailAddress = ""; this.ipAddress = 0, - this.notes = []; + this.notes = []; this.messages = []; this.contacts = []; this.subAccounts = []; @@ -294,7 +295,7 @@ class AccountData { this.streamingRadioVolume = 20; this.locale = 0; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = dbAssoc["acct_id"]; this.name = dbAssoc["acct_name"]; this.password = dbAssoc["acct_pass"]; @@ -338,7 +339,7 @@ class AccountContactData { this.whenAdded = 0; this.needsSaved = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = dbAssoc["acct_contact_id"]; this.accountId = dbAssoc["acct_contact_acct"]; this.contactAccountId = dbAssoc["acct_contact_contact"]; @@ -364,7 +365,7 @@ class AccountMessageData { this.message = ""; this.needsSaved = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = dbAssoc["acct_msg_id"]; this.account = dbAssoc["acct_msg_acct"]; this.whoSent = dbAssoc["acct_msg_who_sent"]; @@ -393,7 +394,7 @@ class AccountStaffNoteData { this.note = ""; this.needsSaved = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = dbAssoc["acct_note_id"]; this.account = dbAssoc["acct_note_acct"]; this.whoAdded = dbAssoc["acct_note_who_added"]; @@ -444,26 +445,26 @@ class SubAccountData { this.accent = ""; this.bodyParts = { - hair: [0,0], - head: [0,0], - upper: [0,0], - lower: [0,0], + hair: [0, 0], + head: [0, 0], + upper: [0, 0], + lower: [0, 0], }; this.bodyProps = { - hair: [0,0], - eyes: [0,0], - head: [0,0], - leftHand: [0,0], - rightHand: [0,0], - leftWrist: [0,0], - rightWrist: [0,0], - hip: [0,0], - leftFoot: [0,0], - rightFoot: [0,0], + hair: [0, 0], + eyes: [0, 0], + head: [0, 0], + leftHand: [0, 0], + rightHand: [0, 0], + leftWrist: [0, 0], + rightWrist: [0, 0], + hip: [0, 0], + leftFoot: [0, 0], + rightFoot: [0, 0], }; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = dbAssoc["sacct_id"]; this.serverId = toInteger(dbAssoc["sacct_server"]); this.firstName = dbAssoc["sacct_name_first"]; @@ -567,7 +568,7 @@ class BusinessData { this.customInterior = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["biz_id"]); this.name = toString(dbAssoc["biz_name"]); this.ownerType = toInteger(dbAssoc["biz_owner_type"]); @@ -621,7 +622,7 @@ class BusinessLocationData { this.interior = 0; this.dimension = 0; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["biz_loc_id"]); this.name = toString(dbAssoc["biz_loc_name"]); this.type = toInteger(dbAssoc["biz_loc_type"]); @@ -648,7 +649,7 @@ class BusinessGameScriptData { this.businessIndex = -1; this.needsSaved = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["biz_script_id"]); this.name = toString(dbAssoc["biz_script_name"]); this.state = toInteger(dbAssoc["biz_script_state"]); @@ -703,7 +704,7 @@ class HouseData { this.customInterior = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["house_id"]); this.description = toString(dbAssoc["house_description"]); this.ownerType = toInteger(dbAssoc["house_owner_type"]); @@ -754,7 +755,7 @@ class HouseLocationData { this.interior = 0; this.dimension = 0; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["house_loc_id"]); this.name = toString(dbAssoc["house_loc_name"]); this.type = toInteger(dbAssoc["house_loc_type"]); @@ -786,7 +787,7 @@ class HouseGameScriptData { this.houseIndex = -1; this.needsSaved = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["house_script_id"]); this.name = toString(dbAssoc["house_script_name"]); this.state = toInteger(dbAssoc["house_script_state"]); @@ -814,7 +815,7 @@ class ClanData { this.needsSaved = false; this.motd = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["clan_id"]); this.name = dbAssoc["clan_name"]; this.owner = toInteger(dbAssoc["clan_owner"]); @@ -843,7 +844,7 @@ class ClanRankData { this.clanIndex = -1; this.needsSaved = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["clan_rank_id"]); this.clan = toInteger(dbAssoc["clan_rank_clan"]); this.name = dbAssoc["clan_rank_name"]; @@ -873,7 +874,7 @@ class ClanMemberData { this.rankIndex = -1; this.needsSaved = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["clan_member_id"]); this.subAccount = toInteger(dbAssoc["clan_member_sacct"]); this.clan = toInteger(dbAssoc["clan_member_clan"]); @@ -960,7 +961,7 @@ class VehicleData { this.triggers = []; - if(dbAssoc) { + if (dbAssoc) { // General Info this.databaseId = toInteger(dbAssoc["veh_id"]); this.serverId = toInteger(dbAssoc["veh_server"]); @@ -1081,7 +1082,7 @@ class JobData { this.blackList = []; this.routes = []; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = dbAssoc["job_id"]; this.serverId = dbAssoc["job_server"]; this.type = dbAssoc["job_type"]; @@ -1119,7 +1120,7 @@ class JobEquipmentData { this.needsSaved = false; this.items = []; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = dbAssoc["job_equip_id"]; this.job = dbAssoc["job_equip_job"]; this.name = dbAssoc["job_equip_name"]; @@ -1143,7 +1144,7 @@ class JobEquipmentItemData { this.jobIndex = -1; this.needsSaved = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = dbAssoc["job_equip_item_id"]; this.equipmentId = dbAssoc["job_equip_item_equip"]; this.itemType = dbAssoc["job_equip_item_type"]; @@ -1169,26 +1170,26 @@ class JobUniformData { this.needsSaved = false; this.bodyParts = { - hair: [0,0], - head: [0,0], - upper: [0,0], - lower: [0,0], + hair: [0, 0], + head: [0, 0], + upper: [0, 0], + lower: [0, 0], }; this.bodyProps = { - hair: [0,0], - eyes: [0,0], - head: [0,0], - leftHand: [0,0], - rightHand: [0,0], - leftWrist: [0,0], - rightWrist: [0,0], - hip: [0,0], - leftFoot: [0,0], - rightFoot: [0,0], + hair: [0, 0], + eyes: [0, 0], + head: [0, 0], + leftHand: [0, 0], + rightHand: [0, 0], + leftWrist: [0, 0], + rightWrist: [0, 0], + hip: [0, 0], + leftFoot: [0, 0], + rightFoot: [0, 0], }; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = dbAssoc["job_uniform_id"]; this.job = dbAssoc["job_uniform_job"]; this.name = dbAssoc["job_uniform_name"]; @@ -1237,7 +1238,7 @@ class JobLocationData { this.needsSaved = false; this.routeCache = []; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["job_loc_id"]); this.jobId = toInteger(dbAssoc["job_loc_job"]); this.position = toVector3(toFloat(dbAssoc["job_loc_pos_x"]), toFloat(dbAssoc["job_loc_pos_y"]), toFloat(dbAssoc["job_loc_pos_z"])); @@ -1258,7 +1259,7 @@ class JobWhiteListData { this.jobIndex = -1; this.needsSaved = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = dbAssoc["job_wl_id"]; this.job = dbAssoc["job_wl_job"]; this.subAccount = dbAssoc["job_wl_sacct"] @@ -1277,7 +1278,7 @@ class JobBlackListData { this.jobIndex = -1; this.needsSaved = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = dbAssoc["job_bl_id"]; this.job = dbAssoc["job_bl_job"]; this.subAccount = dbAssoc["job_bl_sacct"] @@ -1298,7 +1299,7 @@ class KeyBindData { this.index = -1; this.needsSaved = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = dbAssoc["acct_hotkey_id"]; this.key = toInteger(dbAssoc["acct_hotkey_key"]); this.account = toInteger(dbAssoc["acct_hotkey_acct"]); @@ -1319,7 +1320,7 @@ class RadioStationData { this.codec = ""; this.index = -1; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = dbAssoc["radio_id"]; this.name = dbAssoc["radio_name"]; this.url = dbAssoc["radio_url"]; @@ -1349,7 +1350,7 @@ class ItemData { this.enabled = false; this.extra = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["item_id"]); this.index = 0; this.itemTypeIndex = 0; @@ -1412,7 +1413,7 @@ class ItemTypeData { this.takeAnimationIndex = false; this.switchAnimationIndex = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["item_type_id"]); this.serverId = toInteger(dbAssoc["item_type_server"]); this.name = dbAssoc["item_type_name"]; @@ -1486,28 +1487,28 @@ class NPCData { this.ownerId = 0; this.bodyParts = { - hair: [0,0], - head: [0,0], - upper: [0,0], - lower: [0,0], + hair: [0, 0], + head: [0, 0], + upper: [0, 0], + lower: [0, 0], }; this.bodyProps = { - hair: [0,0], - eyes: [0,0], - head: [0,0], - leftHand: [0,0], - rightHand: [0,0], - leftWrist: [0,0], - rightWrist: [0,0], - hip: [0,0], - leftFoot: [0,0], - rightFoot: [0,0], + hair: [0, 0], + eyes: [0, 0], + head: [0, 0], + leftHand: [0, 0], + rightHand: [0, 0], + leftWrist: [0, 0], + rightWrist: [0, 0], + hip: [0, 0], + leftFoot: [0, 0], + rightFoot: [0, 0], }; this.triggers = []; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["npc_id"]); this.serverId = toInteger(dbAssoc["npc_server"]); this.name = dbAssoc["npc_name"]; @@ -1567,7 +1568,7 @@ class NPCTriggerData { this.conditions = []; this.responses = []; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["npc_trig_id"]); this.npc = toInteger(dbAssoc["npc_trig_npc"]); this.triggerType = toInteger(dbAssoc["npc_trig_type"]); @@ -1585,7 +1586,7 @@ class NPCTriggerConditionData { this.conditionValue = false; this.matchType = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["npc_trig_cond_id"]); this.npc = toInteger(dbAssoc["npc_trig_cond_trig"]); this.conditionType = toInteger(dbAssoc["npc_trig_cond_type"]); @@ -1604,7 +1605,7 @@ class NPCTriggerResponseData { this.responseType = 0; this.responseValue = false; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["npc_trig_resp_id"]); this.npc = toInteger(dbAssoc["npc_trig_resp_trig"]); this.responseType = toInteger(dbAssoc["npc_trig_resp_type"]); @@ -1622,7 +1623,7 @@ class BanData { this.name = ""; this.reason = ""; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["ban_id"]); this.type = dbAssoc["ban_type"]; this.detail = toInteger(dbAssoc["ban_detail"]); @@ -1653,7 +1654,7 @@ class JobRouteData { this.locationNextMessage = ""; this.locations = []; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["job_route_id"]); this.name = toString(dbAssoc["job_route_name"]); this.jobId = toInteger(dbAssoc["job_route_job"]); @@ -1685,7 +1686,7 @@ class JobRouteLocationData { this.stopDelay = 0; this.pay = 0; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["job_route_loc_id"]); this.name = toString(dbAssoc["job_route_loc_name"]); this.routeId = toInteger(dbAssoc["job_route_loc_route"]); @@ -1708,7 +1709,7 @@ class GateData { this.ownerType = VRR_GATEOWNER_NONE; this.ownerId = 0; - if(dbAssoc) { + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["gate_id"]); this.name = toString(dbAssoc["gate_name"]); this.scriptName = toString(dbAssoc["gate_script_name"]); diff --git a/scripts/server/misc.js b/scripts/server/misc.js index 1ae25e1a..a037da6f 100644 --- a/scripts/server/misc.js +++ b/scripts/server/misc.js @@ -35,7 +35,7 @@ function toggleMouseCursorCommand(command, params, client) { // =========================================================================== function toggleMouseCameraCommand(command, params, client) { - if(getGame() != VRR_GAME_GTA_VC) { + if (getGame() != VRR_GAME_GTA_VC) { sendPlayerMouseCameraToggle(client); } return true; @@ -58,12 +58,12 @@ function setNewCharacterSpawnPositionCommand(command, params, client) { // =========================================================================== function setNewCharacterMoneyCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } -let amount = toInteger(getParam(params, " ", 1)) || 1000; + let amount = toInteger(getParam(params, " ", 1)) || 1000; getServerConfig().newCharacter.cash = amount; getServerConfig().needsSaved = true; @@ -75,7 +75,7 @@ let amount = toInteger(getParam(params, " ", 1)) || 1000; // =========================================================================== function setNewCharacterSkinCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -92,7 +92,7 @@ function setNewCharacterSkinCommand(command, params, client) { // =========================================================================== function submitIdeaCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -106,7 +106,7 @@ function submitIdeaCommand(command, params, client) { // =========================================================================== function submitBugReportCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -124,15 +124,15 @@ function enterExitPropertyCommand(command, params, client) { let isEntrance = false; let isBusiness = false; - if(areServerElementsSupported()) { - if(!getPlayerData(client).currentPickup) { + if (areServerElementsSupported()) { + if (!getPlayerData(client).currentPickup) { return false; } let ownerType = getEntityData(getPlayerData(client).currentPickup, "vrr.owner.type"); let ownerId = getEntityData(getPlayerData(client).currentPickup, "vrr.owner.id"); - switch(ownerType) { + switch (ownerType) { case VRR_PICKUP_BUSINESS_ENTRANCE: isBusiness = true; isEntrance = true; @@ -161,8 +161,8 @@ function enterExitPropertyCommand(command, params, client) { return false; } } else { - for(let i in getServerData().businesses) { - if(getPlayerDimension(client) == getGameConfig().mainWorldDimension[getGame()] && getPlayerInterior(client) == getGameConfig().mainWorldInterior[getGame()]) { + for (let i in getServerData().businesses) { + if (getPlayerDimension(client) == getGameConfig().mainWorldDimension[getGame()] && getPlayerInterior(client) == getGameConfig().mainWorldInterior[getGame()]) { let businessId = getClosestBusinessEntrance(getPlayerPosition(client), getPlayerDimension(client)); isBusiness = true; isEntrance = true; @@ -175,8 +175,8 @@ function enterExitPropertyCommand(command, params, client) { } } - for(let j in getServerData().houses) { - if(getPlayerDimension(client) == getGameConfig().mainWorldDimension[getGame()] && getPlayerInterior(client) == getGameConfig().mainWorldInterior[getGame()]) { + for (let j in getServerData().houses) { + if (getPlayerDimension(client) == getGameConfig().mainWorldDimension[getGame()] && getPlayerInterior(client) == getGameConfig().mainWorldInterior[getGame()]) { let houseId = getClosestHouseEntrance(getPlayerPosition(client), getPlayerDimension(client)); isBusiness = false; isEntrance = true; @@ -190,20 +190,20 @@ function enterExitPropertyCommand(command, params, client) { } } - if(closestProperty == null) { + if (closestProperty == null) { return false; } logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s closest door is ${(isBusiness) ? closestProperty.name : closestProperty.description} ${(isEntrance) ? "entrance" : "exit"}`); - if(isEntrance) { - if(getDistance(closestProperty.entrancePosition, getPlayerPosition(client)) <= getGlobalConfig().enterPropertyDistance) { - if(closestProperty.locked) { + if (isEntrance) { + if (getDistance(closestProperty.entrancePosition, getPlayerPosition(client)) <= getGlobalConfig().enterPropertyDistance) { + if (closestProperty.locked) { meActionToNearbyPlayers(client, getLocaleString(client, "EnterExitPropertyDoorLocked", (isBusiness) ? getLocaleString(client, "Business") : getLocaleString(client, "House"))); return false; } - if(!closestProperty.hasInterior) { + if (!closestProperty.hasInterior) { messagePlayerAlert(client, getLocaleString(client, "PropertyNoInterior", (isBusiness) ? getLocaleString(client, "Business") : getLocaleString(client, "House"))); return false; } @@ -212,18 +212,18 @@ function enterExitPropertyCommand(command, params, client) { getPlayerData(client).pedState = VRR_PEDSTATE_ENTERINGPROPERTY; meActionToNearbyPlayers(client, getLocaleString(client, "EntersProperty", (isBusiness) ? getLocaleString(client, "Business") : getLocaleString(client, "House"))); - if(isFadeCameraSupported()) { + if (isFadeCameraSupported()) { fadeCamera(client, false, 1.0); } - setTimeout(function() { + setTimeout(function () { setPlayerInCutsceneInterior(client, closestProperty.exitCutscene); setPlayerPosition(client, closestProperty.exitPosition); setPlayerHeading(client, closestProperty.exitRotation); setPlayerDimension(client, closestProperty.exitDimension); setPlayerInterior(client, closestProperty.exitInterior); - setTimeout(function() { - if(isFadeCameraSupported()) { + setTimeout(function () { + if (isFadeCameraSupported()) { fadeCamera(client, true, 1.0); } updateInteriorLightsForPlayer(client, closestProperty.interiorLights); @@ -231,8 +231,8 @@ function enterExitPropertyCommand(command, params, client) { //setPlayerInCutsceneInterior(client, closestProperty.exitCutscene); //updateAllInteriorVehiclesForPlayer(client, closestProperty.exitInterior, closestProperty.exitDimension); }, 1100); - if(closestProperty.streamingRadioStation != -1) { - if(getRadioStationData(closestProperty.streamingRadioStation)) { + if (closestProperty.streamingRadioStation != -1) { + if (getRadioStationData(closestProperty.streamingRadioStation)) { playRadioStreamForPlayer(client, getRadioStationData(closestProperty.streamingRadioStation).url); getPlayerData(client).streamingRadioStation = closestProperty.streamingRadioStation; } @@ -240,8 +240,8 @@ function enterExitPropertyCommand(command, params, client) { return true; } } else { - if(getDistance(closestProperty.exitPosition, getPlayerPosition(client)) <= getGlobalConfig().exitPropertyDistance) { - if(closestProperty.locked) { + if (getDistance(closestProperty.exitPosition, getPlayerPosition(client)) <= getGlobalConfig().exitPropertyDistance) { + if (closestProperty.locked) { meActionToNearbyPlayers(client, getLocaleString(client, "EnterExitPropertyDoorLocked", (isBusiness) ? getLocaleString(client, "Business") : getLocaleString(client, "House"))); return false; } @@ -249,19 +249,19 @@ function enterExitPropertyCommand(command, params, client) { clearPlayerStateToEnterExitProperty(client) meActionToNearbyPlayers(client, getLocaleString(client, "ExitsProperty", (isBusiness) ? getLocaleString(client, "Business") : getLocaleString(client, "House"))); - if(isFadeCameraSupported()) { + if (isFadeCameraSupported()) { fadeCamera(client, false, 1.0); } disableCityAmbienceForPlayer(client, true); - setTimeout(function() { + setTimeout(function () { setPlayerInCutsceneInterior(client, closestProperty.entranceCutscene); setPlayerPosition(client, closestProperty.entrancePosition); setPlayerHeading(client, closestProperty.entranceRotation); setPlayerDimension(client, closestProperty.entranceDimension); setPlayerInterior(client, closestProperty.entranceInterior); - setTimeout(function() { - if(isFadeCameraSupported()) { + setTimeout(function () { + if (isFadeCameraSupported()) { fadeCamera(client, true, 1.0); } @@ -285,11 +285,11 @@ function enterExitPropertyCommand(command, params, client) { function getPlayerInfoCommand(command, params, client) { let targetClient = client; - if(!areParamsEmpty(params)) { - if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("BasicModeration"))) { + if (!areParamsEmpty(params)) { + if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("BasicModeration"))) { targetClient = getPlayerFromParams(params); - if(!getPlayerData(targetClient)) { + if (!getPlayerData(targetClient)) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); return false; } @@ -317,7 +317,7 @@ function getPlayerInfoCommand(command, params, client) { let stats = tempStats.map(stat => `{MAINCOLOUR}${stat[0]}: {ALTCOLOUR}${stat[1]}{MAINCOLOUR}`); let chunkedList = splitArrayIntoChunks(stats, 6); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerInfo(client, chunkedList[i].join(", ")); } } @@ -325,7 +325,7 @@ function getPlayerInfoCommand(command, params, client) { // =========================================================================== function playerChangeAFKState(client, afkState) { - if(!getPlayerData(client)) { + if (!getPlayerData(client)) { return false; } @@ -337,12 +337,12 @@ function playerChangeAFKState(client, afkState) { function checkPlayerSpawning() { let clients = getClients(); - for(let i in clients) { - if(!isConsole(clients[i])) { - if(getPlayerData(clients[i])) { - if(isPlayerLoggedIn(clients[i])) { - if(!getPlayerData(clients[i]).ped) { - if(clients[i].player != null) { + for (let i in clients) { + if (!isConsole(clients[i])) { + if (getPlayerData(clients[i])) { + if (isPlayerLoggedIn(clients[i])) { + if (!getPlayerData(clients[i]).ped) { + if (clients[i].player != null) { //getPlayerData(clients[i]).ped = clients[i].player; onPlayerSpawn(clients[i].player); } @@ -356,7 +356,7 @@ function checkPlayerSpawning() { // =========================================================================== function showPlayerPrompt(client, promptMessage, promptTitle, yesButtonText, noButtonText) { - if(canPlayerUseGUI(client)) { + if (canPlayerUseGUI(client)) { showPlayerPromptGUI(client, promptMessage, promptTitle, yesButtonText, noButtonText); } else { messagePlayerNormal(client, `❓ ${promptMessage}`); @@ -376,7 +376,7 @@ function showPlayerPrompt(client, promptMessage, promptTitle, yesButtonText, noB * */ function updateServerGameTime() { - if(isTimeSupported()) { + if (isTimeSupported()) { game.time.hour = getServerConfig().hour; game.time.minute = getServerConfig().minute; } @@ -399,10 +399,10 @@ function listOnlineAdminsCommand(command, params, client) { let admins = []; let clients = getClients(); - for(let i in clients) { - if(getPlayerData(clients[i])) { - if(typeof getPlayerData(clients[i]).accountData.flags.admin != "undefined") { - if(getPlayerData(clients[i]).accountData.flags.admin > 0 || getPlayerData(clients[i]).accountData.flags.admin == -1) { + for (let i in clients) { + if (getPlayerData(clients[i])) { + if (typeof getPlayerData(clients[i]).accountData.flags.admin != "undefined") { + if (getPlayerData(clients[i]).accountData.flags.admin > 0 || getPlayerData(clients[i]).accountData.flags.admin == -1) { admins.push(`{ALTCOLOUR}[${getPlayerData(clients[i]).accountData.staffTitle}] {MAINCOLOUR}${getCharacterFullName(clients[i])}`); } } @@ -410,7 +410,7 @@ function listOnlineAdminsCommand(command, params, client) { } let chunkedList = splitArrayIntoChunks(admins, 3); - for(let i in chunkedList) { + for (let i in chunkedList) { messagePlayerInfo(client, chunkedList[i].join(", ")); } } @@ -433,7 +433,7 @@ function gpsCommand(command, params, client) { let useType = VRR_ITEM_USETYPE_NONE; let blipColour = "white"; - switch(toLowerCase(params)) { + switch (toLowerCase(params)) { case "police": case "policestation": blipColour = "mediumGrey" @@ -512,32 +512,32 @@ function gpsCommand(command, params, client) { default: { let itemTypeId = getItemTypeFromParams(params); - if(getItemTypeData(itemTypeId) != false) { + if (getItemTypeData(itemTypeId) != false) { locationType = VRR_GPS_TYPE_BUSINESS; blipColour = "mediumGrey"; useType = getItemTypeData(itemTypeId).useType; } else { let gameLocationId = getGameLocationFromParams(params); - if(gameLocationId != false) { + if (gameLocationId != false) { position = getGameConfig().locations[getGame()][gameLocationId][1] } } } } - if(locationType == VRR_GPS_TYPE_NONE) { + if (locationType == VRR_GPS_TYPE_NONE) { messagePlayerError(client, getLocaleString(client, "InvalidGPSLocation")); return false; } - if(locationType == VRR_GPS_TYPE_BUSINESS) { + if (locationType == VRR_GPS_TYPE_BUSINESS) { let businessId = getClosestBusinessWithBuyableItemOfUseType(useType); - if(!businessId) { + if (!businessId) { messagePlayerError(client, getLocaleString(client, "NoBusinessWithItemType")); return false; } - if(!getBusinessData(businessId)) { + if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "NoBusinessWithItemType")); return false; } @@ -547,7 +547,7 @@ function gpsCommand(command, params, client) { messagePlayerSuccess(client, "Look for the blinking icon on your mini map"); } - if(locationType == VRR_GPS_TYPE_GAMELOC) { + if (locationType == VRR_GPS_TYPE_GAMELOC) { hideAllBlipsForPlayerGPS(client); blinkGenericGPSBlipForPlayer(client, position, 0, getColourByType(blipColour), 10); messagePlayerSuccess(client, "Look for the blinking icon on your mini map"); @@ -567,7 +567,7 @@ function gpsCommand(command, params, client) { * */ function stuckPlayerCommand(command, params, client) { - if((getCurrentUnixTimestamp()-getPlayerData(client).lastStuckCommand) < getGlobalConfig().stuckCommandInterval) { + if ((getCurrentUnixTimestamp() - getPlayerData(client).lastStuckCommand) < getGlobalConfig().stuckCommandInterval) { messagePlayerError(client, "CantUseCommandYet"); return false; } @@ -577,8 +577,8 @@ function stuckPlayerCommand(command, params, client) { messagePlayerAlert(client, getLocaleString(client, "FixingStuck")); - if(getGameConfig().skinChangePosition[getGame()].length > 0) { - if(getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType == VRR_RETURNTO_TYPE_SKINSELECT) { + if (getGameConfig().skinChangePosition[getGame()].length > 0) { + if (getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType == VRR_RETURNTO_TYPE_SKINSELECT) { messagePlayerAlert(client, "You canceled the skin change."); restorePlayerCamera(client); @@ -601,10 +601,10 @@ function stuckPlayerCommand(command, params, client) { // return false; //} - if(dimension > 0) { + if (dimension > 0) { let businesses = getServerData().businesses; - for(let i in businesses) { - if(businesses[i].exitDimension == dimension) { + for (let i in businesses) { + if (businesses[i].exitDimension == dimension) { setPlayerPosition(client, businesses[i].entrancePosition); setPlayerDimension(client, businesses[i].entranceDimension); setPlayerInterior(client, businesses[i].entranceInterior); @@ -614,8 +614,8 @@ function stuckPlayerCommand(command, params, client) { } let houses = getServerData().houses; - for(let i in houses) { - if(houses[i].exitDimension == dimension) { + for (let i in houses) { + if (houses[i].exitDimension == dimension) { setPlayerPosition(client, houses[i].entrancePosition); setPlayerDimension(client, houses[i].entranceDimension); setPlayerInterior(client, houses[i].entranceInterior); @@ -646,7 +646,7 @@ function stuckPlayerCommand(command, params, client) { * */ function playerPedSpeakCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } @@ -666,15 +666,15 @@ function playerPedSpeakCommand(command, params, client) { * */ function lockCommand(command, params, client) { - if(isPlayerInAnyVehicle(client)) { + if (isPlayerInAnyVehicle(client)) { let vehicle = getPlayerVehicle(client); - if(!getVehicleData(vehicle)) { + if (!getVehicleData(vehicle)) { messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled")); return false; } - if(!isPlayerInFrontVehicleSeat(client)) { + if (!isPlayerInFrontVehicleSeat(client)) { messagePlayerError(client, getLocaleString(client, "MustBeInVehicleFrontSeat")); return false; } @@ -687,13 +687,13 @@ function lockCommand(command, params, client) { return true; } else { let vehicle = getClosestVehicle(getPlayerPosition(client)); - if(getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleLockDistance) { - if(!getVehicleData(vehicle)) { + if (getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleLockDistance) { + if (!getVehicleData(vehicle)) { messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled")); return false; } - if(!doesPlayerHaveVehicleKeys(client, vehicle)) { + if (!doesPlayerHaveVehicleKeys(client, vehicle)) { messagePlayerError(client, getLocaleString(client, "DontHaveVehicleKey")); return false; } @@ -708,8 +708,8 @@ function lockCommand(command, params, client) { } let businessId = getPlayerBusiness(client); - if(businessId != -1) { - if(!canPlayerManageBusiness(client, businessId)) { + if (businessId != -1) { + if (!canPlayerManageBusiness(client, businessId)) { messagePlayerError(client, getLocaleString(client, "CantModifyBusiness")); return false; } @@ -723,8 +723,8 @@ function lockCommand(command, params, client) { } let houseId = getPlayerHouse(client); - if(houseId != -1) { - if(!canPlayerManageHouse(client, houseId)) { + if (houseId != -1) { + if (!canPlayerManageHouse(client, houseId)) { messagePlayerError(client, getLocaleString(client, "CantModifyHouse")); return false; } @@ -750,16 +750,16 @@ function lockCommand(command, params, client) { * @return {bool} Whether or not the command was successful * */ - function lightsCommand(command, params, client) { - if(isPlayerInAnyVehicle(client)) { +function lightsCommand(command, params, client) { + if (isPlayerInAnyVehicle(client)) { let vehicle = getPlayerVehicle(client); - if(!getVehicleData(vehicle)) { + if (!getVehicleData(vehicle)) { messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled")); return false; } - if(!isPlayerInFrontVehicleSeat(client)) { + if (!isPlayerInFrontVehicleSeat(client)) { messagePlayerError(client, getLocaleString(client, "MustBeInVehicleFrontSeat")); return false; } @@ -797,8 +797,8 @@ function lockCommand(command, params, client) { */ let businessId = getPlayerBusiness(client); - if(businessId != -1) { - if(!canPlayerManageBusiness(client, businessId)) { + if (businessId != -1) { + if (!canPlayerManageBusiness(client, businessId)) { messagePlayerError(client, getLocaleString(client, "CantModifyBusiness")); return false; } @@ -807,8 +807,8 @@ function lockCommand(command, params, client) { getBusinessData(businessId).needsSaved = true; let clients = getClients(); - for(let i in clients) { - if(getPlayerBusiness(client) == getPlayerBusiness(clients[i]) && getPlayerDimension(clients[i]) == getBusinessData(businessId).exitDimension) { + for (let i in clients) { + if (getPlayerBusiness(client) == getPlayerBusiness(clients[i]) && getPlayerDimension(clients[i]) == getBusinessData(businessId).exitDimension) { updateInteriorLightsForPlayer(clients[i], getBusinessData(businessId).interiorLights); } } @@ -818,8 +818,8 @@ function lockCommand(command, params, client) { } let houseId = getPlayerHouse(client); - if(houseId != -1) { - if(!canPlayerManageHouse(client, houseId)) { + if (houseId != -1) { + if (!canPlayerManageHouse(client, houseId)) { messagePlayerError(client, getLocaleString(client, "CantModifyHouse")); return false; } @@ -828,8 +828,8 @@ function lockCommand(command, params, client) { getHouseData(houseId).needsSaved = true; let clients = getClients(); - for(let i in clients) { - if(getPlayerHouse(client) == getPlayerHouse(clients[i]) && getPlayerDimension(clients[i]) == getHouseData(houseId).exitDimension) { + for (let i in clients) { + if (getPlayerHouse(client) == getPlayerHouse(clients[i]) && getPlayerDimension(clients[i]) == getHouseData(houseId).exitDimension) { updateInteriorLightsForPlayer(clients[i], getHouseData(houseId).interiorLights); } } @@ -838,4 +838,51 @@ function lockCommand(command, params, client) { return true; } } +} + +// =========================================================================== + +function resetPlayerBlip(client) { + deletePlayerBlip(client); + createPlayerBlip(client); +} + +// =========================================================================== + +function createPlayerBlip(client) { + if (!areServerElementsSupported()) { + return false; + } + + if (!isGameFeatureSupported("attachedBlips")) { + return false; + } + + if (getServerConfig().createPlayerBlips) { + return false; + } + + let blip = createAttachedGameBlip(getPlayerPed(client), 0, 1, getPlayerColour(client)); + if (blip) { + if (getGlobalConfig().playerBlipStreamInDistance == -1 || getGlobalConfig().playerBlipStreamOutDistance == -1) { + blip.netFlags.distanceStreaming = false; + } else { + setElementStreamInDistance(blip, getGlobalConfig().playerBlipStreamInDistance); + setElementStreamOutDistance(blip, getGlobalConfig().playerBlipStreamOutDistance); + } + getPlayerData(client).playerBlip = blip; + } +} + +// =========================================================================== + +function deletePlayerBlip(client) { + if (!isGameFeatureSupported("attachedBlips")) { + return false; + } + + if (getPlayerData(client).playerBlip != false) { + destroyElement(getPlayerData(client).playerBlip); + getPlayerData(client).playerBlip = false; + } } \ No newline at end of file diff --git a/scripts/server/native/connected.js b/scripts/server/native/connected.js index 176e9888..6fd1f0d2 100644 --- a/scripts/server/native/connected.js +++ b/scripts/server/native/connected.js @@ -40,10 +40,10 @@ let disconnectReasons = [ // =========================================================================== function getPlayerPosition(client) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return getPlayerData(client).syncPosition; } else { - if(getPlayerPed(client) != null) { + if (getPlayerPed(client) != null) { return getPlayerPed(client).position; } } @@ -59,10 +59,10 @@ function setPlayerPosition(client, position) { // =========================================================================== function getPlayerHeading(client) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return getPlayerData(client).syncHeading; } else { - if(getPlayerPed(client) != null) { + if (getPlayerPed(client) != null) { return getPlayerPed(client).heading; } } @@ -78,10 +78,10 @@ function setPlayerHeading(client, heading) { // =========================================================================== function getPlayerVehicle(client) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return getPlayerData().syncVehicle; } else { - if(getPlayerPed(client).vehicle) { + if (getPlayerPed(client).vehicle) { return getPlayerPed(client).vehicle; } } @@ -91,10 +91,10 @@ function getPlayerVehicle(client) { // =========================================================================== function getPlayerDimension(client) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return getPlayerData(client).syncDimension; } else { - if(getPlayerPed(client) != null) { + if (getPlayerPed(client) != null) { return getPlayerPed(client).dimension; } } @@ -110,10 +110,10 @@ function getPlayerInterior(client) { function setPlayerDimension(client, dimension) { logToConsole(LOG_VERBOSE, `Setting ${getPlayerDisplayForConsole(client)}'s dimension to ${dimension}`); - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { getPlayerData(client).syncDimension = dimension; } else { - if(getPlayerPed(client) != null) { + if (getPlayerPed(client) != null) { getPlayerPed(client).dimension = dimension; } } @@ -124,7 +124,7 @@ function setPlayerDimension(client, dimension) { function setPlayerInterior(client, interior) { logToConsole(LOG_VERBOSE, `Setting ${getPlayerDisplayForConsole(client)}'s interior to ${interior}`); sendPlayerSetInterior(client, interior); - if(isPlayerLoggedIn(client) && isPlayerSpawned(client)) { + if (isPlayerLoggedIn(client) && isPlayerSpawned(client)) { getPlayerCurrentSubAccount(client).interior = interior; } } @@ -132,7 +132,7 @@ function setPlayerInterior(client, interior) { // =========================================================================== function isPlayerInAnyVehicle(client) { - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return (getPlayerData().syncVehicle != null); } else { return (getPlayerPed(client).vehicle != null); @@ -142,15 +142,15 @@ function isPlayerInAnyVehicle(client) { // =========================================================================== function getPlayerVehicleSeat(client) { - if(!isPlayerInAnyVehicle(client)) { + if (!isPlayerInAnyVehicle(client)) { return false; } - if(!areServerElementsSupported()) { + if (!areServerElementsSupported()) { return getPlayerData().syncVehicleSeat; } else { - for(let i = 0 ; i <= 8 ; i++) { - if(getPlayerVehicle(client).getOccupant(i) == getPlayerPed(client)) { + for (let i = 0; i <= 8; i++) { + if (getPlayerVehicle(client).getOccupant(i) == getPlayerPed(client)) { return i; } } @@ -180,7 +180,7 @@ function getVehicleHeading(vehicle) { // =========================================================================== function setVehicleHeading(vehicle, heading) { - if(getGame() == VRR_GAME_GTA_IV) { + if (getGame() == VRR_GAME_GTA_IV) { return sendNetworkEventToPlayer("vrr.vehPosition", null, getVehicleForNetworkEvent(vehicle), heading); } return vehicle.heading = heading; @@ -189,20 +189,20 @@ function setVehicleHeading(vehicle, heading) { // =========================================================================== function getElementTransient(element) { - if(typeof element.transient != "undefined") { + if (typeof element.transient != "undefined") { return element.transient; } - return false; + return false; } // =========================================================================== function setElementTransient(element, state) { - if(typeof element.transient != "undefined") { + if (typeof element.transient != "undefined") { element.transient = state; return true; } - return false; + return false; } // =========================================================================== @@ -214,8 +214,8 @@ function getVehicleSyncer(vehicle) { // =========================================================================== function getVehicleForNetworkEvent(vehicle) { - if(getGame() == VRR_GAME_GTA_IV) { - if(getVehicleData(vehicle).ivNetworkId != -1) { + if (getGame() == VRR_GAME_GTA_IV) { + if (getVehicleData(vehicle).ivNetworkId != -1) { return getVehicleData(vehicle).ivNetworkId; } return -1; @@ -227,11 +227,11 @@ function getVehicleForNetworkEvent(vehicle) { function deleteGameElement(element) { try { - if(element != null) { + if (element != null) { destroyElement(element); return true; } - } catch(error) { + } catch (error) { return false; } } @@ -254,7 +254,7 @@ function removePlayerFromVehicle(client) { function setPlayerSkin(client, skinIndex) { logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s skin to ${getGameConfig().skins[getGame()][skinIndex][0]} (Index: ${skinIndex}, Name: ${getGameConfig().skins[getGame()][skinIndex][1]})`); - if(getGame() == VRR_GAME_GTA_IV) { + if (getGame() == VRR_GAME_GTA_IV) { triggerNetworkEvent("vrr.localPlayerSkin", client, getGameConfig().skins[getGame()][skinIndex][0]); } else { getPlayerPed(client).modelIndex = getGameConfig().skins[getGame()][skinIndex][0]; @@ -292,7 +292,7 @@ function setPlayerArmour(client, armour) { // =========================================================================== function getPlayerArmour(client) { - if(areServerElementsSupported(client)) { + if (areServerElementsSupported(client)) { return getPlayerPed(client).armour; } else { return getPlayerData(client).syncArmour; @@ -302,11 +302,11 @@ function getPlayerArmour(client) { // =========================================================================== function setPlayerCash(client, amount) { - if(client == null) { + if (client == null) { return false; } - if(isNaN(amount)) { + if (isNaN(amount)) { return false; } @@ -317,11 +317,11 @@ function setPlayerCash(client, amount) { // =========================================================================== function givePlayerCash(client, amount) { - if(client == null) { + if (client == null) { return false; } - if(isNaN(amount)) { + if (isNaN(amount)) { return false; } @@ -332,11 +332,11 @@ function givePlayerCash(client, amount) { // =========================================================================== function takePlayerCash(client, amount) { - if(client == null) { + if (client == null) { return false; } - if(isNaN(amount)) { + if (isNaN(amount)) { return false; } @@ -368,7 +368,7 @@ function getPlayerWeaponAmmo(client) { function setPlayerVelocity(client, velocity) { logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s velocity to ${velocity.x}, ${velocity.y}, ${velocity.z}`); - if(typeof getPlayerPed(client).velocity != "undefined") { + if (typeof getPlayerPed(client).velocity != "undefined") { getPlayerPed(client).velocity = velocity; } } @@ -376,7 +376,7 @@ function setPlayerVelocity(client, velocity) { // =========================================================================== function getPlayerVelocity(client) { - if(typeof getPlayerPed(client).velocity != "undefined") { + if (typeof getPlayerPed(client).velocity != "undefined") { return getPlayerPed(client).velocity; } return toVector3(0.0, 0.0, 0.0); @@ -385,7 +385,7 @@ function getPlayerVelocity(client) { // =========================================================================== function getElementDimension(element) { - if(typeof element.dimension != "undefined") { + if (typeof element.dimension != "undefined") { return element.dimension; } return 0; @@ -394,18 +394,18 @@ function getElementDimension(element) { // =========================================================================== function setElementDimension(element, dimension) { - if(typeof element.dimension != "undefined") { + if (typeof element.dimension != "undefined") { logToConsole(LOG_VERBOSE, `Setting element ${element} (${element.id}) dimension to ${dimension}`); - element.dimension = dimension; - return true; - } - return false; + element.dimension = dimension; + return true; + } + return false; } // =========================================================================== function setElementRotation(element, rotation) { - if(typeof element.setRotation != "undefined") { + if (typeof element.setRotation != "undefined") { element.setRotation(rotation); } else { return element.rotation = rotation; @@ -415,24 +415,24 @@ function setElementRotation(element, rotation) { // =========================================================================== function givePlayerHealth(client, amount) { - if(getPlayerHealth(client)+amount > 100) { + if (getPlayerHealth(client) + amount > 100) { logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s health to 100`); setPlayerHealth(client, 100); } else { - logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s health to ${getPlayerHealth(client)+amount}`); - setPlayerHealth(client, getPlayerHealth(client)+amount); + logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s health to ${getPlayerHealth(client) + amount}`); + setPlayerHealth(client, getPlayerHealth(client) + amount); } } // =========================================================================== function givePlayerArmour(client, amount) { - if(getPlayerArmour(client)+amount > 100) { + if (getPlayerArmour(client) + amount > 100) { logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s armour to 100`); setPlayerArmour(client, 100); } else { - logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s armour to ${getPlayerArmour(client)+amount}`); - setPlayerArmour(client, getPlayerArmour(client)+amount); + logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s armour to ${getPlayerArmour(client) + amount}`); + setPlayerArmour(client, getPlayerArmour(client) + amount); } } @@ -469,7 +469,7 @@ function getServerName() { // =========================================================================== function createGamePickup(modelIndex, position, type) { - if(!isGameFeatureSupported("pickups")) { + if (!isGameFeatureSupported("pickups")) { return false; } return game.createPickup(modelIndex, position, type); @@ -478,7 +478,7 @@ function createGamePickup(modelIndex, position, type) { // =========================================================================== function createGameBlip(position, type = 0, size = 1, colour = toColour(255, 255, 255, 255)) { - if(!isGameFeatureSupported("blips")) { + if (!isGameFeatureSupported("blips")) { return false; } return game.createBlip(type, position, size, colour); @@ -487,7 +487,7 @@ function createGameBlip(position, type = 0, size = 1, colour = toColour(255, 255 // =========================================================================== function createGameObject(modelIndex, position) { - if(!isGameFeatureSupported("objects")) { + if (!isGameFeatureSupported("objects")) { return false; } return game.createObject(getGameConfig().objects[getGame()][modelIndex][0], position); @@ -496,13 +496,13 @@ function createGameObject(modelIndex, position) { // =========================================================================== function setElementOnAllDimensions(element, state) { - if(!isNull(element) && element != false) { - if(typeof element.netFlags != "undefined") { - if(typeof element.netFlags.onAllDimensions != "undefined") { + if (!isNull(element) && element != false) { + if (typeof element.netFlags != "undefined") { + if (typeof element.netFlags.onAllDimensions != "undefined") { element.netFlags.onAllDimensions = state; } } else { - if(typeof element.onAllDimensions != "undefined") { + if (typeof element.onAllDimensions != "undefined") { element.onAllDimensions = state; } } @@ -512,7 +512,7 @@ function setElementOnAllDimensions(element, state) { // =========================================================================== function destroyGameElement(element) { - if(!isNull(element) && element != false) { + if (!isNull(element) && element != false) { destroyElement(element); } } @@ -532,7 +532,7 @@ function getPlayerLastVehicle(client) { // =========================================================================== function isVehicleObject(vehicle) { - if(vehicle == null || vehicle == undefined) { + if (vehicle == null || vehicle == undefined) { return false; } return (vehicle.type == ELEMENT_VEHICLE); @@ -600,11 +600,11 @@ function setVehicleColours(vehicle, colour1, colour2, colour3 = -1, colour4 = -1 vehicle.colour1 = colour1; vehicle.colour2 = colour2; - if(colour3 != -1) { + if (colour3 != -1) { vehicle.colour3 = colour3; } - if(colour4 != -1) { + if (colour4 != -1) { vehicle.colour4 = colour4; } } @@ -612,7 +612,7 @@ function setVehicleColours(vehicle, colour1, colour2, colour3 = -1, colour4 = -1 // =========================================================================== function createGameVehicle(modelIndex, position, heading, toClient = null) { - if(areServerElementsSupported()) { + if (areServerElementsSupported()) { return game.createVehicle(getGameConfig().vehicles[getGame()][modelIndex][0], position, heading); } } @@ -620,9 +620,9 @@ function createGameVehicle(modelIndex, position, heading, toClient = null) { // =========================================================================== function createGamePed(modelIndex, position, heading, toClient = null) { - if(areServerElementsSupported()) { + if (areServerElementsSupported()) { let ped = game.createPed(getGameConfig().skins[getGame()][modelIndex][0], position); - if(ped) { + if (ped) { //ped.position = position; ped.heading = heading; return ped; @@ -635,10 +635,10 @@ function createGamePed(modelIndex, position, heading, toClient = null) { // =========================================================================== function getIsland(position) { - if(getGame() == VRR_GAME_GTA_III) { - if(position.x > 616) { + if (getGame() == VRR_GAME_GTA_III) { + if (position.x > 616) { return VRR_ISLAND_PORTLAND; - } else if(position.x < -283) { + } else if (position.x < -283) { return VRR_ISLAND_SHORESIDEVALE; } return VRR_ISLAND_STAUNTON; @@ -652,7 +652,7 @@ function getIsland(position) { // =========================================================================== function isValidVehicleModel(model) { - if(getVehicleModelIndexFromModel(model) != false) { + if (getVehicleModelIndexFromModel(model) != false) { return true; } @@ -662,7 +662,7 @@ function isValidVehicleModel(model) { // =========================================================================== function setGameTime(hour, minute, minuteDuration = 1000) { - if(isTimeSupported()) { + if (isTimeSupported()) { game.time.hour = hour; game.time.minute = minute; game.time.minuteDuration = minuteDuration; @@ -672,7 +672,7 @@ function setGameTime(hour, minute, minuteDuration = 1000) { // =========================================================================== function setGameWeather(weather) { - if(isWeatherSupported()) { + if (isWeatherSupported()) { mp.world.weather = weather; } } @@ -680,11 +680,11 @@ function setGameWeather(weather) { // =========================================================================== function setPlayerFightStyle(client, fightStyleId) { - if(!isPlayerSpawned(client)) { + if (!isPlayerSpawned(client)) { return false; } - if(!areFightStylesSupported()) { + if (!areFightStylesSupported()) { return false; } @@ -738,7 +738,7 @@ function setElementCollisionsEnabled(element, state) { // =========================================================================== function isTaxiVehicle(vehicle) { - if(taxiModels[getGame()].indexOf(vehicle.modelIndex) != -1) { + if (taxiModels[getGame()].indexOf(vehicle.modelIndex) != -1) { return true; } @@ -755,11 +755,11 @@ function getVehicleName(vehicle) { // =========================================================================== function getElementModel(element) { - if(typeof element.modelIndex != "undefined") { + if (typeof element.modelIndex != "undefined") { return element.modelIndex; } - if(typeof element.model != "undefined") { + if (typeof element.model != "undefined") { return element.model; } } @@ -773,7 +773,7 @@ function givePlayerWeaponAmmo(client, ammo) { // =========================================================================== function getPlayerWeapon(client) { - if(areServerElementsSupported(client)) { + if (areServerElementsSupported(client)) { return getPlayerPed(client).weapon; } else { return getPlayerData(client).syncWeapon; @@ -783,11 +783,11 @@ function getPlayerWeapon(client) { // =========================================================================== function connectToDatabase() { - if(getDatabaseConfig().usePersistentConnection) { - if(persistentDatabaseConnection == null) { + if (getDatabaseConfig().usePersistentConnection) { + if (persistentDatabaseConnection == null) { logToConsole(LOG_DEBUG, `[VRR.Database] Initializing database connection ...`); persistentDatabaseConnection = module.mysql.connect(getDatabaseConfig().host, getDatabaseConfig().user, getDatabaseConfig().pass, getDatabaseConfig().name, getDatabaseConfig().port); - if(persistentDatabaseConnection.error) { + if (persistentDatabaseConnection.error) { logToConsole(LOG_ERROR, `[VRR.Database] Database connection error: ${persistentDatabaseConnection.error}`); persistentDatabaseConnection = null; return false; @@ -801,7 +801,7 @@ function connectToDatabase() { } } else { let databaseConnection = module.mysql.connect(getDatabaseConfig().host, getDatabaseConfig().user, getDatabaseConfig().pass, getDatabaseConfig().name, getDatabaseConfig().port); - if(databaseConnection.error) { + if (databaseConnection.error) { logToConsole(LOG_ERROR, `[VRR.Database] Database connection error: ${persistentDatabaseConnection.error}`); return false; } else { @@ -813,11 +813,11 @@ function connectToDatabase() { // =========================================================================== function disconnectFromDatabase(dbConnection) { - if(!getDatabaseConfig().usePersistentConnection) { + if (!getDatabaseConfig().usePersistentConnection) { try { dbConnection.close(); logToConsole(LOG_DEBUG, `[VRR.Database] Database connection closed successfully`); - } catch(error) { + } catch (error) { logToConsole(LOG_ERROR, `[VRR.Database] Database connection could not be closed! (Error: ${error})`); } } @@ -828,7 +828,7 @@ function disconnectFromDatabase(dbConnection) { function queryDatabase(dbConnection, queryString, useThread = false) { logToConsole(LOG_DEBUG, `[VRR.Database] Query string: ${queryString}`); - if(useThread == true) { + if (useThread == true) { Promise.resolve().then(() => { let queryResult = dbConnection.query(queryString); return queryResult; @@ -841,11 +841,11 @@ function queryDatabase(dbConnection, queryString, useThread = false) { // =========================================================================== function escapeDatabaseString(dbConnection, unsafeString = "") { - if(!dbConnection) { + if (!dbConnection) { dbConnection = connectToDatabase(); } - if(typeof unsafeString == "string") { + if (typeof unsafeString == "string") { return dbConnection.escapeString(unsafeString); } return unsafeString; @@ -872,7 +872,7 @@ function getDatabaseError(dbConnection) { // =========================================================================== function freeDatabaseQuery(dbQuery) { - if(dbQuery != null) { + if (dbQuery != null) { dbQuery.free(); } return; @@ -889,26 +889,26 @@ function fetchQueryAssoc(dbQuery) { function quickDatabaseQuery(queryString) { let dbConnection = connectToDatabase(); let insertId = 0; - if(dbConnection) { + if (dbConnection) { //logToConsole(LOG_DEBUG, `[VRR.Database] Query string: ${queryString}`); let dbQuery = queryDatabase(dbConnection, queryString); - if(getDatabaseInsertId(dbConnection)) { + if (getDatabaseInsertId(dbConnection)) { insertId = getDatabaseInsertId(dbConnection); logToConsole(LOG_DEBUG, `[VRR.Database] Query returned insert id ${insertId}`); } - if(dbQuery) { + if (dbQuery) { try { freeDatabaseQuery(dbQuery); logToConsole(LOG_DEBUG, `[VRR.Database] Query result free'd successfully`); - } catch(error) { + } catch (error) { logToConsole(LOG_ERROR, `[VRR.Database] Query result could not be free'd! (Error: ${error})`); } } disconnectFromDatabase(dbConnection); - if(insertId != 0) { + if (insertId != 0) { return insertId; } @@ -920,26 +920,26 @@ function quickDatabaseQuery(queryString) { // =========================================================================== function executeDatabaseQueryCommand(command, params, client) { - if(areParamsEmpty(params)) { + if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - if(!targetClient) { + if (!targetClient) { messagePlayerError(client, "That player was not found!"); return false; } - if(targetCode == "") { + if (targetCode == "") { messagePlayerError(client, "You didn't enter any code!"); return false; } let success = quickDatabaseQuery(params); - if(!success) { + if (!success) { messagePlayerAlert(client, `Database query failed to execute: {ALTCOLOUR}${query}`); - } else if(typeof success != "boolean") { + } else if (typeof success != "boolean") { messagePlayeSuccess(client, `Database query successful: {ALTCOLOUR}${query}`); messagePlayerInfo(client, `Returns: ${success}`); } else { @@ -953,9 +953,9 @@ function executeDatabaseQueryCommand(command, params, client) { function setConstantsAsGlobalVariablesInDatabase() { let dbConnection = connectToDatabase(); let entries = Object.entries(global); - for(let i in entries) { + for (let i in entries) { logToConsole(LOG_DEBUG, `[VRR.Database] Checking entry ${i} (${entries[i]})`); - if(toString(i).slice(0, 3).indexOf("VRR_") != -1) { + if (toString(i).slice(0, 3).indexOf("VRR_") != -1) { logToConsole(LOG_DEBUG, `[VRR.Database] Adding ${i} (${entries[i]}) to database global variables`); } } @@ -967,13 +967,13 @@ function createDatabaseInsertQuery(tableName, data) { let fields = []; let values = []; - for(let i in data) { - if(data[i][1] != "undefined" && data[i][1] != NaN && data[i][0] != 'NaN') { - if(data[i][1] != "undefined" && data[i][1] != NaN && data[i][1] != 'NaN') { + for (let i in data) { + if (data[i][1] != "undefined" && data[i][1] != NaN && data[i][0] != 'NaN') { + if (data[i][1] != "undefined" && data[i][1] != NaN && data[i][1] != 'NaN') { fields.push(data[i][0]); - if(typeof data[i][1] == "string") { - if(data[i][1] == "{UNIXTIMESTAMP}") { + if (typeof data[i][1] == "string") { + if (data[i][1] == "{UNIXTIMESTAMP}") { values.push("UNIX_TIMESTAMP()"); } else { values.push(`'${data[i][1]}'`); @@ -994,11 +994,11 @@ function createDatabaseInsertQuery(tableName, data) { function createDatabaseUpdateQuery(tableName, data, whereClause) { let values = []; - for(let i in data) { - if(data[i][0] != "undefined" && data[i][0] != NaN && data[i][0] != 'NaN') { - if(data[i][1] != "undefined" && data[i][1] != NaN && data[i][1] != 'NaN') { - if(typeof data[i][1] == "string") { - if(data[i][1] == "{UNIXTIMESTAMP}") { + for (let i in data) { + if (data[i][0] != "undefined" && data[i][0] != NaN && data[i][0] != 'NaN') { + if (data[i][1] != "undefined" && data[i][1] != NaN && data[i][1] != 'NaN') { + if (typeof data[i][1] == "string") { + if (data[i][1] == "{UNIXTIMESTAMP}") { values.push(`${data[i][0]}=UNIX_TIMESTAMP()`); } else { values.push(`${data[i][0]}='${data[i][1]}'`); @@ -1038,8 +1038,8 @@ function getElementId(element) { function getClientFromIndex(index) { let clients = getClients(); - for(let i in clients) { - if(clients[i].index == index) { + for (let i in clients) { + if (clients[i].index == index) { return clients[i]; } } @@ -1078,7 +1078,7 @@ function getClosestCivilian(position) { // =========================================================================== function getVehiclesInRange(position, range) { - if(getGame() == VRR_GAME_GTA_IV) { + if (getGame() == VRR_GAME_GTA_IV) { return getServerData().vehicles.reduce((i, j) => (getDistance(position, i.syncPosition) <= getDistance(position, j.syncPosition)) ? i : j); } return getElementsByTypeInRange(ELEMENT_VEHICLE, position, range); @@ -1099,8 +1099,8 @@ function getClosestElementByType(elementType, position) { // =========================================================================== function getVehicleFirstEmptySeat(vehicle) { - for(let i = 0; i <= 4; i++) { - if(vehicle.getOccupant(i) == null) { + for (let i = 0; i <= 4; i++) { + if (vehicle.getOccupant(i) == null) { return i; } } @@ -1111,8 +1111,8 @@ function getVehicleFirstEmptySeat(vehicle) { // =========================================================================== function isVehicleTrain(vehicle) { - if(getGame() == VRR_GAME_GTA_III) { - if(vehicle.modelIndex == 124) { + if (getGame() == VRR_GAME_GTA_III) { + if (vehicle.modelIndex == 124) { return true; } } @@ -1155,9 +1155,9 @@ function setPlayerWantedLevel(client, wantedLevel) { // =========================================================================== function setElementStreamInDistance(element, distance) { - if(!isNull(element) && element != false) { - if(typeof element == "Entity") { - if(typeof element.streamInDistance != "undefined") { + if (!isNull(element) && element != false) { + if (typeof element == "Entity") { + if (typeof element.streamInDistance != "undefined") { element.streamInDistance = distance; } } @@ -1167,9 +1167,9 @@ function setElementStreamInDistance(element, distance) { // =========================================================================== function setElementStreamOutDistance(element, distance) { - if(!isNull(element) && element != false) { - if(typeof element == "Entity") { - if(typeof element.streamOutDistance != "undefined") { + if (!isNull(element) && element != false) { + if (typeof element == "Entity") { + if (typeof element.streamOutDistance != "undefined") { element.streamOutDistance = distance; } } @@ -1179,7 +1179,7 @@ function setElementStreamOutDistance(element, distance) { // =========================================================================== function getPlayerPed(client) { - if(getGame() == VRR_GAME_GTA_IV) { + if (getGame() == VRR_GAME_GTA_IV) { return getPlayerData(client).ped; } else { return client.player; @@ -1189,8 +1189,8 @@ function getPlayerPed(client) { // =========================================================================== function setEntityData(entity, dataName, dataValue, syncToClients = true) { - if(entity != null) { - if(areServerElementsSupported()) { + if (entity != null) { + if (areServerElementsSupported()) { return entity.setData(dataName, dataValue, syncToClients); } } @@ -1200,8 +1200,8 @@ function setEntityData(entity, dataName, dataValue, syncToClients = true) { // =========================================================================== function removeEntityData(entity, dataName) { - if(entity != null) { - if(areServerElementsSupported()) { + if (entity != null) { + if (areServerElementsSupported()) { return entity.removeData(dataName); } } @@ -1211,8 +1211,8 @@ function removeEntityData(entity, dataName) { // =========================================================================== function doesEntityDataExist(entity, dataName) { - if(entity != null) { - if(areServerElementsSupported()) { + if (entity != null) { + if (areServerElementsSupported()) { return (entity.getData(dataName) != null); } else { return false; @@ -1266,7 +1266,7 @@ function getGame() { // =========================================================================== function getCountryNameFromIP(ip) { - if(module.geoip.getCountryName(ip)) { + if (module.geoip.getCountryName(ip)) { return module.geoip.getCountryName(ip); } return false; @@ -1331,9 +1331,9 @@ function addServerCommandHandler(command, handlerFunction) { // =========================================================================== function addServerEventHandler(eventName, handlerFunction) { - addEventHandler(eventName, function(event, ...args) { + addEventHandler(eventName, function (event, ...args) { let result = handlerFunction.apply(this, args); - if(result == false) { + if (result == false) { event.preventDefault(); } }); @@ -1342,9 +1342,9 @@ function addServerEventHandler(eventName, handlerFunction) { // =========================================================================== function bindServerEventHandler(eventName, bindTo, handlerFunction) { - addEventHandler(eventName, bindTo, function(event, ...args) { + addEventHandler(eventName, bindTo, function (event, ...args) { let result = handlerFunction.apply(this, args); - if(result == false) { + if (result == false) { event.preventDefault(); } }); @@ -1374,4 +1374,12 @@ function setElementShownByDefault(element, state) { element.netFlags.defaultExistance = state; } +// =========================================================================== + +function createAttachedGameBlip(element, type, size, colour = toColour(255, 255, 255, 255)) { + if (isGameFeatureSupported("attachedBlips")) { + return game.createBlipAttachedTo(element, type, size, colour, true, false); + } +} + // =========================================================================== \ No newline at end of file