From d578b1a083ad457527aaa1c066d79db4c9e62019 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Wed, 8 Mar 2023 12:07:01 -0600 Subject: [PATCH 01/24] House stuff --- scripts/client/house.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/client/house.js b/scripts/client/house.js index 720931f7..5f633e25 100644 --- a/scripts/client/house.js +++ b/scripts/client/house.js @@ -8,7 +8,7 @@ // =========================================================================== class HouseData { - constructor(houseId, description, entrancePosition, blipModel, pickupModel, hasInterior) { + constructor(houseId, description, entrancePosition, blipModel, pickupModel, hasInterior, locked) { this.index = -1; this.houseId = houseId; this.description = description; @@ -19,14 +19,14 @@ class HouseData { this.rentPrice = 0; this.buyPrice = 0; this.blipId = -1; - this.locked = false; + this.locked = locked; } } // =========================================================================== function receiveHouseFromServer(houseId, isDeleted, description, entrancePosition, blipModel, pickupModel, buyPrice, rentPrice, hasInterior, locked) { - logToConsole(LOG_DEBUG, `[V.RP.House] Received house ${houseId} (${name}) from server`); + logToConsole(LOG_DEBUG, `[V.RP.House] Received house ${houseId} (${description}) from server`); if (!areServerElementsSupported() || getGame() == V_GAME_MAFIA_ONE || getGame() == V_GAME_GTA_IV) { if (isDeleted == true) { @@ -96,7 +96,7 @@ function receiveHouseFromServer(houseId, isDeleted, description, entrancePositio } } else { logToConsole(LOG_DEBUG, `[V.RP.House] House ${houseId} doesn't exist. Adding ...`); - let tempHouseData = new HouseData(houseId, description, entrancePosition, blipModel, pickupModel, hasInterior); + let tempHouseData = new HouseData(houseId, description, entrancePosition, blipModel, pickupModel, hasInterior, locked); if (blipModel != -1) { let blipId = createGameBlip(tempHouseData.blipModel, tempHouseData.entrancePosition, "House"); if (blipId != -1) { From 695e729c41300392d2e8960f24ca95ce9dfd9b59 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Wed, 8 Mar 2023 12:07:33 -0600 Subject: [PATCH 02/24] GTA SA won't load sounds for some reason --- scripts/client/payphone.js | 44 ++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/scripts/client/payphone.js b/scripts/client/payphone.js index a0ecc42e..37fa6df0 100644 --- a/scripts/client/payphone.js +++ b/scripts/client/payphone.js @@ -18,10 +18,11 @@ let payPhoneRingingSound = null; let payPhoneDialingSound = null; let payPhonePickupSound = null; let payPhoneHangupSound = null; -let payPhoneRingingSoundFilePath = "files/sounds/payphone/old-payphone-ring.mp3"; -let payPhoneDialingSoundFilePath = "files/sounds/payphone/old-payphone-dial.mp3"; -let payPhonePickupSoundFilePath = "files/sounds/payphone/old-payphone-pickup.mp3"; -let payPhoneHangupSoundFilePath = "files/sounds/payphone/old-payphone-hangup.mp3"; + +let payPhoneRingingSoundFilePath = ""; +let payPhoneDialingSoundFilePath = ""; +let payPhonePickupSoundFilePath = ""; +let payPhoneHangupSoundFilePath = ""; let ringingPayPhone = -1; @@ -40,6 +41,21 @@ class PayPhoneData { function initPayPhoneScript() { logToConsole(LOG_DEBUG, "[V.RP.PayPhone]: Initializing payphone script ..."); + + if (getGame() == V_GAME_MAFIA_ONE) { + payPhoneRingingSoundFilePath = "files/sounds/payphone/old-payphone-ring.mp3"; + payPhoneDialingSoundFilePath = "files/sounds/payphone/old-payphone-dial.mp3"; + payPhonePickupSoundFilePath = "files/sounds/payphone/old-payphone-pickup.mp3"; + payPhoneHangupSoundFilePath = "files/sounds/payphone/old-payphone-hangup.mp3"; + } else { + if (getGame() != V_GAME_GTA_SA) { + payPhoneRingingSoundFilePath = "files/sounds/payphone/old-payphone-ring.mp3"; + payPhoneDialingSoundFilePath = "files/sounds/payphone/old-payphone-dial.mp3"; + payPhonePickupSoundFilePath = "files/sounds/payphone/old-payphone-pickup.mp3"; + payPhoneHangupSoundFilePath = "files/sounds/payphone/old-payphone-hangup.mp3"; + } + } + //payPhoneRingingIndicatorImage = loadPayPhoneRingingIndicatorImage(); payPhoneRingingSound = loadPayPhoneRingingSound(); payPhoneDialingSound = loadPayPhoneDialingSound(); @@ -51,6 +67,10 @@ function initPayPhoneScript() { // =========================================================================== function loadPayPhoneRingingIndicatorImage() { + if (payPhoneRingingIndicatorImagePath == "") { + return null; + } + let imageStream = openFile(payPhoneRingingIndicatorImagePath); let tempImage = null; if (imageStream != null) { @@ -64,6 +84,10 @@ function loadPayPhoneRingingIndicatorImage() { // =========================================================================== function loadPayPhoneRingingSound() { + if (payPhoneRingingSoundFilePath == "") { + return null; + } + let soundStream = openFile(payPhoneRingingSoundFilePath); let tempSound = null; if (soundStream != null) { @@ -77,6 +101,10 @@ function loadPayPhoneRingingSound() { // =========================================================================== function loadPayPhoneDialingSound() { + if (payPhoneDialingSoundFilePath == "") { + return null; + } + let soundStream = openFile(payPhoneDialingSoundFilePath); let tempSound = null; if (soundStream != null) { @@ -94,6 +122,10 @@ function loadPayPhoneDialingSound() { // =========================================================================== function loadPayPhonePickupSound() { + if (payPhonePickupSoundFilePath == "") { + return null; + } + let soundStream = openFile(payPhonePickupSoundFilePath); let tempSound = null; if (soundStream != null) { @@ -111,6 +143,10 @@ function loadPayPhonePickupSound() { // =========================================================================== function loadPayPhoneHangupSound() { + if (payPhoneHangupSoundFilePath == "") { + return null; + } + let soundStream = openFile(payPhoneHangupSoundFilePath); let tempSound = null; if (soundStream != null) { From 17e6bef100b64605acc1d9d37dc77c68121a2f2c Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Wed, 8 Mar 2023 12:10:06 -0600 Subject: [PATCH 03/24] Who/when added business --- scripts/server/business.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/scripts/server/business.js b/scripts/server/business.js index 2dc73fab..0bfab887 100644 --- a/scripts/server/business.js +++ b/scripts/server/business.js @@ -95,6 +95,9 @@ class BusinessData { this.labelHelpType = V_PROPLABEL_INFO_NONE; + this.whoAdded = 0; + this.whenAdded = 0; + if (dbAssoc) { this.databaseId = toInteger(dbAssoc["biz_id"]); this.name = toString(dbAssoc["biz_name"]); @@ -124,9 +127,10 @@ class BusinessData { this.entranceFee = toInteger(dbAssoc["biz_entrance_fee"]); this.till = toInteger(dbAssoc["biz_till"]); - this.labelHelpType = toInteger(dbAssoc["biz_label_help_type"]); this.streamingRadioStation = toInteger(dbAssoc["biz_radio_station"]); + this.whoAdded = toInteger(dbAssoc["biz_who_added"]); + this.whenAdded = toInteger(dbAssoc["biz_when_added"]); } }; }; @@ -315,7 +319,9 @@ function createBusinessCommand(command, params, client) { -1, getPlayerInterior(client), getPlayerDimension(client), - getPlayerData(client).interiorScene); + getPlayerData(client).interiorScene, + getPlayerData(client).accountData.databaseId + ); messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} created business: {businessBlue}${params}`, true); } @@ -357,7 +363,7 @@ function createBusinessLocationCommand(command, params, client) { // =========================================================================== -function createBusiness(name, entrancePosition, exitPosition, entrancePickupModel = -1, entranceBlipModel = -1, entranceInterior = 0, entranceDimension = 0, entranceScene = -1) { +function createBusiness(name, entrancePosition, exitPosition, entrancePickupModel = -1, entranceBlipModel = -1, entranceInterior = 0, entranceDimension = 0, entranceScene = -1, whoAdded = defaultNoAccountId) { let tempBusinessData = new BusinessData(false); tempBusinessData.name = name; @@ -377,6 +383,9 @@ function createBusiness(name, entrancePosition, exitPosition, entrancePickupMode tempBusinessData.exitDimension = 0; tempBusinessData.exitScene = -1; + tempBusinessData.whoAdded = whoAdded; + tempBusinessData.whenAdded = getCurrentUnixTimestamp(); + tempBusinessData.needsSaved = true; let businessId = getServerData().businesses.push(tempBusinessData); setBusinessDataIndexes(); @@ -1933,6 +1942,8 @@ function saveBusinessToDatabase(businessId) { ["biz_radio_station", (getRadioStationData(tempBusinessData.streamingRadioStationIndex) != false) ? toInteger(getRadioStationData(tempBusinessData.streamingRadioStationIndex).databaseId) : -1], ["biz_custom_interior", boolToInt(tempBusinessData.customInterior)], ["biz_buy_price", tempBusinessData.buyPrice], + ["biz_who_added", tempBusinessData.whoAdded], + ["biz_when_added", tempBusinessData.whenAdded], //["biz_rent_price", tempBusinessData.rentPrice], ]; From 8728d1a32446b59d1bb83513b019d0d1dff9bc50 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Wed, 8 Mar 2023 22:21:04 -0600 Subject: [PATCH 04/24] New locale strings --- locale/arabic.json | 7 ++++++- locale/canadian-french.json | 7 ++++++- locale/chinese.json | 5 ++++- locale/english.json | 7 ++++++- locale/finnish.json | 7 ++++++- locale/french.json | 7 ++++++- locale/german.json | 7 ++++++- locale/japanese.json | 7 ++++++- locale/latvian.json | 7 ++++++- locale/lithuanian.json | 7 ++++++- locale/persian.json | 7 ++++++- locale/polish.json | 7 ++++++- locale/russian.json | 7 ++++++- locale/slovak.json | 7 ++++++- locale/spanish.json | 7 ++++++- 15 files changed, 88 insertions(+), 15 deletions(-) diff --git a/locale/arabic.json b/locale/arabic.json index 0cc6352d..ce3a08c2 100644 --- a/locale/arabic.json +++ b/locale/arabic.json @@ -782,5 +782,10 @@ "ResetActionTipsConfirm": "Are you sure you want to reset all seen action tips?", "ActionTipsReset": "All seen action tips have been reset.", "NormalChatDisabled": "Normal chat is disabled by server admin. Use chat commands instead.", - "GlobalChatDisabled": "Global out-of-character chat is disabled by server admin" + "GlobalChatDisabled": "Global out-of-character chat is disabled by server admin", + "CantEditJobUniforms": "You can't edit job uniforms!", + "PlayerNotSurrendered": "The player must be surrendered (hands up, be knocked out, or tazed)!", + "PlayerRemovedFromJob": "You removed {1} from the job", + "RemovedFromJob": "You were removed from the job by {1}", + "UnableToCallPlayer": "{1} can't be called right now" } \ No newline at end of file diff --git a/locale/canadian-french.json b/locale/canadian-french.json index 01244e86..b647bbd4 100644 --- a/locale/canadian-french.json +++ b/locale/canadian-french.json @@ -780,5 +780,10 @@ "ResetActionTipsConfirm": "Are you sure you want to reset all seen action tips?", "ActionTipsReset": "All seen action tips have been reset.", "NormalChatDisabled": "Normal chat is disabled by server admin. Use chat commands instead.", - "GlobalChatDisabled": "Global out-of-character chat is disabled by server admin" + "GlobalChatDisabled": "Global out-of-character chat is disabled by server admin", + "CantEditJobUniforms": "You can't edit job uniforms!", + "PlayerNotSurrendered": "The player must be surrendered (hands up, be knocked out, or tazed)!", + "PlayerRemovedFromJob": "You removed {1} from the job", + "RemovedFromJob": "You were removed from the job by {1}", + "UnableToCallPlayer": "{1} can't be called right now" } \ No newline at end of file diff --git a/locale/chinese.json b/locale/chinese.json index 1833111a..0fdedb0c 100644 --- a/locale/chinese.json +++ b/locale/chinese.json @@ -778,5 +778,8 @@ "ResetActionTipsConfirm": "Are you sure you want to reset all seen action tips?", "ActionTipsReset": "All seen action tips have been reset.", "NormalChatDisabled": "Normal chat is disabled by server admin. Use chat commands instead.", - "GlobalChatDisabled": "Global out-of-character chat is disabled by server admin" + "GlobalChatDisabled": "Global out-of-character chat is disabled by server admin", + "CantEditJobUniforms": "You can't edit job uniforms!", + "PlayerNotSurrendered": "The player must be surrendered (hands up, be knocked out, or tazed)!", + "UnableToCallPlayer": "{1} can't be called right now" } diff --git a/locale/english.json b/locale/english.json index 7788d2d6..d9af8d60 100644 --- a/locale/english.json +++ b/locale/english.json @@ -789,5 +789,10 @@ "JobInviteAlreadyHasJob": "That player already has a job!", "JobInviteRequest": "{1} invited you to the {2} job.", "CantAddJobMembers": "You can't invite new members to the job!", - "CantRemoveJobMembers": "You can't remove members from the job!" + "CantRemoveJobMembers": "You can't remove members from the job!", + "CantEditJobUniforms": "You can't edit job uniforms!", + "PlayerNotSurrendered": "The player must be surrendered (hands up, be knocked out, or tazed)!", + "PlayerRemovedFromJob": "You removed {1} from the job", + "RemovedFromJob": "You were removed from the job by {1}", + "UnableToCallPlayer": "{1} can't be called right now" } diff --git a/locale/finnish.json b/locale/finnish.json index f15ded21..b513bbe3 100644 --- a/locale/finnish.json +++ b/locale/finnish.json @@ -777,5 +777,10 @@ "ResetActionTipsConfirm": "Are you sure you want to reset all seen action tips?", "ActionTipsReset": "All seen action tips have been reset.", "NormalChatDisabled": "Normal chat is disabled by server admin. Use chat commands instead.", - "GlobalChatDisabled": "Global out-of-character chat is disabled by server admin" + "GlobalChatDisabled": "Global out-of-character chat is disabled by server admin", + "CantEditJobUniforms": "You can't edit job uniforms!", + "PlayerNotSurrendered": "The player must be surrendered (hands up, be knocked out, or tazed)!", + "PlayerRemovedFromJob": "You removed {1} from the job", + "RemovedFromJob": "You were removed from the job by {1}", + "UnableToCallPlayer": "{1} can't be called right now" } diff --git a/locale/french.json b/locale/french.json index 4e015367..1b23a885 100644 --- a/locale/french.json +++ b/locale/french.json @@ -778,5 +778,10 @@ "ResetActionTipsConfirm": "Are you sure you want to reset all seen action tips?", "ActionTipsReset": "All seen action tips have been reset.", "NormalChatDisabled": "Normal chat is disabled by server admin. Use chat commands instead.", - "GlobalChatDisabled": "Global out-of-character chat is disabled by server admin" + "GlobalChatDisabled": "Global out-of-character chat is disabled by server admin", + "CantEditJobUniforms": "You can't edit job uniforms!", + "PlayerNotSurrendered": "The player must be surrendered (hands up, be knocked out, or tazed)!", + "PlayerRemovedFromJob": "You removed {1} from the job", + "RemovedFromJob": "You were removed from the job by {1}", + "UnableToCallPlayer": "{1} can't be called right now" } \ No newline at end of file diff --git a/locale/german.json b/locale/german.json index 683b5d5f..dbfc7b58 100644 --- a/locale/german.json +++ b/locale/german.json @@ -777,5 +777,10 @@ "ResetActionTipsConfirm": "Are you sure you want to reset all seen action tips?", "ActionTipsReset": "All seen action tips have been reset.", "NormalChatDisabled": "Normal chat is disabled by server admin. Use chat commands instead.", - "GlobalChatDisabled": "Global out-of-character chat is disabled by server admin" + "GlobalChatDisabled": "Global out-of-character chat is disabled by server admin", + "CantEditJobUniforms": "You can't edit job uniforms!", + "PlayerNotSurrendered": "The player must be surrendered (hands up, be knocked out, or tazed)!", + "PlayerRemovedFromJob": "You removed {1} from the job", + "RemovedFromJob": "You were removed from the job by {1}", + "UnableToCallPlayer": "{1} can't be called right now" } \ No newline at end of file diff --git a/locale/japanese.json b/locale/japanese.json index c4ba8fe6..31c2cb77 100644 --- a/locale/japanese.json +++ b/locale/japanese.json @@ -778,5 +778,10 @@ "ResetActionTipsConfirm": "Are you sure you want to reset all seen action tips?", "ActionTipsReset": "All seen action tips have been reset.", "NormalChatDisabled": "Normal chat is disabled by server admin. Use chat commands instead.", - "GlobalChatDisabled": "Global out-of-character chat is disabled by server admin" + "GlobalChatDisabled": "Global out-of-character chat is disabled by server admin", + "CantEditJobUniforms": "You can't edit job uniforms!", + "PlayerNotSurrendered": "The player must be surrendered (hands up, be knocked out, or tazed)!", + "PlayerRemovedFromJob": "You removed {1} from the job", + "RemovedFromJob": "You were removed from the job by {1}", + "UnableToCallPlayer": "{1} can't be called right now" } \ No newline at end of file diff --git a/locale/latvian.json b/locale/latvian.json index 039cd0d0..d51e8fed 100644 --- a/locale/latvian.json +++ b/locale/latvian.json @@ -780,5 +780,10 @@ "ResetActionTipsConfirm": "Are you sure you want to reset all seen action tips?", "ActionTipsReset": "All seen action tips have been reset.", "NormalChatDisabled": "Normal chat is disabled by server admin. Use chat commands instead.", - "GlobalChatDisabled": "Global out-of-character chat is disabled by server admin" + "GlobalChatDisabled": "Global out-of-character chat is disabled by server admin", + "CantEditJobUniforms": "You can't edit job uniforms!", + "PlayerNotSurrendered": "The player must be surrendered (hands up, be knocked out, or tazed)!", + "PlayerRemovedFromJob": "You removed {1} from the job", + "RemovedFromJob": "You were removed from the job by {1}", + "UnableToCallPlayer": "{1} can't be called right now" } \ No newline at end of file diff --git a/locale/lithuanian.json b/locale/lithuanian.json index 9707649a..4dae276d 100644 --- a/locale/lithuanian.json +++ b/locale/lithuanian.json @@ -779,5 +779,10 @@ "ResetActionTipsConfirm": "Are you sure you want to reset all seen action tips?", "ActionTipsReset": "All seen action tips have been reset.", "NormalChatDisabled": "Normal chat is disabled by server admin. Use chat commands instead.", - "GlobalChatDisabled": "Global out-of-character chat is disabled by server admin" + "GlobalChatDisabled": "Global out-of-character chat is disabled by server admin", + "CantEditJobUniforms": "You can't edit job uniforms!", + "PlayerNotSurrendered": "The player must be surrendered (hands up, be knocked out, or tazed)!", + "PlayerRemovedFromJob": "You removed {1} from the job", + "RemovedFromJob": "You were removed from the job by {1}", + "UnableToCallPlayer": "{1} can't be called right now" } diff --git a/locale/persian.json b/locale/persian.json index c6fb505f..4c0505a9 100644 --- a/locale/persian.json +++ b/locale/persian.json @@ -779,5 +779,10 @@ "ResetActionTipsConfirm": "Are you sure you want to reset all seen action tips?", "ActionTipsReset": "All seen action tips have been reset.", "NormalChatDisabled": "Normal chat is disabled by server admin. Use chat commands instead.", - "GlobalChatDisabled": "Global out-of-character chat is disabled by server admin" + "GlobalChatDisabled": "Global out-of-character chat is disabled by server admin", + "CantEditJobUniforms": "You can't edit job uniforms!", + "PlayerNotSurrendered": "The player must be surrendered (hands up, be knocked out, or tazed)!", + "PlayerRemovedFromJob": "You removed {1} from the job", + "RemovedFromJob": "You were removed from the job by {1}", + "UnableToCallPlayer": "{1} can't be called right now" } \ No newline at end of file diff --git a/locale/polish.json b/locale/polish.json index 7b1d1f61..a5f7d5dc 100644 --- a/locale/polish.json +++ b/locale/polish.json @@ -777,5 +777,10 @@ "ResetActionTipsConfirm": "Are you sure you want to reset all seen action tips?", "ActionTipsReset": "All seen action tips have been reset.", "NormalChatDisabled": "Normal chat is disabled by server admin. Use chat commands instead.", - "GlobalChatDisabled": "Global out-of-character chat is disabled by server admin" + "GlobalChatDisabled": "Global out-of-character chat is disabled by server admin", + "CantEditJobUniforms": "You can't edit job uniforms!", + "PlayerNotSurrendered": "The player must be surrendered (hands up, be knocked out, or tazed)!", + "PlayerRemovedFromJob": "You removed {1} from the job", + "RemovedFromJob": "You were removed from the job by {1}", + "UnableToCallPlayer": "{1} can't be called right now" } diff --git a/locale/russian.json b/locale/russian.json index ac48e711..597d5a94 100644 --- a/locale/russian.json +++ b/locale/russian.json @@ -778,5 +778,10 @@ "ResetActionTipsConfirm": "Are you sure you want to reset all seen action tips?", "ActionTipsReset": "All seen action tips have been reset.", "NormalChatDisabled": "Normal chat is disabled by server admin. Use chat commands instead.", - "GlobalChatDisabled": "Global out-of-character chat is disabled by server admin" + "GlobalChatDisabled": "Global out-of-character chat is disabled by server admin", + "CantEditJobUniforms": "You can't edit job uniforms!", + "PlayerNotSurrendered": "The player must be surrendered (hands up, be knocked out, or tazed)!", + "PlayerRemovedFromJob": "You removed {1} from the job", + "RemovedFromJob": "You were removed from the job by {1}", + "UnableToCallPlayer": "{1} can't be called right now" } diff --git a/locale/slovak.json b/locale/slovak.json index 65468699..e411d3ba 100644 --- a/locale/slovak.json +++ b/locale/slovak.json @@ -778,5 +778,10 @@ "ResetActionTipsConfirm": "Are you sure you want to reset all seen action tips?", "ActionTipsReset": "All seen action tips have been reset.", "NormalChatDisabled": "Normal chat is disabled by server admin. Use chat commands instead.", - "GlobalChatDisabled": "Global out-of-character chat is disabled by server admin" + "GlobalChatDisabled": "Global out-of-character chat is disabled by server admin", + "CantEditJobUniforms": "You can't edit job uniforms!", + "PlayerNotSurrendered": "The player must be surrendered (hands up, be knocked out, or tazed)!", + "PlayerRemovedFromJob": "You removed {1} from the job", + "RemovedFromJob": "You were removed from the job by {1}", + "UnableToCallPlayer": "{1} can't be called right now" } \ No newline at end of file diff --git a/locale/spanish.json b/locale/spanish.json index 262dbde7..7aa19e3b 100644 --- a/locale/spanish.json +++ b/locale/spanish.json @@ -784,5 +784,10 @@ "ResetActionTipsConfirm": "Are you sure you want to reset all seen action tips?", "ActionTipsReset": "All seen action tips have been reset.", "NormalChatDisabled": "Normal chat is disabled by server admin. Use chat commands instead.", - "GlobalChatDisabled": "Global out-of-character chat is disabled by server admin" + "GlobalChatDisabled": "Global out-of-character chat is disabled by server admin", + "CantEditJobUniforms": "You can't edit job uniforms!", + "PlayerNotSurrendered": "The player must be surrendered (hands up, be knocked out, or tazed)!", + "PlayerRemovedFromJob": "You removed {1} from the job", + "RemovedFromJob": "You were removed from the job by {1}", + "UnableToCallPlayer": "{1} can't be called right now" } From fd02988d5d7dd61ac3ef320a7a8e5ee886d043fa Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Wed, 8 Mar 2023 22:21:26 -0600 Subject: [PATCH 05/24] Move local money --- scripts/client/core.js | 1 - scripts/client/timers.js | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/client/core.js b/scripts/client/core.js index 2fb68155..30ee06d5 100644 --- a/scripts/client/core.js +++ b/scripts/client/core.js @@ -104,7 +104,6 @@ let serverData = { }; let localPlayerMoney = 0; -let localPlayerMoneyInterval = null; let currencyString = "${AMOUNT}"; diff --git a/scripts/client/timers.js b/scripts/client/timers.js index 87c7e101..e7ce60d3 100644 --- a/scripts/client/timers.js +++ b/scripts/client/timers.js @@ -7,6 +7,10 @@ // TYPE: Client (JavaScript) // =========================================================================== +let localPlayerMoneyInterval = null; + +// =========================================================================== + function initTimersScript() { logToConsole(LOG_DEBUG, "[V.RP.Timers]: Initializing timer script ..."); logToConsole(LOG_DEBUG, "[V.RP.Timers]: Timers script initialized!"); @@ -15,6 +19,7 @@ function initTimersScript() { // =========================================================================== function initTimers() { + localPlayerMoneyInterval = setInterval(updateLocalPlayerMoney, 1000 * 5); } // =========================================================================== \ No newline at end of file From 85388f0cb89f4dd04d497c323261a0b6bb20d659 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Wed, 8 Mar 2023 22:21:41 -0600 Subject: [PATCH 06/24] Improve client script load a bit --- scripts/client/event.js | 10 +++++----- scripts/client/startup.js | 11 +++++++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/scripts/client/event.js b/scripts/client/event.js index d38cc572..387cd000 100644 --- a/scripts/client/event.js +++ b/scripts/client/event.js @@ -16,9 +16,6 @@ function initEventScript() { // =========================================================================== function addAllEventHandlers() { - addEventHandler("OnResourceStart", onResourceStart); - addEventHandler("OnResourceReady", onResourceReady); - addEventHandler("OnResourceStop", onResourceStop); addEventHandler("OnProcess", onProcess); addEventHandler("OnKeyUp", onKeyUp); addEventHandler("OnDrawnHUD", onDrawnHUD); @@ -94,8 +91,11 @@ function onResourceStop(event, resource) { function onResourceReady(event, resource) { if (resource == thisResource) { logToConsole(LOG_DEBUG | LOG_WARN, `[V.RP.Event] onResourceReady called - Sending signal to server`); - loadLocaleConfig(); - sendResourceReadySignalToServer(); + + setTimeout(function () { + initClientScripts(); + sendResourceReadySignalToServer(); + }, 500); } } diff --git a/scripts/client/startup.js b/scripts/client/startup.js index 172a83c3..73fe48e7 100644 --- a/scripts/client/startup.js +++ b/scripts/client/startup.js @@ -25,6 +25,11 @@ function initClientScripts() { initPayPhoneScript(); initTimersScript(); initJobScript(); + initItemScript(); + initBusinessScript(); + initHouseScript(); + + loadLocaleConfig(); addAllNetworkHandlers(); @@ -203,6 +208,8 @@ function setUpInitialGame() { // =========================================================================== -initClientScripts(); +addEventHandler("OnResourceStart", onResourceStart); +addEventHandler("OnResourceReady", onResourceReady); +addEventHandler("OnResourceStop", onResourceStop); -// =========================================================================== +// =========================================================================== \ No newline at end of file From 2a56241c60a311d49859f593d5dbf252d372bf8d Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Wed, 8 Mar 2023 22:22:41 -0600 Subject: [PATCH 07/24] Init house script --- scripts/client/house.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/client/house.js b/scripts/client/house.js index 5f633e25..1b67c746 100644 --- a/scripts/client/house.js +++ b/scripts/client/house.js @@ -25,6 +25,13 @@ class HouseData { // =========================================================================== +function initHouseScript() { + logToConsole(LOG_DEBUG, "[V.RP.House]: Initializing house script ..."); + logToConsole(LOG_DEBUG, "[V.RP.House]: House script initialized!"); +} + +// =========================================================================== + function receiveHouseFromServer(houseId, isDeleted, description, entrancePosition, blipModel, pickupModel, buyPrice, rentPrice, hasInterior, locked) { logToConsole(LOG_DEBUG, `[V.RP.House] Received house ${houseId} (${description}) from server`); From 3b28340c7249e2683bf107676e45a7cb30de75b2 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Wed, 8 Mar 2023 22:22:56 -0600 Subject: [PATCH 08/24] Check for payphone sounds before trying to use --- scripts/client/payphone.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/scripts/client/payphone.js b/scripts/client/payphone.js index 37fa6df0..30707afe 100644 --- a/scripts/client/payphone.js +++ b/scripts/client/payphone.js @@ -164,6 +164,10 @@ function loadPayPhoneHangupSound() { // =========================================================================== function processPayPhonesDistance() { + if (payPhoneRingingSound == null) { + return false; + } + let tempRingingPhone = -1; for (let i in getServerData().payPhones) { if (getServerData().payPhones[i].state == V_PAYPHONE_STATE_RINGING) { @@ -267,6 +271,11 @@ function removePayPhonesFromClient() { // =========================================================================== function payPhoneDial() { + if (payPhoneDialingSound == null) { + logToConsole(LOG_DEBUG | LOG_ERROR, "[V.RP.PayPhone]: Attempted to play payphone dial sound, but sound object is null"); + return false; + } + logToConsole(LOG_DEBUG, "[V.RP.PayPhone]: Playing payphone dial sound"); payPhoneDialingSound.play(); } @@ -274,6 +283,11 @@ function payPhoneDial() { // =========================================================================== function payPhoneHangup() { + if (payPhoneHangupSound == null) { + logToConsole(LOG_DEBUG | LOG_ERROR, "[V.RP.PayPhone]: Attempted to play payphone hangup sound, but sound object is null"); + return false; + } + logToConsole(LOG_DEBUG, "[V.RP.PayPhone]: Playing payphone hangup sound"); payPhoneHangupSound.play(); } @@ -281,6 +295,11 @@ function payPhoneHangup() { // =========================================================================== function payPhonePickup() { + if (payPhonePickupSound == null) { + logToConsole(LOG_DEBUG | LOG_ERROR, "[V.RP.PayPhone]: Attempted to play payphone pickup sound, but sound object is null"); + return false; + } + logToConsole(LOG_DEBUG, "[V.RP.PayPhone]: Playing payphone pickup sound"); payPhonePickupSound.play(); } From 6af7339ac7178a35fb5c058e8c540080988bd00e Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Wed, 8 Mar 2023 22:23:33 -0600 Subject: [PATCH 09/24] Check if player data is false when kicking all --- scripts/server/client.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/server/client.js b/scripts/server/client.js index b3aec166..d6d641eb 100644 --- a/scripts/server/client.js +++ b/scripts/server/client.js @@ -207,9 +207,11 @@ function resetClientStuff(client) { function kickAllClients() { getClients().forEach((client) => { - getPlayerData(client).customDisconnectReason = "ServerRestarting"; + if (getPlayerData(client) != false) { + getPlayerData(client).customDisconnectReason = "ServerRestarting"; + } disconnectPlayer(client); - }) + }); } // =========================================================================== From d7b4ce86e5d7c8b70ad452c1c3adaccf752f6765 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Wed, 8 Mar 2023 22:23:55 -0600 Subject: [PATCH 10/24] Add job uniform name/rank + search cmds --- scripts/server/command.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/server/command.js b/scripts/server/command.js index 65af8a8c..0be50045 100644 --- a/scripts/server/command.js +++ b/scripts/server/command.js @@ -348,9 +348,10 @@ function loadCommands() { new CommandData("use", useItemCommand, "", getStaffFlagValue("None"), true, false, "Uses the currently equipped item"), new CommandData("inv", listPlayerInventoryCommand, "", getStaffFlagValue("None"), true, false, "Shows the items in your inventory"), new CommandData("inventory", listPlayerInventoryCommand, "", getStaffFlagValue("None"), true, false, "Shows the items in your inventory"), + new CommandData("search", listOtherPlayerInventoryCommand, "", getStaffFlagValue("None"), true, false, "Shows the items in a player's inventory"), new CommandData("items", listItemInventoryCommand, "", getStaffFlagValue("None"), true, false, "Shows the items stored in a container item"), - new CommandData("vehtrunk", listVehicleTrunkInventoryCommand, "", getStaffFlagValue("None"), true, false, "Shows the items in a vehicle's trunk"), + //new CommandData("vehtrunk", listVehicleTrunkInventoryCommand, "", getStaffFlagValue("None"), true, false, "Shows the items in a vehicle's trunk"), new CommandData("houseitems", listHouseInventoryCommand, "", getStaffFlagValue("None"), true, false, "Shows the items in the house's storage"), new CommandData("bizstorage", listBusinessStorageInventoryCommand, "", getStaffFlagValue("None"), true, false, "Shows the items in the business's extra storage (not buyable)"), new CommandData("bizfloor", listBusinessFloorInventoryCommand, "", getStaffFlagValue("None"), true, false, "Shows the items that can be bought from the business"), @@ -428,6 +429,8 @@ function loadCommands() { new CommandData("deljobroute", deleteJobRouteCommand, "", getStaffFlagValue("ManageJobs"), true, false), new CommandData("deljobrouteloc", deleteJobRouteLocationCommand, "", getStaffFlagValue("ManageJobs"), true, false), new CommandData("deljobroutelocation", deleteJobRouteLocationCommand, "", getStaffFlagValue("ManageJobs"), true, false), + new CommandData("jobuniformname", setJobUniformNameCommand, " ", getStaffFlagValue("ManageJobs"), true, false), + new CommandData("jobuniformrank", setJobUniformMinimumRankCommand, " ", getStaffFlagValue("ManageJobs"), true, false), new CommandData("jobroutelocpos", setJobRouteLocationPositionCommand, "", getStaffFlagValue("ManageJobs"), true, false), new CommandData("jobroutename", setJobRouteNameCommand, "", getStaffFlagValue("ManageJobs"), true, false), new CommandData("jobroutepay", setJobRoutePayCommand, "", getStaffFlagValue("ManageJobs"), true, false), From 573201834d569cfebaf5b686bc67711215eb2546 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Wed, 8 Mar 2023 22:24:13 -0600 Subject: [PATCH 11/24] Some dev utils stuff --- scripts/server/developer.js | 61 ++++++++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 4 deletions(-) diff --git a/scripts/server/developer.js b/scripts/server/developer.js index 26437927..9f90a66a 100644 --- a/scripts/server/developer.js +++ b/scripts/server/developer.js @@ -593,11 +593,10 @@ function togglePauseSavingToDatabaseCommand(command, params, client) { function createAccountDataForNewServer(serverId) { let dbConnection = connectToDatabase(); - let dbQuery = false; if (dbConnection) { - dbQuery = queryDatabase(dbConnection, `SELECT * FROM acct_main`); - if (dbQuery) { - let dbQueryString = `INSERT INTO acct_svr (acct_svr_acct, acct_svr_svr) VALUES (${accountDatabaseId}, ${serverId})`; + let accounts = fetchQueryAssoc(dbConnection, `SELECT * FROM acct_main`); + for (let i in accounts) { + let dbQueryString = `INSERT INTO acct_svr (acct_svr_acct, acct_svr_svr) VALUES (${accounts[i]["acct_id"]}, ${serverId})`; quickDatabaseQuery(dbQueryString); } } @@ -605,6 +604,60 @@ function createAccountDataForNewServer(serverId) { // =========================================================================== +function fixMissingAccountServerData() { + let dbConnection = connectToDatabase(); + console.log(`Connection: ${dbConnection}`); + if (dbConnection != false) { + let accounts = fetchQueryAssoc(dbConnection, `SELECT * FROM acct_main WHERE acct_id > 12`); + console.log(`Accounts: ${accounts.length}`); + let servers = fetchQueryAssoc(dbConnection, `SELECT * FROM svr_main`); + console.log(`Servers: ${servers.length}`); + + for (let i in accounts) { + let serverAccounts = fetchQueryAssoc(dbConnection, `SELECT * FROM acct_svr WHERE acct_svr_acct = ${accounts[i]["acct_id"]}`) + console.log(`Server accounts for ${accounts[i]["acct_id"]}: ${serverAccounts.length}`); + for (let k in servers) { + let check = serverAccounts.find((sa) => sa["acct_svr_svr"] == servers[k]["svr_id"]); + console.log(`Check server: ${servers[k]["svr_id"]}. Amount ${check}`); + if (typeof check == "undefined") { + let dbQueryString = `INSERT INTO acct_svr (acct_svr_acct, acct_svr_svr) VALUES (${accounts[i]["acct_id"]}, ${servers[k]["svr_id"]})`; + //console.log(dbQueryString); + quickDatabaseQuery(dbQueryString); + } + } + } + } +} + +// =========================================================================== + +function fixMissingSubAccountServerData() { + let dbConnection = connectToDatabase(); + console.log(`Connection: ${dbConnection}`); + if (dbConnection != false) { + let subAccounts = fetchQueryAssoc(dbConnection, `SELECT * FROM sacct_main`); + console.log(`SubAccounts: ${subAccounts.length}`); + let servers = fetchQueryAssoc(dbConnection, `SELECT * FROM svr_main`); + console.log(`Servers: ${servers.length}`); + + for (let i in subAccounts) { + let serverAccounts = fetchQueryAssoc(dbConnection, `SELECT * FROM sacct_svr WHERE sacct_svr_sacct = ${subAccounts[i]["sacct_id"]}`) + console.log(`Server accounts for ${subAccounts[i]["sacct_id"]}: ${serverAccounts.length}`); + for (let k in servers) { + let check = serverAccounts.find((sa) => sa["sacct_svr_server"] == servers[k]["svr_id"]); + console.log(`Check server: ${servers[k]["svr_id"]}. Amount ${check}`); + if (typeof check == "undefined") { + let dbQueryString = `INSERT INTO sacct_svr (sacct_svr_sacct, sacct_svr_server) VALUES (${subAccounts[i]["sacct_id"]}, ${servers[k]["svr_id"]})`; + //console.log(dbQueryString); + quickDatabaseQuery(dbQueryString); + } + } + } + } +} + +// =========================================================================== + function streamAudioURLToAllPlayersCommand(command, params, client) { if (areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); From 2d66d081139e65c87015db69253b886408e56bc2 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Wed, 8 Mar 2023 22:24:32 -0600 Subject: [PATCH 12/24] Send house to player test --- scripts/server/house.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/scripts/server/house.js b/scripts/server/house.js index 31b8a5a8..948f7a18 100644 --- a/scripts/server/house.js +++ b/scripts/server/house.js @@ -1801,9 +1801,21 @@ function updateHousePickupLabelData(houseId) { if (!areServerElementsSupported() || getGame() == V_GAME_MAFIA_ONE || getGame() == V_GAME_GTA_IV) { if (houseData == false) { - sendHouseToPlayer(null, houseId, true, "", false, -1, -1, 0, 0, false, false, false); + sendHouseToPlayer(null, houseId, true, "", false, -1, -1, 0, 0, false, false); } else { - sendHouseToPlayer(null, houseId, false, houseData.description, houseData.entrancePosition, getHouseEntranceBlipModelForNetworkEvent(houseId), getHouseEntrancePickupModelForNetworkEvent(houseId), houseData.buyPrice, houseData.rentPrice, houseData.hasInterior, houseData.locked); + sendHouseToPlayer( + null, + houseId, + false, + houseData.description, + houseData.entrancePosition, + getHouseEntranceBlipModelForNetworkEvent(houseId), + getHouseEntrancePickupModelForNetworkEvent(houseId), + houseData.buyPrice, + houseData.rentPrice, + houseData.hasInterior, + houseData.locked + ); } return false; } From 4581de603b197193348db9bddd61cf5fcb1fa5f0 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Wed, 8 Mar 2023 22:24:50 -0600 Subject: [PATCH 13/24] Add search cmd handler --- scripts/server/item.js | 48 ++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/scripts/server/item.js b/scripts/server/item.js index 2e73a2ec..968efd8c 100644 --- a/scripts/server/item.js +++ b/scripts/server/item.js @@ -2400,26 +2400,46 @@ function getBestItemToTake(client, slot) { * */ function listPlayerInventoryCommand(command, params, client) { - //let targetClient = client; - //if(!areParamsEmpty(client)) { - // if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("BasicModeration"))) { - // if(targetClient == false) { - // sendMessageToPlayer(client, getLocaleString(client, "InvalidPlayer")); - // return false; - // } - // - // targetClient = getPlayerFromParams(params); - // } - //} - //showPlayerInventoryToPlayer(client, targetClient); - showPlayerInventoryToPlayer(client, client); - markPlayerActionTipSeen(client, "ViewInventory"); } // =========================================================================== +/** + * This is a command handler function. + * + * @param {string} command - The command name used by the player + * @param {string} params - The parameters/args string used with the command by the player + * @param {Client} client - The client/player that used the command + * @return {bool} Whether or not the command was successful + * + */ +function listOtherPlayerInventoryCommand(command, params, client) { + if (areParamsEmpty(params)) { + messagePlayerSyntax(client, getCommandSyntaxText(client, command)); + return false; + } + + let targetClient = getPlayerFromParams(params); + + if (!targetClient) { + messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); + return false; + } + + if (!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageItems"))) { + if (!isPlayerSurrendered(targetClient)) { + messagePlayerError(client, getLocaleString(client, "MustBeSurrendered")); + return false; + } + } + + showPlayerInventoryToPlayer(client, targetClient); +} + +// =========================================================================== + /** * This is a command handler function. * From 6f0937360f4b44cce3a8b2821195851fcf8669c2 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Wed, 8 Mar 2023 22:26:25 -0600 Subject: [PATCH 14/24] Add job uniform cmds + WL/BL utils --- scripts/server/job.js | 321 ++++++++++++++++++++++++++++++++---------- 1 file changed, 245 insertions(+), 76 deletions(-) diff --git a/scripts/server/job.js b/scripts/server/job.js index b6a5170b..29eb75a8 100644 --- a/scripts/server/job.js +++ b/scripts/server/job.js @@ -60,8 +60,8 @@ class JobData { this.walkieTalkieFrequency = 0; this.index = -1; this.needsSaved = false; - this.whoCreated = 0; - this.whenCreated = 0; + this.whoAdded = 0; + this.whenAdded = 0; /** @type {Array.} */ this.equipment = []; @@ -96,8 +96,8 @@ class JobData { this.whiteListEnabled = dbAssoc["job_wl"]; this.blackListEnabled = dbAssoc["job_bl"]; this.walkieTalkieFrequency = dbAssoc["job_walkietalkiefreq"]; - this.whoCreated = dbAssoc["job_who_added"]; - this.whenCreated = dbAssoc["job_when_added"]; + this.whoAdded = dbAssoc["job_who_added"]; + this.whenAdded = dbAssoc["job_when_added"]; this.equipment = []; this.uniforms = []; @@ -136,8 +136,8 @@ class JobRouteData { //this.failedMessage = ""; this.locationArriveMessage = ""; this.locationGotoMessage = ""; - this.whoCreated = 0; - this.whenCreated = 0; + this.whoAdded = 0; + this.whenAdded = 0; this.sphere = null; /** @type {Array.} */ @@ -158,8 +158,8 @@ class JobRouteData { this.vehicleColour1 = toInteger(dbAssoc["job_route_veh_colour1"]); this.vehicleColour2 = toInteger(dbAssoc["job_route_veh_colour2"]); this.detail = toInteger(dbAssoc["job_route_detail"]); - this.whoCreated = dbAssoc["job_route_who_added"]; - this.whenCreated = dbAssoc["job_route_when_added"]; + this.whoAdded = dbAssoc["job_route_who_added"]; + this.whenAdded = dbAssoc["job_route_when_added"]; this.sphere = null; } } @@ -186,8 +186,8 @@ class JobRouteLocationData { this.type = V_JOB_ROUTE_LOC_TYPE_NONE; this.gotoMessage = ""; this.departMessage = ""; - this.whoCreated = 0; - this.whenCreated = 0; + this.whoAdded = 0; + this.whenAdded = 0; if (dbAssoc) { this.databaseId = toInteger(dbAssoc["job_route_loc_id"]); @@ -199,8 +199,8 @@ class JobRouteLocationData { this.pay = toInteger(dbAssoc["job_route_loc_pay"]); this.arriveMessage = toInteger(dbAssoc["job_route_loc_arrive_msg"]); this.gotoMessage = toInteger(dbAssoc["job_route_loc_goto_msg"]); - this.whoCreated = dbAssoc["job_route_loc_who_added"]; - this.whenCreated = dbAssoc["job_route_loc_when_added"]; + this.whoAdded = dbAssoc["job_route_loc_who_added"]; + this.whenAdded = dbAssoc["job_route_loc_when_added"]; } } }; @@ -221,8 +221,8 @@ class JobEquipmentData { this.index = -1; this.jobIndex = -1; this.needsSaved = false; - this.whoCreated = 0; - this.whenCreated = 0; + this.whoAdded = 0; + this.whenAdded = 0; /** @type {Array.} */ this.items = []; @@ -233,8 +233,8 @@ class JobEquipmentData { this.name = dbAssoc["job_equip_name"]; this.requiredRank = dbAssoc["job_equip_minrank"]; this.enabled = dbAssoc["job_equip_enabled"]; - this.whoCreated = dbAssoc["job_equip_who_added"]; - this.whenCreated = dbAssoc["job_equip_when_added"]; + this.whoAdded = dbAssoc["job_equip_who_added"]; + this.whenAdded = dbAssoc["job_equip_when_added"]; } } }; @@ -254,8 +254,8 @@ class JobEquipmentItemData { this.index = -1; this.jobIndex = -1; this.needsSaved = false; - this.whoCreated = 0; - this.whenCreated = 0; + this.whoAdded = 0; + this.whenAdded = 0; if (dbAssoc) { this.databaseId = dbAssoc["job_equip_item_id"]; @@ -263,8 +263,8 @@ class JobEquipmentItemData { this.itemType = dbAssoc["job_equip_item_type"]; this.value = dbAssoc["job_equip_item_value"]; this.enabled = dbAssoc["job_equip_item_enabled"]; - this.whoCreated = dbAssoc["job_equip_item_who_added"]; - this.whenCreated = dbAssoc["job_equip_item_when_added"]; + this.whoAdded = dbAssoc["job_equip_item_who_added"]; + this.whenAdded = dbAssoc["job_equip_item_when_added"]; } } }; @@ -285,8 +285,8 @@ class JobUniformData { this.index = -1; this.jobIndex = -1; this.needsSaved = false; - this.whoCreated = 0; - this.whenCreated = 0; + this.whoAdded = 0; + this.whenAdded = 0; /* this.bodyParts = { @@ -317,8 +317,8 @@ class JobUniformData { this.requiredRank = dbAssoc["job_uniform_minrank"]; this.skin = dbAssoc["job_uniform_skin"]; this.enabled = intToBool(dbAssoc["job_uniform_enabled"]); - this.whoCreated = dbAssoc["job_uniform_who_added"]; - this.whenCreated = dbAssoc["job_uniform_when_added"]; + this.whoAdded = dbAssoc["job_uniform_who_added"]; + this.whenAdded = dbAssoc["job_uniform_when_added"]; /* this.bodyParts = { @@ -364,8 +364,8 @@ class JobLocationData { this.jobIndex = -1; this.needsSaved = false; this.routeCache = []; - this.whoCreated = 0; - this.whenCreated = 0; + this.whoAdded = 0; + this.whenAdded = 0; if (dbAssoc) { this.databaseId = dbAssoc["job_loc_id"]; @@ -376,8 +376,8 @@ class JobLocationData { this.enabled = intToBool(dbAssoc["job_loc_enabled"]); this.interior = dbAssoc["job_loc_int"]; this.dimension = dbAssoc["job_loc_vw"]; - this.whoCreated = dbAssoc["job_loc_who_added"]; - this.whenCreated = dbAssoc["job_loc_when_added"]; + this.whoAdded = dbAssoc["job_loc_who_added"]; + this.whenAdded = dbAssoc["job_loc_when_added"]; } } }; @@ -397,8 +397,8 @@ class JobRankData { this.level = 0; this.enabled = false; this.pay = 0; - this.whoCreated = 0; - this.whenCreated = 0; + this.whoAdded = 0; + this.whenAdded = 0; this.flags = 0; this.needsSaved = false; this.public = false; @@ -410,8 +410,8 @@ class JobRankData { this.level = toInteger(dbAssoc["job_rank_level"]); this.enabled = intToBool(dbAssoc["job_rank_enabled"]); this.pay = toInteger(dbAssoc["job_rank_pay"]); - this.whoCreated = toInteger(dbAssoc["job_rank_who_added"]); - this.whenCreated = toInteger(dbAssoc["job_rank_when_added"]); + this.whoAdded = toInteger(dbAssoc["job_rank_who_added"]); + this.whenAdded = toInteger(dbAssoc["job_rank_when_added"]); this.flags = toInteger(dbAssoc["job_rank_flags"]); this.public = intToBool(dbAssoc["job_rank_public"]); } @@ -429,16 +429,16 @@ class JobWhiteListData { this.index = -1; this.jobIndex = -1; this.needsSaved = false; - this.whoCreated = 0; - this.whenCreated = 0; + this.whoAdded = 0; + this.whenAdded = 0; 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"]; - this.whoCreated = dbAssoc["job_wl_who_added"]; - this.whenCreated = dbAssoc["job_wl_when_added"]; + this.whoAdded = dbAssoc["job_wl_who_added"]; + this.whenAdded = dbAssoc["job_wl_when_added"]; } } }; @@ -454,16 +454,16 @@ class JobBlackListData { this.index = -1; this.jobIndex = -1; this.needsSaved = false; - this.whoCreated = 0; - this.whenCreated = 0; + this.whoAdded = 0; + this.whenAdded = 0; 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"]; - this.whoCreated = dbAssoc["job_bl_who_added"]; - this.whenCreated = dbAssoc["job_bl_when_added"]; + this.whoAdded = dbAssoc["job_bl_who_added"]; + this.whenAdded = dbAssoc["job_bl_when_added"]; } } }; @@ -1818,7 +1818,9 @@ function setPlayerJobRankCommand(command, params, client) { } let targetClient = getPlayerFromParams(getParam(params, " ", 1)); - let rankIndex = getJobRankFromParams(jobIndex, params.split(" ").slice(2).join(" ")); + let rankParam = getJobRankFromParams(jobIndex, params.split(" ").slice(2).join(" ")); + + let rankIndex = getJobRankFromParams(jobIndex, rankParam); if (!targetClient) { messagePlayerError(client, getLocaleString(client, "InvalidPlayer")); @@ -2763,7 +2765,7 @@ function setAllJobDataIndexes() { // =========================================================================== -function createJobLocation(jobId, position, interior, dimension, whoCreated) { +function createJobLocation(jobId, position, interior, dimension, whoAdded) { let jobLocationData = new JobLocationData(false); jobLocationData.position = position; jobLocationData.jobId = getJobData(jobId).databaseId; @@ -2772,8 +2774,8 @@ function createJobLocation(jobId, position, interior, dimension, whoCreated) { jobLocationData.enabled = true; jobLocationData.jobIndex = jobId; jobLocationData.needsSaved = true; - jobLocationData.whoCreated = whoCreated; - jobLocationData.whenCreated = getCurrentUnixTimestamp(); + jobLocationData.whoAdded = whoAdded; + jobLocationData.whenAdded = getCurrentUnixTimestamp(); getServerData().jobs[jobId].locations.push(jobLocationData); let newSlot = getServerData().jobs[jobId].locations.length - 1; @@ -2814,8 +2816,8 @@ function saveJobToDatabase(jobData) { ["job_walkietalkiefreq", jobData.walkieTalkieFrequency], ["job_wl", jobData.whiteListEnabled], ["job_bl", jobData.blackListEnabled], - ["job_who_added", jobData.whoCreated], - ["job_when_added", jobData.whenCreated], + ["job_who_added", jobData.whoAdded], + ["job_when_added", jobData.whenAdded], ]; let dbQuery = null; @@ -2863,8 +2865,8 @@ function saveJobRankToDatabase(jobRankData) { ["job_rank_flags", jobRankData.flags], ["job_rank_pay", jobRankData.pay], ["job_rank_level", jobRankData.level], - ["job_rank_who_added", jobRankData.whoCreated], - ["job_rank_when_added", jobRankData.whenCreated], + ["job_rank_who_added", jobRankData.whoAdded], + ["job_rank_when_added", jobRankData.whenAdded], ["job_rank_public", boolToInt(jobRankData.public)], ]; @@ -2930,8 +2932,8 @@ function saveJobRouteToDatabase(jobRouteData) { ["job_route_loc_goto_msg", safeLocationNextMessage], ["job_route_pay", jobRouteData.pay], ["job_route_detail", jobRouteData.detail], - ["job_route_who_added", jobRouteData.whoCreated], - ["job_route_when_added", jobRouteData.whenCreated], + ["job_route_who_added", jobRouteData.whoAdded], + ["job_route_when_added", jobRouteData.whenAdded], ]; let dbQuery = null; @@ -2987,8 +2989,8 @@ function saveJobRouteLocationToDatabase(jobRouteLocationData) { ["job_route_loc_z", jobRouteLocationData.position.z], ["job_route_loc_pay", jobRouteLocationData.pay], ["job_route_loc_delay", jobRouteLocationData.stopDelay], - ["job_route_loc_who_added", jobRouteLocationData.whoCreated], - ["job_route_loc_when_added", jobRouteLocationData.whenCreated], + ["job_route_loc_who_added", jobRouteLocationData.whoAdded], + ["job_route_loc_when_added", jobRouteLocationData.whenAdded], ]; let dbQuery = null; @@ -3042,8 +3044,8 @@ function saveJobLocationToDatabase(jobLocationData) { ["job_loc_pos_z", jobLocationData.position.z], ["job_loc_int", jobLocationData.interior], ["job_loc_vw", jobLocationData.dimension], - ["job_loc_who_added", jobLocationData.whoCreated], - ["job_loc_when_added", jobLocationData.whenCreated], + ["job_loc_who_added", jobLocationData.whoAdded], + ["job_loc_when_added", jobLocationData.whenAdded], ]; let dbQuery = null; @@ -3097,12 +3099,12 @@ function saveJobEquipmentToDatabase(jobEquipmentData) { ["job_equip_enabled", boolToInt(jobEquipmentData.enabled)], ["job_equip_minrank", jobLocationData.requiredRank], ["job_equip_name", safeName], - ["job_equip_who_added", jobEquipmentData.whoCreated], - ["job_equip_when_added", jobEquipmentData.whenCreated], + ["job_equip_who_added", jobEquipmentData.whoAdded], + ["job_equip_when_added", jobEquipmentData.whenAdded], ]; let dbQuery = null; - if (tempJobRouteData.databaseId == 0) { + if (jobEquipmentData.databaseId == 0) { let queryString = createDatabaseInsertQuery("job_equip", data); dbQuery = queryDatabase(dbConnection, queryString); jobEquipmentData.databaseId = getDatabaseInsertId(dbConnection); @@ -3150,12 +3152,12 @@ function saveJobEquipmentItemToDatabase(jobEquipmentItemData) { ["job_equip_item_enabled", boolToInt(jobEquipmentItemData.enabled)], ["job_equip_item_type", jobEquipmentItemData.itemType], ["job_equip_item_value", jobEquipmentItemData.value], - ["job_equip_item_who_added", jobEquipmentItemData.whoCreated], - ["job_equip_item_when_added", jobEquipmentItemData.whenCreated], + ["job_equip_item_who_added", jobEquipmentItemData.whoAdded], + ["job_equip_item_when_added", jobEquipmentItemData.whenAdded], ]; let dbQuery = null; - if (tempJobRouteData.databaseId == 0) { + if (jobEquipmentItemData.databaseId == 0) { let queryString = createDatabaseInsertQuery("job_equip_item", data); dbQuery = queryDatabase(dbConnection, queryString); jobEquipmentItemData.databaseId = getDatabaseInsertId(dbConnection); @@ -3199,17 +3201,17 @@ function saveJobUniformToDatabase(jobUniformData) { if (dbConnection) { let safeName = escapeDatabaseString(dbConnection, jobUniformData.name); let data = [ - ["job_uniform_job", jobUniformData.jobId], + ["job_uniform_job", jobUniformData.job], ["job_uniform_enabled", boolToInt(jobUniformData.enabled)], ["job_uniform_minrank", jobUniformData.requiredRank], ["job_uniform_name", safeName], - ["job_uniform_model", jobUniformData.skin], - ["job_uniform_who_added", jobUniformData.whoCreated], - ["job_uniform_when_added", jobUniformData.whenCreated], + ["job_uniform_skin", jobUniformData.skin], + ["job_uniform_who_added", jobUniformData.whoAdded], + ["job_uniform_when_added", jobUniformData.whenAdded], ]; let dbQuery = null; - if (tempJobRouteData.databaseId == 0) { + if (jobUniformData.databaseId == 0) { let queryString = createDatabaseInsertQuery("job_uniform", data); dbQuery = queryDatabase(dbConnection, queryString); jobUniformData.databaseId = getDatabaseInsertId(dbConnection); @@ -3686,14 +3688,14 @@ function createJobUniformCommand(command, params, client) { return false; } - createJobUniform(jobId, skinIndex); + createJobUniform(jobId, skinIndex, getPlayerData(client).accountData.databaseId); messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} created uniform with skin {ALTCOLOUR}${getSkinNameFromIndex(skinIndex)} (${getGameConfig().skins[getGame()][skinIndex][0]}){MAINCOLOUR} for job {jobYellow}${getJobData(jobId).name}`); return true; } // =========================================================================== -function createJobRoute(routeName, closestJobLocation, whoCreated = defaultNoAccountId) { +function createJobRoute(routeName, closestJobLocation, whoAdded = defaultNoAccountId) { let tempJobRouteData = new JobRouteData(false); tempJobRouteData.name = routeName; tempJobRouteData.jobId = closestJobLocation.jobId; @@ -3708,8 +3710,8 @@ function createJobRoute(routeName, closestJobLocation, whoCreated = defaultNoAcc tempJobRouteData.finishMessage = `You have finished the {ALTCOLOUR}{JOBROUTENAME}{MAINCOLOUR} route and {ALTCOLOUR}{JOBROUTEPAY}{MAINCOLOUR} has been added to your next paycheck!`; tempJobRouteData.locationArriveMessage = `You arrived at a stop.`; tempJobRouteData.locationGotoMessage = `Drive to the next stop.`; - tempJobRouteData.whoCreated = whoCreated; - tempJobRouteData.whenCreated = getCurrentUnixTimestamp(); + tempJobRouteData.whoAdded = whoAdded; + tempJobRouteData.whenAdded = getCurrentUnixTimestamp(); let routeId = getJobData(closestJobLocation.jobIndex).routes.push(tempJobRouteData); saveJobRouteToDatabase(tempJobRouteData); @@ -3719,7 +3721,7 @@ function createJobRoute(routeName, closestJobLocation, whoCreated = defaultNoAcc // =========================================================================== -function createJobRouteLocation(routeLocationName, position, jobRouteData, whoCreated = defaultNoAccountId, delay = 0, arriveMessage = "", gotoMessage = "", type = V_JOB_ROUTE_LOC_TYPE_NONE) { +function createJobRouteLocation(routeLocationName, position, jobRouteData, whoAdded = defaultNoAccountId, delay = 0, arriveMessage = "", gotoMessage = "", type = V_JOB_ROUTE_LOC_TYPE_NONE) { let tempJobRouteLocationData = new JobRouteLocationData(false); tempJobRouteLocationData.name = routeLocationName; tempJobRouteLocationData.routeId = jobRouteData.databaseId; @@ -3731,8 +3733,8 @@ function createJobRouteLocation(routeLocationName, position, jobRouteData, whoCr tempJobRouteLocationData.arriveMessage = arriveMessage; tempJobRouteLocationData.gotoMessage = gotoMessage; tempJobRouteLocationData.type = type; - tempJobRouteLocationData.whoCreated = whoCreated; - tempJobRouteLocationData.whenCreated = getCurrentUnixTimestamp(); + tempJobRouteLocationData.whoAdded = whoAdded; + tempJobRouteLocationData.whenAdded = getCurrentUnixTimestamp(); getJobData(jobRouteData.jobIndex).routes[jobRouteData.index].locations.push(tempJobRouteLocationData); //saveJobRouteLocationToDatabase(tempJobRouteLocationData); @@ -3741,13 +3743,16 @@ function createJobRouteLocation(routeLocationName, position, jobRouteData, whoCr // =========================================================================== -function createJobUniform(jobId, skinIndex) { +function createJobUniform(jobId, skinIndex, whoAdded = defaultNoAccountId) { let tempJobUniformData = new JobUniformData(false); tempJobUniformData.skin = skinIndex; tempJobUniformData.jobIndex = jobId; tempJobUniformData.job = getJobData(jobId).databaseId; tempJobUniformData.name = getGameConfig().skins[getGame()][skinIndex][1]; + tempJobUniformData.whoAdded = whoAdded; + tempJobUniformData.whenAdded = getCurrentUnixTimestamp(); tempJobUniformData.needsSaved = true; + tempJobUniformData.enabled = true; getJobData(jobId).uniforms.push(tempJobUniformData); @@ -3822,6 +3827,11 @@ function deleteJobUniformCommand(command, params, client) { return false; } + if (doesPlayerHaveJobPermission(client, getJobFlagValue("ManageUniforms"))) { + messagePlayerError(client, "You can't edit job uniforms!"); + return false; + } + if (isNaN(uniformIndex)) { messagePlayerError(client, getLocaleString(client, "MustBeNumber")); return false; @@ -3841,6 +3851,82 @@ function deleteJobUniformCommand(command, params, client) { // =========================================================================== +function setJobUniformMinimumRankCommand(command, params, client) { + let uniformIndex = getParam(params, " ", 1); + let newRankLevel = getParam(params, " ", 2); + + if (!getJobData(jobId)) { + messagePlayerError(client, getLocaleString(client, "InvalidJob")); + return false; + } + + let jobIndex = getPlayerJob(client); + + if (doesPlayerHaveJobPermission(client, getJobFlagValue("ManageUniforms"))) { + messagePlayerError(client, "You can't edit job uniforms!"); + return false; + } + + if (isNaN(uniformIndex)) { + messagePlayerError(client, getLocaleString(client, "MustBeNumber")); + return false; + } + + if (isNaN(newRankLevel)) { + messagePlayerError(client, getLocaleString(client, "MustBeNumber")); + return false; + } + + if (typeof getJobData(jobId).uniforms[uniformIndex] == "undefined") { + messagePlayerError(client, getLocaleString(client, "InvalidJobUniform")); + return false; + } + + if (newRankLevel < 0) { + messagePlayerError(client, "The rank can't be negative!"); + return false; + } + + getJobData(jobIndex).uniforms[uniformIndex].requiredRank = newRankLevel; + getJobData(jobIndex).uniforms[uniformIndex].needsSaved = true; + messagePlayerSuccess(client, `You set job uniform ${getJobUniformData(jobIndex, uniformIndex).name}'s minimum rank to ${newRankLevel}`); +} + +// =========================================================================== + +function setJobUniformNameCommand(command, params, client) { + let uniformIndex = getParam(params, " ", 1); + let newName = params.slice(1).join(" "); + + if (!getJobData(jobId)) { + messagePlayerError(client, getLocaleString(client, "InvalidJob")); + return false; + } + + let jobIndex = getPlayerJob(client); + + if (doesPlayerHaveJobPermission(client, getJobFlagValue("ManageUniforms"))) { + messagePlayerError(client, "You can't edit job uniforms!"); + return false; + } + + if (isNaN(uniformIndex)) { + messagePlayerError(client, getLocaleString(client, "InvalidJobUniform")); + return false; + } + + if (typeof getJobData(jobId).uniforms[uniformIndex] == "undefined") { + messagePlayerError(client, getLocaleString(client, "InvalidJobUniform")); + return false; + } + + getJobData(jobIndex).uniforms[uniformIndex].name = newName; + getJobData(jobIndex).uniforms[uniformIndex].needsSaved = true; + messagePlayerSuccess(client, `You set job uniform ${getJobUniformData(jobIndex, uniformIndex).name}'s name to ${newName}`); +} + +// =========================================================================== + function getJobFromParams(params) { if (isNaN(params)) { for (let i in getServerData().jobs) { @@ -4315,6 +4401,31 @@ function getJobRankFromParams(jobIndex, params) { // =========================================================================== +/** + * @param {Number} jobIndex - The job index to search uniforms for + * @param {String} params - The params to search for + * @return {Number} The data index of a matching job + */ +function getJobUniformFromParams(jobIndex, params) { + if (isNaN(params)) { + for (let i in getJobData(jobIndex).uniforms) { + if ((toLowerCase(getJobData(jobIndex).uniforms[i].name).indexOf(toLowerCase(params)) != -1)) { + return i; + } + } + } else { + for (let i in getJobData(jobIndex).uniforms) { + if (getJobData(jobIndex).uniforms[i].level == toInteger(params)) { + return i; + } + } + } + + return false; +} + +// =========================================================================== + function getJobRoutesCommand(command, params, client) { let closestJobLocation = getClosestJobLocation(getPlayerPosition(client)); @@ -4326,7 +4437,7 @@ function getJobRoutesCommand(command, params, client) { let jobData = getJobData(closestJobLocation.jobIndex); let jobRoutesList = jobData.routes.map(function (r) { - return `{chatBoxListIndex}${r.index}: ${(r.enabled) ? "{softGreen}" : "{softRed}"}${r.name} {ALTCOLOUR}(${r.locations.length} stops, added ${getTimeDifferenceDisplay(getCurrentUnixTimestamp(), r.whenCreated)} ago)`; + return `{chatBoxListIndex}${r.index}: ${(r.enabled) ? "{softGreen}" : "{softRed}"}${r.name} {ALTCOLOUR}(${r.locations.length} stops, added ${getTimeDifferenceDisplay(getCurrentUnixTimestamp(), r.whenAdded)} ago)`; }); let chunkedList = splitArrayIntoChunks(jobRoutesList, 2); @@ -4368,8 +4479,8 @@ function getJobRouteInfoCommand(command, params, client) { [`ID`, `${jobRouteData.index}/${jobRouteData.databaseId}`], [`Job`, `${jobData.name}`], [`Name`, `${jobRouteData.name}`], - [`Added By`, `${loadAccountFromId(jobRouteData.whoCreated).name}`], - [`Added On`, `${new Date(jobRouteData.whenCreated * 1000).toLocaleDateString("en-GB")}`], + [`Added By`, `${loadAccountFromId(jobRouteData.whoAdded).name}`], + [`Added On`, `${new Date(jobRouteData.whenAdded * 1000).toLocaleDateString("en-GB")}`], [`Enabled`, `${getYesNoFromBool(jobRouteData.enabled)}`], [`Stops`, `${jobRouteData.locations.length}`], [`Pay`, `${getCurrencyString(jobRouteData.pay)}`], @@ -4462,4 +4573,62 @@ function jobUninviteCommand(command, params, client) { getPlayerCurrentSubAccount(targetClient).jobRankIndex = -1; } +// =========================================================================== + +function addPlayerToJobBlackList(client, jobIndex, whoAdded = defaultNoAccountId) { + let tempJobBlackListData = new JobBlackListData(false); + tempJobBlackListData.subAccount = getPlayerCurrentSubAccount(client).databaseId; + tempJobBlackListData.jobIndex = jobIndex; + tempJobBlackListData.job = getJobData(jobIndex).databaseId; + tempJobBlackListData.whoAdded = whoAdded; + tempJobBlackListData.whenAdded = getCurrentUnixTimestamp(); + tempJobBlackListData.needsSaved = true; + + getJobData(jobIndex).blackList.push(tempJobBlackListData); + setAllJobDataIndexes(); +} + +// =========================================================================== + +function addPlayerToJobWhiteList(client, jobIndex, whoAdded = defaultNoAccountId) { + let tempJobWhiteListData = new JobWhiteListData(false); + tempJobWhiteListData.subAccount = getPlayerCurrentSubAccount(client).databaseId; + tempJobWhiteListData.jobIndex = jobIndex; + tempJobWhiteListData.job = getJobData(jobIndex).databaseId; + tempJobWhiteListData.whoAdded = whoAdded; + tempJobWhiteListData.whenAdded = getCurrentUnixTimestamp(); + tempJobWhiteListData.needsSaved = true; + + getJobData(jobIndex).whiteList.push(tempJobWhiteListData); + setAllJobDataIndexes(); +} + +// =========================================================================== + +function removePlayerFromJobBlackList(client, jobIndex, whoDeleted = defaultNoAccountId) { + quickDatabaseQuery(`UPDATE job_bl SET job_bl_deleted = 1, job_bl_who_deleted = ${whoDeleted}, job_bl_when_deleted = UNIX_TIMESTAMP() WHERE job_bl_sacct = ${getPlayerCurrentSubAccount(client).databaseId}`) + + for (let i in getServerData().jobs[jobIndex].blackList) { + if (getServerData().jobs[jobIndex].blackList[i].subAccount == getPlayerCurrentSubAccount(client).databaseId) { + getServerData().jobs[jobIndex].splice(i, 1); + } + } + + setAllJobDataIndexes(); +} + +// =========================================================================== + +function removePlayerFromJobWhiteList(client, jobIndex, whoDeleted = defaultNoAccountId) { + quickDatabaseQuery(`UPDATE job_wl SET job_wl_deleted = 1, job_wl_who_deleted = ${whoDeleted}, job_wl_when_deleted = UNIX_TIMESTAMP() WHERE job_wl_sacct = ${getPlayerCurrentSubAccount(client).databaseId}`) + + for (let i in getServerData().jobs[jobIndex].whiteList) { + if (getServerData().jobs[jobIndex].whiteList[i].subAccount == getPlayerCurrentSubAccount(client).databaseId) { + getServerData().jobs[jobIndex].splice(i, 1); + } + } + + setAllJobDataIndexes(); +} + // =========================================================================== \ No newline at end of file From 259eb3346c557d8e90f50307d5b59340591c825a Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Wed, 8 Mar 2023 22:41:24 -0600 Subject: [PATCH 15/24] Workaround for player pos in veh (Mafia 1) --- scripts/server/native/connected.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/scripts/server/native/connected.js b/scripts/server/native/connected.js index e17bb845..7aba0f7e 100644 --- a/scripts/server/native/connected.js +++ b/scripts/server/native/connected.js @@ -62,8 +62,19 @@ function getPlayerPosition(client) { if (!areServerElementsSupported()) { return getPlayerData(client).syncPosition; } else { - if (getPlayerPed(client) != null) { - return getPlayerPed(client).position; + // Check if Mafia 1, player position is bugged when in a vehicle + if (getGame() == V_GAME_MAFIA_ONE) { + if (isPlayerInAnyVehicle(client)) { + return getPlayerVehicle(client).position; + } else { + return getPlayerPed(client).position; + } + } else { + if (getPlayerPed(client) != null) { + return getPlayerPed(client).position; + } else { + return toVector3(0.0, 0.0, 0.0); + } } } } @@ -166,6 +177,10 @@ function isPlayerInAnyVehicle(client) { if (!areServerElementsSupported()) { return (getPlayerData().syncVehicle != null); } else { + if (getPlayerPed(client) == null) { + return false; + } + return (getPlayerPed(client).vehicle != null); } } From bd4681aa9b2537e87e3789b964331476925d9633 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Wed, 8 Mar 2023 22:41:40 -0600 Subject: [PATCH 16/24] Unable to call player message --- scripts/server/payphone.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/server/payphone.js b/scripts/server/payphone.js index ac398409..778a905f 100644 --- a/scripts/server/payphone.js +++ b/scripts/server/payphone.js @@ -219,14 +219,14 @@ function callPayPhoneCommand(command, params, client) { } if (getPlayerData(targetClient).usingPayPhone != -1 || isPlayerRestrained(targetClient) || isPlayerSurrendered(targetClient) || isPlayerMuted(targetClient) || !isPlayerSpawned(targetClient)) { - messagePlayerError(client, getLocaleString(client, "UnableToCallPlayer")); + messagePlayerError(client, getLocaleString(client, "UnableToCallPlayer", getCharacterFullName(targetClient))); return false; } let closestPayPhoneTarget = getClosestPayPhone(getPlayerPosition(targetClient)); if (closestPayPhoneTarget == closestPayPhone) { - messagePlayerError(client, getLocaleString(client, "UnableToCallPlayer")); + messagePlayerError(client, getLocaleString(client, "UnableToCallPlayer", getCharacterFullName(targetClient))); return false; } From 4999ab3ac5de1409f351734f4ba5b6a4e85b8a04 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Wed, 8 Mar 2023 22:42:07 -0600 Subject: [PATCH 17/24] Check job/clan rank, remove if fucked --- scripts/server/subaccount.js | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/scripts/server/subaccount.js b/scripts/server/subaccount.js index 4b870db5..6814c0c5 100644 --- a/scripts/server/subaccount.js +++ b/scripts/server/subaccount.js @@ -208,8 +208,20 @@ function loadSubAccountsFromAccount(accountId) { let clanRankIndex = getClanRankIndexFromDatabaseId(clanIndex, tempSubAccount.clanRank); if (!getClanRankData(clanIndex, clanRankIndex)) { let newClanRankIndex = getLowestClanRank(clanIndex); - tempSubAccount.clanRank = getClanRankData(clanIndex, newClanRankIndex).databaseId - tempSubAccount.clanRankIndex = newClanRankIndex; + if (getClanRankData(clanIndex, newClanRankIndex) != false) { + console.log(LOG_DEBUG | LOG_WARN, `[V.RP.SubAccount]: Clan ${clanIndex} has no rank ${tempSubAccount.clanRank}! Using lowest rank ${newClanRankIndex} instead.`); + tempSubAccount.clanRank = getClanRankData(clanIndex, newClanRankIndex).databaseId; + tempSubAccount.clanRankIndex = newClanRankIndex; + } else { + // Somethings fucked. Clan rank invalid, and no other rank to use. Removing from clan. + logToConsole(LOG_DEBUG | LOG_ERROR, `[V.RP.SubAccount]: Clan ${clanIndex} has no rank ${tempSubAccount.clanRank}, and no other rank to use. Removing from clan ...`); + tempSubAccount.clan = 0; + tempSubAccount.clanRank = 0; + tempSubAccount.clanIndex = -1; + tempSubAccount.clanRankIndex = -1; + tempSubAccount.clanTitle = ""; + tempSubAccount.clanFlags = 0; + } } else { tempSubAccount.clanRankIndex = clanRankIndex; } @@ -231,7 +243,19 @@ function loadSubAccountsFromAccount(accountId) { let jobRankIndex = getJobRankIndexFromDatabaseId(jobIndex, tempSubAccount.jobRank); if (!getJobRankData(jobIndex, jobRankIndex)) { let newJobRankIndex = getLowestJobRank(jobIndex); - console.log(`[V.RP.SubAccount]: Job ${jobIndex} has no rank ${tempSubAccount.jobRank}! Using lowest rank ${newJobRankIndex} instead.`); + if (getJobRankData(jobIndex, newJobRankIndex) != false) { + console.log(LOG_DEBUG | LOG_WARN, `[V.RP.SubAccount]: Job ${jobIndex} has no rank ${tempSubAccount.jobRank}! Using lowest rank ${newJobRankIndex} instead.`); + tempSubAccount.jobRank = getJobRankData(jobIndex, newJobRankIndex).databaseId; + tempSubAccount.jobRankIndex = newJobRankIndex; + } else { + // Somethings fucked. Job rank invalid, and no other rank to use. Removing from Job. + logToConsole(LOG_DEBUG | LOG_ERROR, `[V.RP.SubAccount]: Job ${jobIndex} has no rank ${tempSubAccount.jobRank}, and no other rank to use. Removing from job ...`); + tempSubAccount.job = 0; + tempSubAccount.jobRank = 0; + tempSubAccount.jobIndex = -1; + tempSubAccount.jobRankIndex = -1; + } + tempSubAccount.jobRank = getJobRankData(jobIndex, newJobRankIndex).databaseId; tempSubAccount.jobRankIndex = newJobRankIndex; } else { From 86bb681ba0eaae683e10222ac629a9ae5b883cfc Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Wed, 8 Mar 2023 22:42:24 -0600 Subject: [PATCH 18/24] Vehicle transmit radio util --- scripts/server/vehicle.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/scripts/server/vehicle.js b/scripts/server/vehicle.js index b70bf195..4cea534f 100644 --- a/scripts/server/vehicle.js +++ b/scripts/server/vehicle.js @@ -1988,4 +1988,24 @@ function getVehicleDataIndexFromVehicle(vehicle) { return -1; } +// =========================================================================== + +function doesVehicleHaveTransmitRadio(vehicle) { + if (getVehicleData(vehicle).ownerType == V_VEHOWNER_JOB) { + if (getJobType(getJobIdFromDatabaseId(getVehicleData(vehicle).ownerId)) == V_JOB_POLICE) { + return true; + } + + if (getJobType(getJobIdFromDatabaseId(getVehicleData(vehicle).ownerId)) == V_JOB_FIRE) { + return true; + } + + if (getJobType(getJobIdFromDatabaseId(getVehicleData(vehicle).ownerId)) == V_JOB_MEDICAL) { + return true; + } + } + + return false; +} + // =========================================================================== \ No newline at end of file From 244b1e94e7891d352fcfef619545abacf4d9770c Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Wed, 8 Mar 2023 22:42:42 -0600 Subject: [PATCH 19/24] Vehicle transmit radio distance (for next to car) --- scripts/server/config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/server/config.js b/scripts/server/config.js index 10601f1a..6b2f1e18 100644 --- a/scripts/server/config.js +++ b/scripts/server/config.js @@ -283,6 +283,7 @@ let globalConfig = { nightMapEndHour: 7, payPhoneGiveDistance: 2.5, payPhoneAnswerDistance: 2.5, + vehicleTransmitRadioUseDistance: 2.5, }; // =========================================================================== From 0ba6bb770e7718b8daca64d387b1dc28507118b1 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Wed, 8 Mar 2023 23:40:37 -0600 Subject: [PATCH 20/24] New locale strings --- locale/arabic.json | 5 ++++- locale/canadian-french.json | 5 ++++- locale/chinese.json | 7 ++++++- locale/english.json | 5 ++++- locale/finnish.json | 5 ++++- locale/french.json | 5 ++++- locale/german.json | 5 ++++- locale/japanese.json | 5 ++++- locale/latvian.json | 5 ++++- locale/lithuanian.json | 5 ++++- locale/persian.json | 5 ++++- locale/polish.json | 5 ++++- locale/russian.json | 5 ++++- locale/slovak.json | 5 ++++- locale/spanish.json | 5 ++++- 15 files changed, 62 insertions(+), 15 deletions(-) diff --git a/locale/arabic.json b/locale/arabic.json index ce3a08c2..6094309b 100644 --- a/locale/arabic.json +++ b/locale/arabic.json @@ -787,5 +787,8 @@ "PlayerNotSurrendered": "The player must be surrendered (hands up, be knocked out, or tazed)!", "PlayerRemovedFromJob": "You removed {1} from the job", "RemovedFromJob": "You were removed from the job by {1}", - "UnableToCallPlayer": "{1} can't be called right now" + "UnableToCallPlayer": "{1} can't be called right now", + "NoRadioToUse": "You must have a radio, or be in a vehicle with a radio!", + "FrequencyMustBeNumber": "The radio channel must be a number!", + "FrequencyMustBeBetween": "The radio channel must be between {1} and {2}!" } \ No newline at end of file diff --git a/locale/canadian-french.json b/locale/canadian-french.json index b647bbd4..0218c314 100644 --- a/locale/canadian-french.json +++ b/locale/canadian-french.json @@ -785,5 +785,8 @@ "PlayerNotSurrendered": "The player must be surrendered (hands up, be knocked out, or tazed)!", "PlayerRemovedFromJob": "You removed {1} from the job", "RemovedFromJob": "You were removed from the job by {1}", - "UnableToCallPlayer": "{1} can't be called right now" + "UnableToCallPlayer": "{1} can't be called right now", + "NoRadioToUse": "You must have a radio, or be in a vehicle with a radio!", + "FrequencyMustBeNumber": "The radio channel must be a number!", + "FrequencyMustBeBetween": "The radio channel must be between {1} and {2}!" } \ No newline at end of file diff --git a/locale/chinese.json b/locale/chinese.json index 0fdedb0c..c5511cbb 100644 --- a/locale/chinese.json +++ b/locale/chinese.json @@ -781,5 +781,10 @@ "GlobalChatDisabled": "Global out-of-character chat is disabled by server admin", "CantEditJobUniforms": "You can't edit job uniforms!", "PlayerNotSurrendered": "The player must be surrendered (hands up, be knocked out, or tazed)!", - "UnableToCallPlayer": "{1} can't be called right now" + "PlayerRemovedFromJob": "You removed {1} from the job", + "RemovedFromJob": "You were removed from the job by {1}", + "UnableToCallPlayer": "{1} can't be called right now", + "NoRadioToUse": "You must have a radio, or be in a vehicle with a radio!", + "FrequencyMustBeNumber": "The radio channel must be a number!", + "FrequencyMustBeBetween": "The radio channel must be between {1} and {2}!" } diff --git a/locale/english.json b/locale/english.json index d9af8d60..cb55eade 100644 --- a/locale/english.json +++ b/locale/english.json @@ -794,5 +794,8 @@ "PlayerNotSurrendered": "The player must be surrendered (hands up, be knocked out, or tazed)!", "PlayerRemovedFromJob": "You removed {1} from the job", "RemovedFromJob": "You were removed from the job by {1}", - "UnableToCallPlayer": "{1} can't be called right now" + "UnableToCallPlayer": "{1} can't be called right now", + "NoRadioToUse": "You must have a radio, or be in a vehicle with a radio!", + "FrequencyMustBeNumber": "The radio channel must be a number!", + "FrequencyMustBeBetween": "The radio channel must be between {1} and {2}!" } diff --git a/locale/finnish.json b/locale/finnish.json index b513bbe3..d443d465 100644 --- a/locale/finnish.json +++ b/locale/finnish.json @@ -782,5 +782,8 @@ "PlayerNotSurrendered": "The player must be surrendered (hands up, be knocked out, or tazed)!", "PlayerRemovedFromJob": "You removed {1} from the job", "RemovedFromJob": "You were removed from the job by {1}", - "UnableToCallPlayer": "{1} can't be called right now" + "UnableToCallPlayer": "{1} can't be called right now", + "NoRadioToUse": "You must have a radio, or be in a vehicle with a radio!", + "FrequencyMustBeNumber": "The radio channel must be a number!", + "FrequencyMustBeBetween": "The radio channel must be between {1} and {2}!" } diff --git a/locale/french.json b/locale/french.json index 1b23a885..ee49e44a 100644 --- a/locale/french.json +++ b/locale/french.json @@ -783,5 +783,8 @@ "PlayerNotSurrendered": "The player must be surrendered (hands up, be knocked out, or tazed)!", "PlayerRemovedFromJob": "You removed {1} from the job", "RemovedFromJob": "You were removed from the job by {1}", - "UnableToCallPlayer": "{1} can't be called right now" + "UnableToCallPlayer": "{1} can't be called right now", + "NoRadioToUse": "You must have a radio, or be in a vehicle with a radio!", + "FrequencyMustBeNumber": "The radio channel must be a number!", + "FrequencyMustBeBetween": "The radio channel must be between {1} and {2}!" } \ No newline at end of file diff --git a/locale/german.json b/locale/german.json index dbfc7b58..7a818b77 100644 --- a/locale/german.json +++ b/locale/german.json @@ -782,5 +782,8 @@ "PlayerNotSurrendered": "The player must be surrendered (hands up, be knocked out, or tazed)!", "PlayerRemovedFromJob": "You removed {1} from the job", "RemovedFromJob": "You were removed from the job by {1}", - "UnableToCallPlayer": "{1} can't be called right now" + "UnableToCallPlayer": "{1} can't be called right now", + "NoRadioToUse": "You must have a radio, or be in a vehicle with a radio!", + "FrequencyMustBeNumber": "The radio channel must be a number!", + "FrequencyMustBeBetween": "The radio channel must be between {1} and {2}!" } \ No newline at end of file diff --git a/locale/japanese.json b/locale/japanese.json index 31c2cb77..020f875d 100644 --- a/locale/japanese.json +++ b/locale/japanese.json @@ -783,5 +783,8 @@ "PlayerNotSurrendered": "The player must be surrendered (hands up, be knocked out, or tazed)!", "PlayerRemovedFromJob": "You removed {1} from the job", "RemovedFromJob": "You were removed from the job by {1}", - "UnableToCallPlayer": "{1} can't be called right now" + "UnableToCallPlayer": "{1} can't be called right now", + "NoRadioToUse": "You must have a radio, or be in a vehicle with a radio!", + "FrequencyMustBeNumber": "The radio channel must be a number!", + "FrequencyMustBeBetween": "The radio channel must be between {1} and {2}!" } \ No newline at end of file diff --git a/locale/latvian.json b/locale/latvian.json index d51e8fed..21109df5 100644 --- a/locale/latvian.json +++ b/locale/latvian.json @@ -785,5 +785,8 @@ "PlayerNotSurrendered": "The player must be surrendered (hands up, be knocked out, or tazed)!", "PlayerRemovedFromJob": "You removed {1} from the job", "RemovedFromJob": "You were removed from the job by {1}", - "UnableToCallPlayer": "{1} can't be called right now" + "UnableToCallPlayer": "{1} can't be called right now", + "NoRadioToUse": "You must have a radio, or be in a vehicle with a radio!", + "FrequencyMustBeNumber": "The radio channel must be a number!", + "FrequencyMustBeBetween": "The radio channel must be between {1} and {2}!" } \ No newline at end of file diff --git a/locale/lithuanian.json b/locale/lithuanian.json index 4dae276d..7d0e4e67 100644 --- a/locale/lithuanian.json +++ b/locale/lithuanian.json @@ -784,5 +784,8 @@ "PlayerNotSurrendered": "The player must be surrendered (hands up, be knocked out, or tazed)!", "PlayerRemovedFromJob": "You removed {1} from the job", "RemovedFromJob": "You were removed from the job by {1}", - "UnableToCallPlayer": "{1} can't be called right now" + "UnableToCallPlayer": "{1} can't be called right now", + "NoRadioToUse": "You must have a radio, or be in a vehicle with a radio!", + "FrequencyMustBeNumber": "The radio channel must be a number!", + "FrequencyMustBeBetween": "The radio channel must be between {1} and {2}!" } diff --git a/locale/persian.json b/locale/persian.json index 4c0505a9..636e80d9 100644 --- a/locale/persian.json +++ b/locale/persian.json @@ -784,5 +784,8 @@ "PlayerNotSurrendered": "The player must be surrendered (hands up, be knocked out, or tazed)!", "PlayerRemovedFromJob": "You removed {1} from the job", "RemovedFromJob": "You were removed from the job by {1}", - "UnableToCallPlayer": "{1} can't be called right now" + "UnableToCallPlayer": "{1} can't be called right now", + "NoRadioToUse": "You must have a radio, or be in a vehicle with a radio!", + "FrequencyMustBeNumber": "The radio channel must be a number!", + "FrequencyMustBeBetween": "The radio channel must be between {1} and {2}!" } \ No newline at end of file diff --git a/locale/polish.json b/locale/polish.json index a5f7d5dc..38fd240a 100644 --- a/locale/polish.json +++ b/locale/polish.json @@ -782,5 +782,8 @@ "PlayerNotSurrendered": "The player must be surrendered (hands up, be knocked out, or tazed)!", "PlayerRemovedFromJob": "You removed {1} from the job", "RemovedFromJob": "You were removed from the job by {1}", - "UnableToCallPlayer": "{1} can't be called right now" + "UnableToCallPlayer": "{1} can't be called right now", + "NoRadioToUse": "You must have a radio, or be in a vehicle with a radio!", + "FrequencyMustBeNumber": "The radio channel must be a number!", + "FrequencyMustBeBetween": "The radio channel must be between {1} and {2}!" } diff --git a/locale/russian.json b/locale/russian.json index 597d5a94..e9959dd1 100644 --- a/locale/russian.json +++ b/locale/russian.json @@ -783,5 +783,8 @@ "PlayerNotSurrendered": "The player must be surrendered (hands up, be knocked out, or tazed)!", "PlayerRemovedFromJob": "You removed {1} from the job", "RemovedFromJob": "You were removed from the job by {1}", - "UnableToCallPlayer": "{1} can't be called right now" + "UnableToCallPlayer": "{1} can't be called right now", + "NoRadioToUse": "You must have a radio, or be in a vehicle with a radio!", + "FrequencyMustBeNumber": "The radio channel must be a number!", + "FrequencyMustBeBetween": "The radio channel must be between {1} and {2}!" } diff --git a/locale/slovak.json b/locale/slovak.json index e411d3ba..a6ab8286 100644 --- a/locale/slovak.json +++ b/locale/slovak.json @@ -783,5 +783,8 @@ "PlayerNotSurrendered": "The player must be surrendered (hands up, be knocked out, or tazed)!", "PlayerRemovedFromJob": "You removed {1} from the job", "RemovedFromJob": "You were removed from the job by {1}", - "UnableToCallPlayer": "{1} can't be called right now" + "UnableToCallPlayer": "{1} can't be called right now", + "NoRadioToUse": "You must have a radio, or be in a vehicle with a radio!", + "FrequencyMustBeNumber": "The radio channel must be a number!", + "FrequencyMustBeBetween": "The radio channel must be between {1} and {2}!" } \ No newline at end of file diff --git a/locale/spanish.json b/locale/spanish.json index 7aa19e3b..5b5f172a 100644 --- a/locale/spanish.json +++ b/locale/spanish.json @@ -789,5 +789,8 @@ "PlayerNotSurrendered": "The player must be surrendered (hands up, be knocked out, or tazed)!", "PlayerRemovedFromJob": "You removed {1} from the job", "RemovedFromJob": "You were removed from the job by {1}", - "UnableToCallPlayer": "{1} can't be called right now" + "UnableToCallPlayer": "{1} can't be called right now", + "NoRadioToUse": "You must have a radio, or be in a vehicle with a radio!", + "FrequencyMustBeNumber": "The radio channel must be a number!", + "FrequencyMustBeBetween": "The radio channel must be between {1} and {2}!" } From c71e16c8737735c0b81b79e53346ce2fb792e0f6 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Wed, 8 Mar 2023 23:41:42 -0600 Subject: [PATCH 21/24] Radio command --- scripts/server/command.js | 6 +- scripts/server/radio.js | 142 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 145 insertions(+), 3 deletions(-) diff --git a/scripts/server/command.js b/scripts/server/command.js index 0be50045..f46785dd 100644 --- a/scripts/server/command.js +++ b/scripts/server/command.js @@ -360,11 +360,11 @@ function loadCommands() { new CommandData("buylist", listBusinessFloorInventoryCommand, "", getStaffFlagValue("None"), true, false, "Shows the items that can be bought from the business"), new CommandData("power", toggleItemEnabledCommand, "", getStaffFlagValue("None"), true, false, "Turns on or off an item"), - new CommandData("freq", setWalkieTalkieFrequencyCommand, "[frequncy number]", getStaffFlagValue("None"), true, false, "Sets a radio item's frequency"), + //new CommandData("freq", setRadioFrequencyCommand, "[frequency number]", getStaffFlagValue("None"), true, false, "Sets a vehicle or item radio frequency"), //new CommandData("call", callWithPhoneCommand, "[number]", getStaffFlagValue("None"), true, false), //new CommandData("speakerphone", togglePhoneSpeakerCommand, "", getStaffFlagValue("None"), true, false), - new CommandData("radio", walkieTalkieChatCommand, "", getStaffFlagValue("None"), true, false, "Chat over a radio item (item must be able to transmit)"), - new CommandData("r", walkieTalkieChatCommand, "", getStaffFlagValue("None"), true, false, "Chat over a radio item (item must be able to transmit)"), + new CommandData("radio", radioTransmitCommand, "", getStaffFlagValue("None"), true, false, "Chat over a radio (vehicle radio or item)"), + new CommandData("r", radioTransmitCommand, "", getStaffFlagValue("None"), true, false, "Chat over a radio (vehicle radio or item)"), new CommandData("additemtype", createItemTypeCommand, "", getStaffFlagValue("ManageItems"), true, false, "Adds a new item type"), new CommandData("itemtypeusetype", setItemTypeUseTypeCommand, " ", getStaffFlagValue("ManageItems"), true, false, "Sets an item type's use-type (what kind of action is performed when using it)"), diff --git a/scripts/server/radio.js b/scripts/server/radio.js index 193da78b..1927f004 100644 --- a/scripts/server/radio.js +++ b/scripts/server/radio.js @@ -329,4 +329,146 @@ function getRadioStationData(radioStationIndex) { return getServerData().radioStations[radioStationIndex]; } +// =========================================================================== + +function radioTransmitCommand(command, params, client) { + let possibleRadio = getPlayerFirstItemSlotByUseType(client, V_ITEM_USE_TYPE_WALKIETALKIE); + + let frequency = -1; + + if (possibleRadio != -1) { + if (getItemData(possibleRadio).enabled) { + frequency = getItemData(possibleRadio).value; + } + } else { + let vehicle = null; + + if (isPlayerInAnyVehicle(client)) { + vehicle = getPlayerVehicle(client); + } else { + let tempVehicle = getClosestVehicle(getPlayerPosition(client)); + if (getDistance(getPlayerPosition(client), getVehiclePosition(tempVehicle)) <= getGlobalConfig().vehicleTrunkDistance) { + vehicle = tempVehicle; + } + } + + if (vehicle == null) { + messagePlayerError(client, getLocaleString(client, "NoRadioToUse")); + return false; + } + + if (!doesVehicleHaveTransmitRadio(vehicle)) { + messagePlayerError(client, getLocaleString(client, "NoRadioToUse")); + return false; + } + + frequency = getVehicleData(vehicle).radioFrequency; + } + + if (frequency == -1) { + messagePlayerError(client, getLocaleString(client, "NoRadioToUse")); + return false; + } + + sendRadioTransmission(frequency, params, client); +} + +// =========================================================================== + +function sendRadioTransmission(frequency, messageText, sentFromClient) { + let seenClients = []; + seenClients.push(sentFromClient); + + let clients = getClients(); + + for (let i in clients) { + if (seenClients.indexOf(clients[i]) == -1) { + if (getDistance(getPlayerPosition(clients[i]), getPlayerPosition(sentFromClient)) <= getGlobalConfig().talkDistance) { + seenClients.push(clients[i]); + messagePlayerNormal(`[#CCCCCC]${getCharacterFullName(client)} {ALTCOLOUR}(to radio): {MAINCOLOUR}${messageText}`); + } + } + } + + let vehicles = getServerData().vehicles; + for (let i in vehicles) { + if (getVehicleData(vehicles[i]).radioFrequency == frequency) { + for (let j in clients) { + if (seenClients.indexOf(clients[j]) == -1) { + if (getDistance(getPlayerPosition(clients[j]), getVehiclePosition(getServerData().vehicles[j].vehicle)) <= getGlobalConfig().transmitRadioSpeakerDistance) { + seenClients.push(clients[j]); + messagePlayerNormal(clients[j], `📻 {ALTCOLOUR}(On Radio): {MAINCOLOUR}${messageText}`); + } + } + } + } + } + + let items = getServerData().items; + for (let i in items) { + if (items[i].enabled) { + if (getItemTypeData(items[i].itemTypeIndex).useType == V_ITEM_USE_TYPE_WALKIETALKIE) { + if (items[i].value == frequency) { + for (let j in clients) { + if (seenClients.indexOf(clients[j]) == -1) { + if (getDistance(getPlayerPosition(clients[j], getItemPosition(i))) <= getGlobalConfig().transmitRadioSpeakerDistance) { + seenClients.push(clients[j]); + messagePlayerNormal(clients[j], `📻 {ALTCOLOUR}(On Radio): {MAINCOLOUR}${messageText}`); + } + } + } + } + } + } + } +} + +// =========================================================================== + +function setRadioFrequencyCommand(command, params, client) { + // Needs finished + return false; + + /* + if (areParamsEmpty(params)) { + messagePlayerSyntax(client, getCommandSyntaxText(command)); + return false; + } + + if (isNaN(params)) { + messagePlayerError(client, ``); + return false; + } + + params = toInteger(params); + + if (params < 100 || params > 500) { + messagePlayerError(client, `The frequency channel must be between 100 and 500!`); + return false; + } + + if (!getPlayerActiveItem(client)) { + messagePlayerError(client, `You aren't holding a walkie talkie!`); + return false; + } + + if (!getItemData(getPlayerActiveItem(client))) { + messagePlayerError(client, `You aren't holding a walkie talkie!`); + return false; + } + + if (getItemData(getPlayerActiveItem(client)).enabled) { + if (!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "use")) { + messagePlayerError(client, `Your walkie talkie is turned off. Press ${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "use")).key)} to turn it on`); + } else { + messagePlayerError(client, `Your walkie talkie is turned off. Type {ALTCOLOUR}/use {MAINCOLOUR}to turn it on`); + } + return false; + } + + getItemData(getPlayerActiveItem(client)).value = params * 100; + messagePlayerSuccess(client, getLocaleString(client, "FrequencyChannelChanged", `Walkie Talkie`, `${getPlayerData(client).activeHotBarSlot + 1}`, `${getItemValueDisplayForItem(getPlayerActiveItem(client))}`)); + */ +} + // =========================================================================== \ No newline at end of file From 5ab29e84e016fe9814282218b3fb36ed3b70bd28 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Wed, 8 Mar 2023 23:41:57 -0600 Subject: [PATCH 22/24] Radio data --- scripts/server/job.js | 8 ++++---- scripts/server/startup.js | 1 + scripts/server/vehicle.js | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/scripts/server/job.js b/scripts/server/job.js index 29eb75a8..7009af63 100644 --- a/scripts/server/job.js +++ b/scripts/server/job.js @@ -57,7 +57,7 @@ class JobData { this.colour = toColour(0, 0, 0, 255); this.whiteListEnabled = false; this.blackListEnabled = false; - this.walkieTalkieFrequency = 0; + this.radioFrequency = 0; this.index = -1; this.needsSaved = false; this.whoAdded = 0; @@ -95,7 +95,7 @@ class JobData { this.colour = toColour(dbAssoc["job_colour_r"], dbAssoc["job_colour_g"], dbAssoc["job_colour_b"], 255); this.whiteListEnabled = dbAssoc["job_wl"]; this.blackListEnabled = dbAssoc["job_bl"]; - this.walkieTalkieFrequency = dbAssoc["job_walkietalkiefreq"]; + this.radioFrequency = dbAssoc["job_radio_freq"]; this.whoAdded = dbAssoc["job_who_added"]; this.whenAdded = dbAssoc["job_when_added"]; @@ -1148,7 +1148,7 @@ function givePlayerJobEquipment(client, equipmentId) { for (let i in getJobData(jobId).equipment[equipmentId].items) { let value = getJobData(jobId).equipment[equipmentId].items[i].value if (getItemTypeData(getItemTypeIndexFromDatabaseId(getJobData(jobId).equipment[equipmentId].items[i].itemType)).useType == V_ITEM_USE_TYPE_WALKIETALKIE) { - value = getJobData(jobId).walkieTalkieFrequency; + value = getJobData(jobId).radioFrequency; } let itemId = createItem(getItemTypeIndexFromDatabaseId(getJobData(jobId).equipment[equipmentId].items[i].itemType), value, V_ITEM_OWNER_PLAYER, getPlayerCurrentSubAccount(client).databaseId); getItemData(itemId).needsSaved = false; @@ -2813,7 +2813,7 @@ function saveJobToDatabase(jobData) { ["job_colour_r", colour[0]], ["job_colour_g", colour[1]], ["job_colour_b", colour[2]], - ["job_walkietalkiefreq", jobData.walkieTalkieFrequency], + ["job_radio_freq", jobData.radioFrequency], ["job_wl", jobData.whiteListEnabled], ["job_bl", jobData.blackListEnabled], ["job_who_added", jobData.whoAdded], diff --git a/scripts/server/startup.js b/scripts/server/startup.js index 214353d6..8ac96fa9 100644 --- a/scripts/server/startup.js +++ b/scripts/server/startup.js @@ -172,6 +172,7 @@ function setAllServerDataIndexes() { setAllRaceDataIndexes(); setAllRadioStationIndexes(); setAllPayPhoneIndexes(); + setAllVehicleRadioTransmitFrequencies(); cacheAllGroundItems(); cacheAllBusinessItems(); cacheAllItemItems(); diff --git a/scripts/server/vehicle.js b/scripts/server/vehicle.js index 4cea534f..a432b02b 100644 --- a/scripts/server/vehicle.js +++ b/scripts/server/vehicle.js @@ -87,6 +87,7 @@ class VehicleData { this.whoAdded = 0; this.whenAdded = 0; this.licensePlate = ""; + this.radioFrequency = -1; this.lastActiveTime = false; @@ -160,6 +161,9 @@ class VehicleData { this.whenAdded = toInteger(dbAssoc["veh_when_added"]); this.licensePlate = toInteger(dbAssoc["veh_license_plate"]); this.rank = toInteger(dbAssoc["veh_rank"]); + this.radioFrequency = toInteger(dbAssoc["veh_radio_freq"]); + this.whoAdded = toInteger(dbAssoc["veh_who_added"]); + this.whenAdded = toInteger(dbAssoc["veh_when_added"]); } } }; @@ -2008,4 +2012,16 @@ function doesVehicleHaveTransmitRadio(vehicle) { return false; } +// =========================================================================== + +function setAllVehicleRadioTransmitFrequencies() { + for (let i in getServerData().vehicles) { + if (getServerData().vehicles[i].ownerType == V_VEHOWNER_JOB) { + if (getJobData(getJobIdFromDatabaseId(getServerData().vehicles[i].ownerId)) != false) { + getServerData().vehicles[i].radioFrequency = getJobData(getJobIdFromDatabaseId(getServerData().vehicles[i].ownerId)).radioFrequency; + } + } + } +} + // =========================================================================== \ No newline at end of file From 8eae93210ac6f5aa9123fbe08e878e9d3dc60de6 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Wed, 8 Mar 2023 23:42:06 -0600 Subject: [PATCH 23/24] Radio distance --- scripts/server/config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/server/config.js b/scripts/server/config.js index 6b2f1e18..f4b5c5e8 100644 --- a/scripts/server/config.js +++ b/scripts/server/config.js @@ -211,8 +211,8 @@ let globalConfig = { houseDimensionStart: 100, buyVehicleDriveAwayDistance: 25.0, returnToJobVehicleTime: 30, - walkieTalkieSpeakerDistance: 15, - walkieTalkieTalkDistance: 15, + radioTransmitSpeakerDistance: 15, + radioTransmitTalkDistance: 15, phoneSpeakerDistance: 15, phoneTalkDistance: 15, tazerEffectDuration: 15000, From 8cae1283535aed4c4ceba82cdaee874057e84e9e Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Wed, 8 Mar 2023 23:42:38 -0600 Subject: [PATCH 24/24] Remove old walkie talkie stuff (moved to radio) --- scripts/server/item/walkie-talkie.js | 131 --------------------------- 1 file changed, 131 deletions(-) diff --git a/scripts/server/item/walkie-talkie.js b/scripts/server/item/walkie-talkie.js index 199ae3f2..9cd3fd8b 100644 --- a/scripts/server/item/walkie-talkie.js +++ b/scripts/server/item/walkie-talkie.js @@ -5,135 +5,4 @@ // FILE: walkie-talkie.js // DESC: Provides features and usage for the walkie-talkie item type // TYPE: Server (JavaScript) -// =========================================================================== - -function getPlayerActiveWalkieTalkieFrequency(client) { - let walkieTalkieSlot = getPlayerFirstItemSlotByUseType(client, V_ITEM_USE_TYPE_WALKIETALKIE); - - if (walkieTalkieSlot != -1) { - if (getItemData(getPlayerData(client).hotBarItems[walkieTalkieSlot])) { - if (getItemData(getPlayerData(client).hotBarItems[walkieTalkieSlot]).enabled) { - return getItemData(getPlayerData(client).hotBarItems[walkieTalkieSlot]).value; - } - } - } - - return false; -} - -// =========================================================================== - -function walkieTalkieTransmit(radioFrequency, messageText, transmittingPlayer) { - walkieTalkieOutgoingToNearbyPlayers(transmittingPlayer, messageText); - - //let clients = getServerData().items; - //for(let i in clients) { - // if(isPlayerSpawned(clients[i])) { - // if(!isSamePlayer(transmittingPlayer, clients[i])) { - // if(getPlayerActiveWalkieTalkieFrequency(clients[i]) == radioFrequency) { - // if(getItemData(getPlayerData(clients[i]).hotBarItems[getPlayerFirstItemSlotByUseType(clients[i], V_ITEM_USE_TYPE_WALKIETALKIE)]).enabled) { - // walkieTalkieIncomingToNearbyPlayers(clients[i], messageText); - // } - // } - // } - // } - //} - - let items = getServerData().items; - for (let i in items) { - if (items[i].enabled) { - if (getItemTypeData(items[i].itemTypeIndex).useType == V_ITEM_USE_TYPE_WALKIETALKIE) { - if (items[i].value == radioFrequency) { - walkieTalkieIncomingToNearbyPlayers(null, messageText, getItemPosition(i)); - } - } - } - } -} - -// =========================================================================== - -function walkieTalkieOutgoingToNearbyPlayers(client, messageText) { - let clients = getPlayersInRange(getPlayerPosition(client), getGlobalConfig().talkDistance); - for (let i in clients) { - messagePlayerNormal(clients[i], `[#CCCCCC]${getCharacterFullName(client)} {ALTCOLOUR}(to radio): {MAINCOLOUR}${messageText}`); - } -} - -// =========================================================================== - -function walkieTalkieIncomingToNearbyPlayers(client, messageText, position = null) { - let prefix = `{ALTCOLOUR}(Nearby radio)`; - if (client != null) { - prefix = `${getCharacterFullName(client)} {ALTCOLOUR}(from radio)`; - } - - let clients = getPlayersInRange(getPlayerPosition(client), getGlobalConfig().walkieTalkieSpeakerDistance); - for (let i in clients) { - messagePlayerNormal(clients[i], `[#CCCCCC]${prefix}: {MAINCOLOUR}${messageText}`); - } -} - -// =========================================================================== - -function setWalkieTalkieFrequencyCommand(command, params, client) { - if (areParamsEmpty(params)) { - messagePlayerSyntax(client, getCommandSyntaxText(command)); - return false; - } - - if (isNaN(params)) { - messagePlayerError(client, `The frequency channel must be a number!`); - return false; - } - - params = toInteger(params); - - if (params < 100 || params > 500) { - messagePlayerError(client, `The frequency channel must be between 100 and 500!`); - return false; - } - - if (!getPlayerActiveItem(client)) { - messagePlayerError(client, `You aren't holding a walkie talkie!`); - return false; - } - - if (!getItemData(getPlayerActiveItem(client))) { - messagePlayerError(client, `You aren't holding a walkie talkie!`); - return false; - } - - if (getItemData(getPlayerActiveItem(client)).enabled) { - if (!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "use")) { - messagePlayerError(client, `Your walkie talkie is turned off. Press ${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "use")).key)} to turn it on`); - } else { - messagePlayerError(client, `Your walkie talkie is turned off. Type {ALTCOLOUR}/use {MAINCOLOUR}to turn it on`); - } - return false; - } - - getItemData(getPlayerActiveItem(client)).value = params * 100; - messagePlayerSuccess(client, getLocaleString(client, "FrequencyChannelChanged", `Walkie Talkie`, `${getPlayerData(client).activeHotBarSlot + 1}`, `${getItemValueDisplayForItem(getPlayerActiveItem(client))}`)); -} - -// =========================================================================== - -function walkieTalkieChatCommand(command, params, client) { - if (areParamsEmpty(params)) { - messagePlayerSyntax(client, getCommandSyntaxText(command)); - return false; - } - - let walkieTalkieSlot = getPlayerFirstItemSlotByUseType(client, V_ITEM_USE_TYPE_WALKIETALKIE); - if (!getItemData(getPlayerData(client).hotBarItems[walkieTalkieSlot]).enabled) { - messagePlayerError(client, "Please turn on a walkie talkie first!"); - return false; - } - - walkieTalkieTransmit(getPlayerActiveWalkieTalkieFrequency(client), params, client); - - markPlayerActionTipSeen(client, "RadioCommandAfterEnablingWalkieTalkie"); -} - // =========================================================================== \ No newline at end of file