From c4f8afecc0bd67968f3aef5d28fe2caf4bc94e02 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Mon, 22 Aug 2022 14:18:01 -0500 Subject: [PATCH 001/221] Action tips --- scripts/server/account.js | 3 +++ scripts/server/bitflag.js | 25 ++++++++++++++++++++++--- scripts/server/help.js | 20 ++++++++++++++++++++ scripts/shared/utilities.js | 2 +- 4 files changed, 46 insertions(+), 4 deletions(-) diff --git a/scripts/server/account.js b/scripts/server/account.js index bd76b8e4..e923a0c2 100644 --- a/scripts/server/account.js +++ b/scripts/server/account.js @@ -58,6 +58,7 @@ class AccountData { this.ircAccount = ""; this.discordAccount = 0; this.settings = 0; + this.seenActionTips = 0; this.emailAddress = ""; this.ipAddress = 0; @@ -87,6 +88,7 @@ class AccountData { this.ircAccount = toInteger(dbAssoc["acct_irc"]); this.discordAccount = toInteger(dbAssoc["acct_discord"]); this.settings = toInteger(dbAssoc["acct_svr_settings"]); + this.seenActionTips = toInteger(dbAssoc["acct_svr_seen_action_tips"]); this.emailAddress = toString(dbAssoc["acct_email"]); this.ipAddress = toString(dbAssoc["acct_ip"]); @@ -921,6 +923,7 @@ function saveAccountToDatabase(accountData) { let data2 = [ ["acct_svr_settings", (accountData.settings != NaN) ? toInteger(accountData.settings) : 0], + ["acct_svr_seen_action_tips", (accountData.seenActionTips != NaN) ? toInteger(accountData.seenActionTips) : 0], ["acct_svr_staff_title", toString(safeStaffTitle)], ["acct_svr_staff_flags", (accountData.flags.admin != NaN) ? toInteger(accountData.flags.admin) : 0], ["acct_svr_mod_flags", (accountData.flags.moderation != NaN) ? toInteger(accountData.flags.moderation) : 0], diff --git a/scripts/server/bitflag.js b/scripts/server/bitflag.js index e0635c77..fe81526a 100644 --- a/scripts/server/bitflag.js +++ b/scripts/server/bitflag.js @@ -16,7 +16,7 @@ let serverBitFlags = { accountSettingsFlags: {}, subAccountSettingsFlags: {}, accountFlags: {}, - seenHelpTipsFlags: {}, + seenActionTipsFlags: {}, npcTriggerTypeFlags: {}, npcTriggerConditionTypesFlags: {}, npcTriggerResponseTypeFlags: {}, @@ -240,12 +240,17 @@ let serverBitFlagKeys = { "EnterProperty", "SearchArea", ], - seenHelpTipsKeys: [ + seenActionTipsKeys: [ "None", "VehicleEngineOffWhenEntering", "VehicleLockedAfterEntryAttempt", "ShowItemsAfterPurchase", "BuyCommandAfterEnterBusiness", + "UseItemKeyAfterEquipping", + "UseItemKeyAfterEquippingWalkieTalkie", + "RadioCommandAfterEnablingWalkieTalkie", + "ReplyToDirectMessage", + "UseItemKeyAmmoAfterEquippingWeapon", ], jobRankKeys: [ "None", @@ -277,7 +282,7 @@ function initBitFlagScript() { serverBitFlags.npcTriggerTypes = createBitFlagTable(serverBitFlagKeys.npcTriggerTypeKeys); serverBitFlags.npcTriggerConditionTypes = createBitFlagTable(serverBitFlagKeys.npcTriggerConditionTypeKeys); serverBitFlags.npcTriggerResponseTypes = createBitFlagTable(serverBitFlagKeys.npcTriggerResponseTypeKeys); - serverBitFlags.seenHelpTips = createBitFlagTable(serverBitFlagKeys.seenHelpTipsKeys); + serverBitFlags.seenActionTips = createBitFlagTable(serverBitFlagKeys.seenActionTipsKeys); serverBitFlags.jobRankFlags = createBitFlagTable(serverBitFlagKeys.jobRankKeys); logToConsole(LOG_INFO, "[VRR.BitFlag]: Bit flag script initialized successfully!"); return true; @@ -443,6 +448,20 @@ function getClanDiscordWebhookValue(flagName) { // =========================================================================== +function getSeenActionTipsValue(flagName) { + if (flagName == "All") { + return -1; + } + + if (typeof serverBitFlags.seenActionTips[flagName] == "undefined") { + return false; + } + + return serverBitFlags.seenActionTips[flagName]; +} + +// =========================================================================== + function givePlayerStaffFlag(client, flagName) { if (!getStaffFlagValue(flagName)) { return false; diff --git a/scripts/server/help.js b/scripts/server/help.js index 17fa1b0b..f3aea44c 100644 --- a/scripts/server/help.js +++ b/scripts/server/help.js @@ -398,4 +398,24 @@ function helpGetSkinCommand(command, params, client) { messagePlayerAlert(client, ``); } +// =========================================================================== + +function hasPlayerSeenActionTip(client, seenActionTipFlagName) { + let seenActionTipFlagValue = getSeenActionTipsValue(seenActionTipFlagName); + + if (hasBitFlag(getPlayerData(client).accountData.seenActionTips, seenActionTipFlagValue)) { + return true; + } else { + return false; + } +} + +// =========================================================================== + +function playerHasSeenActionTip(client, seenActionTipFlagName) { + let seenActionTipFlagValue = getSeenActionTipsValue(seenActionTipFlagName); + + getPlayerData(client).accountData.seenActionTips = addBitFlag(getPlayerData(client).accountData.seenActionTips, seenActionTipFlagValue); +} + // =========================================================================== \ No newline at end of file diff --git a/scripts/shared/utilities.js b/scripts/shared/utilities.js index a90fea74..4597a9b5 100644 --- a/scripts/shared/utilities.js +++ b/scripts/shared/utilities.js @@ -3181,4 +3181,4 @@ function fillLeadingZeros(number, length) { return str; } -// =========================================================================== \ No newline at end of file +// =========================================================================== From 9e44f4d2fae724c2a64e1c54229721eb09414703 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Mon, 22 Aug 2022 14:26:48 -0500 Subject: [PATCH 002/221] Action tips (cont'd) --- scripts/server/animation.js | 6 +++++- scripts/server/business.js | 14 +++++++++----- scripts/server/chat.js | 7 ++++++- scripts/server/help.js | 6 +++--- scripts/server/job.js | 12 ++++++++---- 5 files changed, 31 insertions(+), 14 deletions(-) diff --git a/scripts/server/animation.js b/scripts/server/animation.js index d92d493d..9fd6d192 100644 --- a/scripts/server/animation.js +++ b/scripts/server/animation.js @@ -44,7 +44,9 @@ function playPlayerAnimationCommand(command, params, client) { return false; } - messagePlayerTip(client, getLocaleString(client, "AnimationStopCommandTip", "{ALTCOLOUR}/stopanim{MAINCOLOUR}")); + if (hasPlayerSeenActionTip(client, "AnimationStop")) { + messagePlayerTip(client, getIndexedLocaleString(client, "ActionTips", "AnimationStopTip", "{ALTCOLOUR}/stopanim{MAINCOLOUR}")); + } makePlayerPlayAnimation(client, animationSlot, animationPositionOffset); } @@ -66,6 +68,8 @@ function stopPlayerAnimationCommand(command, params, client) { getPlayerData(client).animationForced = false; //setPlayerMouseCameraState(client, false); + + markPlayerActionTipSeen(client, "AnimationStop"); } // =========================================================================== diff --git a/scripts/server/business.js b/scripts/server/business.js index ea801d8c..c7523922 100644 --- a/scripts/server/business.js +++ b/scripts/server/business.js @@ -2670,12 +2670,16 @@ function buyFromBusinessCommand(command, params, client) { //messagePlayerSuccess(client, `You bought ${amount} {ALTCOLOUR}${itemName} {MAINCOLOUR}for ${totalCost} ${priceEach}`); meActionToNearbyPlayers(client, `buys a ${itemName}`); - if (doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand("inv")) { - let keyData = getPlayerKeyBindForCommand("inv"); - messagePlayerNewbieTip(client, getLocaleString(client, "ViewInventoryKeyPressTip", `{ALTCOLOUR}${getKeyNameFromId(keyData.key)}{MAINCOLOUR}`)); - } else { - messagePlayerNewbieTip(client, getLocaleString(client, "ViewInventoryCommandTip", `{ALTCOLOUR}/inv{MAINCOLOUR}`)); + if (!hasPlayerSeenActionTip(client, "ViewInventory")) { + if (doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand("inv")) { + let keyData = getPlayerKeyBindForCommand("inv"); + messagePlayerActionTip(client, getIndexedLocaleString(client, "ActionTips", "ViewInventory", `{ALTCOLOUR}${getKeyNameFromId(keyData.key)}{MAINCOLOUR}`)); + } else { + messagePlayerActionTip(client, getIndexedLocaleString(client, "ActionTips", "ViewInventory", `{ALTCOLOUR}/inv{MAINCOLOUR}`)); + } } + + markPlayerActionTipSeen(client, "ViewInventory"); } // =========================================================================== diff --git a/scripts/server/chat.js b/scripts/server/chat.js index c2cc5673..19220075 100644 --- a/scripts/server/chat.js +++ b/scripts/server/chat.js @@ -217,7 +217,10 @@ function privateMessageCommand(command, params, client) { getPlayerData(targetClient).privateMessageReplyTo = client; messagePlayerPrivateMessage(targetClient, client, messageText); - messagePlayerTip(client, getLocaleString(client, "PrivateMessageReplyCommandTip", "{ALTCOLOUR}/reply{MAINCOLOUR}")) + + if (hasPlayerSeenActionTip(targetClient, "ReplyToDirectMessage")) { + messagePlayerTip(targetClient, getIndexedLocaleString(targetClient, "ActionTips", "ReplyToDirectMessage", "{ALTCOLOUR}/reply{MAINCOLOUR}")); + } } // =========================================================================== @@ -240,6 +243,8 @@ function replyToLastPrivateMessageCommand(command, params, client) { getPlayerData(targetClient).privateMessageReplyTo = client; messagePlayerPrivateMessage(targetClient, client, messageText); + + markPlayerActionTipSeen(client, "ReplyToDirectMessage"); } // =========================================================================== diff --git a/scripts/server/help.js b/scripts/server/help.js index f3aea44c..c7dda1ea 100644 --- a/scripts/server/help.js +++ b/scripts/server/help.js @@ -405,14 +405,14 @@ function hasPlayerSeenActionTip(client, seenActionTipFlagName) { if (hasBitFlag(getPlayerData(client).accountData.seenActionTips, seenActionTipFlagValue)) { return true; - } else { - return false; } + + return false; } // =========================================================================== -function playerHasSeenActionTip(client, seenActionTipFlagName) { +function markPlayerActionTipSeen(client, seenActionTipFlagName) { let seenActionTipFlagValue = getSeenActionTipsValue(seenActionTipFlagName); getPlayerData(client).accountData.seenActionTips = addBitFlag(getPlayerData(client).accountData.seenActionTips, seenActionTipFlagValue); diff --git a/scripts/server/job.js b/scripts/server/job.js index 3a5981cd..d9ab5d95 100644 --- a/scripts/server/job.js +++ b/scripts/server/job.js @@ -1394,11 +1394,15 @@ function jobEquipmentCommand(command, params, client) { givePlayerJobEquipment(client, equipmentId - 1); //messagePlayerSuccess(client, `You have been given the ${equipments[equipmentId-1].name} equipment`); meActionToNearbyPlayers(client, `grabs the ${jobEquipmentData.name} equipment from the locker`); - if (doesPlayerHaveKeyBindForCommand(client, "inv")) { - messagePlayerTip(client, getLocaleString(client, "JobEquipmentInventoryKeyBindTip", toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "inv").key)))); - } else { - messagePlayerTip(client, getLocaleString(client, "JobEquipmentInventoryCommandTip", "/inv")); + if (!hasPlayerSeenActionTip(client, "JobEquipmentInventory")) { + if (doesPlayerHaveKeyBindForCommand(client, "inv")) { + messagePlayerTip(client, getIndexedLocaleString(client, "ActionTips", "JobEquipmentInventory", toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "inv").key)))); + } else { + messagePlayerTip(client, getIndexedLocaleString(client, "ActionTips", "JobEquipmentInventory", "/inv")); + } + markPlayerActionTipSeen(client, "JobEquipmentInventory"); } + } // =========================================================================== From cdebb12226c5fe1a71afccade781f73f2c9ee028 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Tue, 23 Aug 2022 14:28:38 -0500 Subject: [PATCH 003/221] Use new currency string --- config/economy.json | 1 + scripts/client/economy.js | 27 +++++++++++++++++++++++++++ scripts/client/gui/charselect.js | 4 ++-- scripts/client/netevents.js | 25 ++++++++++++++++--------- scripts/server/business.js | 26 +++++++++++++------------- scripts/server/economy.js | 20 ++++++++++++++------ scripts/server/event.js | 6 +++--- scripts/server/house.js | 4 ++-- scripts/server/item.js | 4 ++-- scripts/server/job.js | 6 +++--- scripts/server/misc.js | 4 ++-- scripts/server/netevents.js | 6 ++++++ scripts/server/staff.js | 6 +++--- scripts/server/vehicle.js | 6 +++--- 14 files changed, 97 insertions(+), 48 deletions(-) create mode 100644 scripts/client/economy.js diff --git a/config/economy.json b/config/economy.json index 15284ba5..549a9759 100644 --- a/config/economy.json +++ b/config/economy.json @@ -4,6 +4,7 @@ "applyUpkeep": true, "grossIncomeMultiplier": 1.0, "incomeTaxRate": 0.7, + "currencyString": "${AMOUNT}", "upKeepCosts": { "upKeepPerVehicle": 250, "upKeepPerHouse": 350, diff --git a/scripts/client/economy.js b/scripts/client/economy.js new file mode 100644 index 00000000..fcdb6cf0 --- /dev/null +++ b/scripts/client/economy.js @@ -0,0 +1,27 @@ +// =========================================================================== +// Asshat Gaming Roleplay +// https://github.com/VortrexFTW/agrp_main +// (c) 2022 Asshat Gaming +// =========================================================================== +// FILE: economy.js +// DESC: Provides economy functions +// TYPE: Client (JavaScript) +// =========================================================================== + +let currencyString = "{AMOUNT}"; + +// =========================================================================== + +function getCurrencyString(amount) { + let tempString = currencyString; + tempString = tempString.replace("{AMOUNT}", toString(makeLargeNumberReadable(amount))); + return tempString; +} + +// =========================================================================== + +function receiveCurrencyStringFromServer(newCurrencyString) { + currencyString = newCurrencyString; +} + +// =========================================================================== \ No newline at end of file diff --git a/scripts/client/gui/charselect.js b/scripts/client/gui/charselect.js index f46f4a9c..5f83562b 100644 --- a/scripts/client/gui/charselect.js +++ b/scripts/client/gui/charselect.js @@ -162,7 +162,7 @@ function showCharacterSelectGUI(firstName, lastName, cash, clan, lastPlayed, ski setChatWindowEnabled(false); mexui.setInput(true); characterSelect.nameText.text = `${firstName} ${lastName}`; - characterSelect.cashText.text = `Money: $${cash}`; + characterSelect.cashText.text = `Money: ${getCurrencyString(cash)}`; characterSelect.clanText.text = `Clan: ${clan}`; characterSelect.lastPlayedText.text = `Last Played: ${lastPlayed}`; characterSelect.skinImage = characterSelect.window.image(310, 32, 100, 90, "files/images/skins/none.png"); @@ -211,7 +211,7 @@ function switchCharacterSelectGUI(firstName, lastName, cash, clan, lastPlayed, s setChatWindowEnabled(false); characterSelect.window.shown = false; characterSelect.nameText.text = `${firstName} ${lastName}`; - characterSelect.cashText.text = `Money: $${cash}`; + characterSelect.cashText.text = `Money: ${getCurrencyString(cash)}`; characterSelect.clanText.text = `Clan: ${clan}`; characterSelect.lastPlayedText.text = `Last Played: ${lastPlayed}`; diff --git a/scripts/client/netevents.js b/scripts/client/netevents.js index e7a1e715..780733cf 100644 --- a/scripts/client/netevents.js +++ b/scripts/client/netevents.js @@ -70,6 +70,7 @@ function addAllNetworkHandlers() { addNetworkEventHandler("agrp.veh.engine", setVehicleEngine); addNetworkEventHandler("agrp.veh.repair", repairVehicle); addNetworkEventHandler("agrp.cruiseControl", toggleVehicleCruiseControl); + addNetworkEventHandler("agrp.passenger", enterVehicleAsPassenger); // Radio addNetworkEventHandler("agrp.radioStream", playStreamingRadio); @@ -109,6 +110,11 @@ function addAllNetworkHandlers() { addNetworkEventHandler("agrp.showLocaleChooser", showLocaleChooserGUI); addNetworkEventHandler("agrp.guiColour", setGUIColours); + // 2D Rendering + addNetworkEventHandler("agrp.set2DRendering", set2DRendering); + addNetworkEventHandler("agrp.logo", setServerLogoRenderState); + addNetworkEventHandler("agrp.showItemActionDelay", showItemActionDelay); + // Business addNetworkEventHandler("agrp.business", receiveBusinessFromServer); @@ -122,13 +128,20 @@ function addAllNetworkHandlers() { addNetworkEventHandler("agrp.locale", setLocale); addNetworkEventHandler("agrp.localeChooser", toggleLocaleChooserGUI); + // Animation + addNetworkEventHandler("agrp.anim", makePedPlayAnimation); + addNetworkEventHandler("agrp.stopAnim", makePedStopAnimation); + addNetworkEventHandler("agrp.forceAnim", forcePedAnimation); + + // Nametags + addNetworkEventHandler("agrp.nametag", updatePlayerNameTag); + addNetworkEventHandler("agrp.nametagDistance", setNameTagDistance); + // Misc addNetworkEventHandler("agrp.mouseCursor", toggleMouseCursor); addNetworkEventHandler("agrp.mouseCamera", toggleMouseCamera); addNetworkEventHandler("agrp.clearPeds", clearLocalPlayerOwnedPeds); addNetworkEventHandler("agrp.clearPickups", clearLocalPlayerOwnedPickups); - addNetworkEventHandler("agrp.passenger", enterVehicleAsPassenger); - addNetworkEventHandler("agrp.logo", setServerLogoRenderState); addNetworkEventHandler("agrp.ambience", setCityAmbienceState); addNetworkEventHandler("agrp.runCode", runClientCode); addNetworkEventHandler("agrp.minuteDuration", setMinuteDuration); @@ -136,17 +149,10 @@ function addAllNetworkHandlers() { addNetworkEventHandler("agrp.enterPropertyKey", setEnterPropertyKey); addNetworkEventHandler("agrp.skinSelect", toggleSkinSelect); addNetworkEventHandler("agrp.hotbar", updatePlayerHotBar); - addNetworkEventHandler("agrp.showItemActionDelay", showItemActionDelay); - addNetworkEventHandler("agrp.set2DRendering", set2DRendering); addNetworkEventHandler("agrp.mouseCameraForce", setMouseCameraState); addNetworkEventHandler("agrp.logLevel", setLogLevel); addNetworkEventHandler("agrp.hideAllGUI", hideAllGUI); - addNetworkEventHandler("agrp.nametag", updatePlayerNameTag); - addNetworkEventHandler("agrp.nametagDistance", setNameTagDistance); addNetworkEventHandler("agrp.ping", updatePlayerPing); - addNetworkEventHandler("agrp.anim", makePedPlayAnimation); - addNetworkEventHandler("agrp.stopAnim", makePedStopAnimation); - addNetworkEventHandler("agrp.forceAnim", forcePedAnimation); addNetworkEventHandler("agrp.clientInfo", serverRequestedClientInfo); addNetworkEventHandler("agrp.interiorLights", updateInteriorLightsState); addNetworkEventHandler("agrp.cutsceneInterior", setCutsceneInterior); @@ -156,6 +162,7 @@ function addAllNetworkHandlers() { addNetworkEventHandler("agrp.vehBuyState", setVehiclePurchaseState); addNetworkEventHandler("agrp.holdObject", makePedHoldObject); addNetworkEventHandler("agrp.profanityFilter", setProfanityFilterState); + addNetworkEventHandler("agrp.currencyString", receiveCurrencyStringFromServer); } // =========================================================================== diff --git a/scripts/server/business.js b/scripts/server/business.js index c7523922..1029169a 100644 --- a/scripts/server/business.js +++ b/scripts/server/business.js @@ -847,7 +847,7 @@ function setBusinessEntranceFeeCommand(command, params, client) { getBusinessData(businessId).entranceFee = entranceFee; getBusinessData(businessId).needsSaved = true; - messagePlayerSuccess(client, `{MAINCOLOUR}You set business {businessBlue}${getBusinessData(businessId).name}{MAINCOLOUR} entrance fee to [#AAAAAAA]$${entranceFee}`); + messagePlayerSuccess(client, `{MAINCOLOUR}You set business {businessBlue}${getBusinessData(businessId).name}{MAINCOLOUR} entrance fee to {ALTCOLOUR}${getCurrencyString(entranceFee)}`); } // =========================================================================== @@ -940,14 +940,14 @@ function getBusinessInfoCommand(command, params, client) { [`ID`, `${businessData.index}/${businessData.databaseId}`], [`Owner`, `${ownerName} (${getBusinessOwnerTypeText(businessData.ownerType)})`], [`Locked`, `${getLockedUnlockedFromBool(businessData.locked)}`], - [`BuyPrice`, `$${businessData.buyPrice}`], + [`BuyPrice`, `${getCurrencyString(businessData.buyPrice)}`], //[`RentPrice`, `${businessData.rentPrice}`], [`HasInterior`, `${getYesNoFromBool(businessData.hasInterior)}`], [`CustomInterior`, `${getYesNoFromBool(businessData.customInterior)}`], [`HasBuyableItems`, `${getYesNoFromBool(doesBusinessHaveAnyItemsToBuy(businessId))}`], - [`EntranceFee`, `$${businessData.entranceFee}`], + [`EntranceFee`, `${getCurrencyString(businessData.entranceFee)}`], [`InteriorLights`, `${getOnOffFromBool(businessData.interiorLights)}`], - [`Balance`, `$${businessData.till}`], + [`Balance`, `${getCurrencyString(businessData.till)}`], [`RadioStation`, `${businessData.streamingRadioStation}`], [`LabelHelpType`, `${businessData.labelHelpType}`], ]; @@ -1409,7 +1409,7 @@ function withdrawFromBusinessCommand(command, params, client) { updatePlayerCash(client); getBusinessData(businessId).needsSaved = true; - messagePlayerSuccess(client, `You withdrew $${amount} from business {businessBlue}${getBusinessData(businessId).name} till`); + messagePlayerSuccess(client, `You withdrew ${getCurrencyString(amount)} from business {businessBlue}${getBusinessData(businessId).name} till`); } // =========================================================================== @@ -1451,7 +1451,7 @@ function setBusinessBuyPriceCommand(command, params, client) { setEntityData(getBusinessData(businessId).entrancePickup, "agrp.label.price", getBusinessData(businessId).buyPrice, true); getBusinessData(businessId).needsSaved = true; - messagePlayerSuccess(client, `{MAINCOLOUR}You set business {businessBlue}${getBusinessData(businessId).name}'s {MAINCOLOUR}for-sale price to {ALTCOLOUR}$${makeLargeNumberReadable(amount)}`); + messagePlayerSuccess(client, `{MAINCOLOUR}You set business {businessBlue}${getBusinessData(businessId).name}'s{MAINCOLOUR} for-sale price to {ALTCOLOUR}${getCurrencyString(amount)}`); } // =========================================================================== @@ -1486,7 +1486,7 @@ function depositIntoBusinessCommand(command, params, client) { //} if (getPlayerCurrentSubAccount(client).cash < amount) { - messagePlayerError(client, `You don't have that much money! You only have $${getPlayerCurrentSubAccount(client).cash}`); + messagePlayerError(client, `You don't have that much money! You only have ${getCurrencyString(getPlayerCurrentSubAccount(client).cash)}`); return false; } @@ -1495,7 +1495,7 @@ function depositIntoBusinessCommand(command, params, client) { updatePlayerCash(client); getBusinessData(businessId).needsSaved = true; - messagePlayerSuccess(client, `You deposited $${amount} into business {businessBlue}${getBusinessData(businessId).name} {MAINCOLOUR}till`); + messagePlayerSuccess(client, `You deposited ${getCurrencyString(amount)} into business {businessBlue}${getBusinessData(businessId).name}{MAINCOLOUR} till`); } // =========================================================================== @@ -1556,7 +1556,7 @@ function orderItemForBusinessCommand(command, params, client) { getPlayerData(client).businessOrderCost = orderTotalCost; getBusinessData(businessId).needsSaved = true; - showPlayerPrompt(client, `Ordering ${amount} ${getPluralForm(getItemTypeData(itemType).name)} (${getItemValueDisplay(itemType, value)}) at $${makeLargeNumberReadable(pricePerItem)} each will cost a total of $${makeLargeNumberReadable(orderTotalCost)}`, "Business Order Cost"); + showPlayerPrompt(client, `Ordering ${amount} ${getPluralForm(getItemTypeData(itemType).name)} (${getItemValueDisplay(itemType, value)}) at ${getCurrencyString(pricePerItem)} each will cost a total of ${getCurrencyString(orderTotalCost)}`, "Business Order Cost"); getPlayerData(client).promptType = AGRP_PROMPT_BIZORDER; } @@ -1574,13 +1574,13 @@ function orderItemForBusinessCommand(command, params, client) { function orderItemForBusiness(businessId, itemType, amount) { if (getBusinessData(businessId).till < orderTotalCost) { let neededAmount = orderTotalCost - getBusinessData(businessId).till; - //messagePlayerError(client, `The business doesn't have enough money (needs {ALTCOLOUR}$${neededAmount} {MAINCOLOUR}more)! Use {ALTCOLOUR}/bizdeposit {MAINCOLOUR}to add money to the business.`); + //messagePlayerError(client, `The business doesn't have enough money (needs {ALTCOLOUR}${getCurrencyString(neededAmount)} {MAINCOLOUR}more)! Use {ALTCOLOUR}/bizdeposit {MAINCOLOUR}to add money to the business.`); return false; } getBusinessData(businessId).till -= orderTotalCost; addToBusinessInventory(businessId, itemType, amount); - //messagePlayerSuccess(client, `You ordered ${amount} ${getPluralForm(getItemTypeData(itemType).name)} (${getItemValueDisplay(itemType, value)}) at $${getItemTypeData(itemType).orderPrice} each for business {businessBlue}${getBusinessData(businessId).name}`); + //messagePlayerSuccess(client, `You ordered ${amount} ${getPluralForm(getItemTypeData(itemType).name)} (${getItemValueDisplay(itemType, value)}) at ${getCurrencyString(getItemTypeData(itemType).orderPrice)} each for business {businessBlue}${getBusinessData(businessId).name}`); } // =========================================================================== @@ -1611,7 +1611,7 @@ function viewBusinessTillAmountCommand(command, params, client) { return false; } - messagePlayerSuccess(client, `Business {businessBlue}${getBusinessData(businessId).name}{MAINCOLOUR} till has {ALTCOLOUR}$${getBusinessData(businessId).till}`); + messagePlayerSuccess(client, `Business {businessBlue}${getBusinessData(businessId).name}{MAINCOLOUR} till has {ALTCOLOUR}${getCurrencyString(getBusinessData(businessId).till)}`); } // =========================================================================== @@ -2722,7 +2722,7 @@ function setBusinessItemSellPriceCommand(command, params, client) { getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).buyPrice = newPrice; - messagePlayerSuccess(client, `You changed the price of the {ALTCOLOUR}${getItemTypeData(getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).itemTypeIndex).name}'s {MAINCOLOUR}in slot {ALTCOLOUR}${itemSlot} {MAINCOLOUR}from $${makeLargeNumberReadable(oldPrice)} to $${makeLargeNumberReadable(newprice)}`); + messagePlayerSuccess(client, `You changed the price of the {ALTCOLOUR}${getItemTypeData(getItemData(getBusinessData(businessId).floorItemCache[itemSlot - 1]).itemTypeIndex).name}'s {MAINCOLOUR}in slot {ALTCOLOUR}${itemSlot} {MAINCOLOUR}from ${getCurrencyString(oldPrice)} to ${getCurrencyString(newprice)}`); } // =========================================================================== diff --git a/scripts/server/economy.js b/scripts/server/economy.js index 68b08a59..a8555f2c 100644 --- a/scripts/server/economy.js +++ b/scripts/server/economy.js @@ -47,15 +47,15 @@ function playerPayDay(client) { let netIncome = Math.round(grossIncome - incomeTaxAmount); messagePlayerAlert(client, "== Payday! ============================="); - messagePlayerInfo(client, `Paycheck: {ALTCOLOUR}$${grossIncome}`); - messagePlayerInfo(client, `Taxes: {ALTCOLOUR}$${incomeTaxAmount}`); - messagePlayerInfo(client, `You receive: {ALTCOLOUR}$${netIncome}`); + messagePlayerInfo(client, `Paycheck: {ALTCOLOUR}${getCurrencyString(grossIncome)}`); + messagePlayerInfo(client, `Taxes: {ALTCOLOUR}${getCurrencyString(incomeTaxAmount)}`); + messagePlayerInfo(client, `You receive: {ALTCOLOUR}${getCurrencyString(netIncome)}`); if (netIncome < incomeTaxAmount) { let totalCash = getPlayerCash(client); let canPayNow = totalCash + netIncome; if (incomeTaxAmount <= canPayNow) { takePlayerCash(client, canPayNow); - messagePlayerInfo(client, `{orange}${getLocaleString(client, "RemainingTaxPaidInCash", `{ALTCOLOUR}${canPayNow}{MAINCOLOUR}`)}`); + messagePlayerInfo(client, `{orange}${getLocaleString(client, "RemainingTaxPaidInCash", `{ALTCOLOUR}${getCurrencyString(canPayNow)}{MAINCOLOUR}`)}`); messagePlayerAlert(client, `{orange}${getLocaleString(client, "LostMoneyFromTaxes")}`); messagePlayerAlert(client, `{orange}${getLocaleString(client, "NextPaycheckRepossessionWarning")}`); } else { @@ -141,14 +141,14 @@ function setPayDayBonusMultiplier(command, params, client) { function taxInfoCommand(command, params, client) { let wealth = calculateWealth(client); let tax = calculateIncomeTax(wealth); - messagePlayerInfo(client, `Your tax on payday is: $${tax}. Use {ALTCOLOUR}/help tax {MAINCOLOUR}for more information.`); + messagePlayerInfo(client, `Your tax on payday is: ${getCurrencyString(tax)}. Use {ALTCOLOUR}/help tax {MAINCOLOUR}for more information.`); } // =========================================================================== function wealthInfoCommand(command, params, client) { let wealth = calculateWealth(client); - messagePlayerInfo(client, `Your wealth is: {ALTCOLOUR}$${wealth}{MAINCOLOUR}. Use {ALTCOLOUR}/help wealth {MAINCOLOUR}for more information.`); + messagePlayerInfo(client, `Your wealth is: {ALTCOLOUR}${getCurrencyString(wealth)}{MAINCOLOUR}. Use {ALTCOLOUR}/help wealth {MAINCOLOUR}for more information.`); } // =========================================================================== @@ -213,4 +213,12 @@ function isDoubleBonusActive() { return false; } +// =========================================================================== + +function getCurrencyString(amount) { + let tempString = getEconomyConfig().currencyString + tempString = tempString.replace("{AMOUNT}", toString(makeLargeNumberReadable(amount))); + return tempString; +} + // =========================================================================== \ No newline at end of file diff --git a/scripts/server/event.js b/scripts/server/event.js index c706b2af..767d0910 100644 --- a/scripts/server/event.js +++ b/scripts/server/event.js @@ -694,14 +694,14 @@ function onPedEnteredVehicle(event, ped, vehicle, seat) { vehicle.engine = getVehicleData(vehicle).engine; if (getVehicleData(vehicle).buyPrice > 0) { - messagePlayerAlert(client, getLocaleString(client, "VehicleForSale", getVehicleName(vehicle), `{ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).buyPrice)}{MAINCOLOUR}`, `{ALTCOLOUR}/vehbuy{MAINCOLOUR}`)); + messagePlayerAlert(client, getLocaleString(client, "VehicleForSale", getVehicleName(vehicle), `{ALTCOLOUR}${getCurrencyString(getVehicleData(vehicle).buyPrice)}{MAINCOLOUR}`, `{ALTCOLOUR}/vehbuy{MAINCOLOUR}`)); resetVehiclePosition(vehicle); } else if (getVehicleData(vehicle).rentPrice > 0) { if (getVehicleData(vehicle).rentedBy != client) { - messagePlayerAlert(client, getLocaleString(client, "VehicleForRent", getVehicleName(vehicle), `{ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).rentPrice)}{MAINCOLOUR}`, `{ALTCOLOUR}/vehrent{MAINCOLOUR}`)); + messagePlayerAlert(client, getLocaleString(client, "VehicleForRent", getVehicleName(vehicle), `{ALTCOLOUR}${getCurrencyString(getVehicleData(vehicle).rentPrice)}{MAINCOLOUR}`, `{ALTCOLOUR}/vehrent{MAINCOLOUR}`)); resetVehiclePosition(vehicle); } else { - messagePlayerAlert(client, getLocaleString(client, "CurrentlyRentingThisVehicle", `{vehiclePurple}${getVehicleName(vehicle)}{MAINCOLOUR}`, `{ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).rentPrice)}`, `{ALTCOLOUR}/stoprent{MAINCOLOUR}`)); + messagePlayerAlert(client, getLocaleString(client, "CurrentlyRentingThisVehicle", `{vehiclePurple}${getVehicleName(vehicle)}{MAINCOLOUR}`, `{ALTCOLOUR}${getCurrencyString(getVehicleData(vehicle).rentPrice)}`, `{ALTCOLOUR}/stoprent{MAINCOLOUR}`)); } } else { let ownerName = "Nobody"; diff --git a/scripts/server/house.js b/scripts/server/house.js index 7f9be89a..6819a946 100644 --- a/scripts/server/house.js +++ b/scripts/server/house.js @@ -1384,7 +1384,7 @@ function setHouseBuyPriceCommand(command, params, client) { getHouseData(houseId).buyPrice = amount; getHouseData(houseId).needsSaved = true; updateHousePickupLabelData(houseId); - messagePlayerSuccess(client, `{MAINCOLOUR}You set house {houseGreen}${getHouseData(houseId).description}'s{MAINCOLOUR} for-sale price to {ALTCOLOUR}$${makeLargeNumberReadable(amount)}`); + messagePlayerSuccess(client, `{MAINCOLOUR}You set house {houseGreen}${getHouseData(houseId).description}'s{MAINCOLOUR} for-sale price to {ALTCOLOUR}${getCurrencyString(amount)}`); } // =========================================================================== @@ -1422,7 +1422,7 @@ function setHouseRentPriceCommand(command, params, client) { getHouseData(houseId).rentPrice = amount; getHouseData(houseId).needsSaved = true; updateHousePickupLabelData(houseId); - messagePlayerSuccess(client, `{MAINCOLOUR}You set house {houseGreen}${getHouseData(houseId).description}'s{MAINCOLOUR} rent price to {ALTCOLOUR}$${makeLargeNumberReadable(amount)}`); + messagePlayerSuccess(client, `{MAINCOLOUR}You set house {houseGreen}${getHouseData(houseId).description}'s{MAINCOLOUR} rent price to {ALTCOLOUR}${getCurrencyString(amount)}`); } // =========================================================================== diff --git a/scripts/server/item.js b/scripts/server/item.js index 8b4bcda6..d34e31ea 100644 --- a/scripts/server/item.js +++ b/scripts/server/item.js @@ -887,7 +887,7 @@ function setItemTypeOrderPriceCommand(command, params, client) { getItemTypeData(itemTypeIndex).orderPrice = orderPrice; getItemTypeData(itemTypeIndex).needsSaved = true; - messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} set item type {ALTCOLOUR}${getItemTypeData(itemTypeIndex).name}{MAINCOLOUR} base price to {ALTCOLOUR}$${orderPrice}`); + messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} set item type {ALTCOLOUR}${getItemTypeData(itemTypeIndex).name}{MAINCOLOUR} base price to {ALTCOLOUR}${getCurrencyString(orderPrice)}`); } // =========================================================================== @@ -2940,7 +2940,7 @@ function showBusinessFloorInventoryToPlayer(client, businessId) { if (getBusinessData(businessId).floorItemCache == -1) { itemDisplay.push(`{MAINCOLOUR}${toInteger(i) + 1}{ALTCOLOUR}(Empty)`); } else { - itemDisplay.push(`{MAINCOLOUR}${toInteger(i) + 1}: {ALTCOLOUR}${getItemTypeData(getItemData(getBusinessData(businessId).floorItemCache[i]).itemTypeIndex).name} - ${(getPlayerCurrentSubAccount(client).cash > getItemData(getBusinessData(businessId).floorItemCache[i]).buyPrice) ? "{softGreen}" : "{softRed}"}$${getItemData(getBusinessData(businessId).floorItemCache[i]).buyPrice}`); + itemDisplay.push(`{MAINCOLOUR}${toInteger(i) + 1}: {ALTCOLOUR}${getItemTypeData(getItemData(getBusinessData(businessId).floorItemCache[i]).itemTypeIndex).name} - ${(getPlayerCurrentSubAccount(client).cash > getItemData(getBusinessData(businessId).floorItemCache[i]).buyPrice) ? "{softGreen}" : "{softRed}"}${getCurrencyString(getItemData(getBusinessData(businessId).floorItemCache[i]).buyPrice)}`); } } diff --git a/scripts/server/job.js b/scripts/server/job.js index d9ab5d95..55e5c3f7 100644 --- a/scripts/server/job.js +++ b/scripts/server/job.js @@ -2143,7 +2143,7 @@ function setJobRoutePayCommand(command, params, client) { getJobData(jobId).routes[jobRoute].pay = toInteger(amount); getJobData(jobId).routes[jobRoute].needsSaved = true; - messageAdmins(`{adminOrange}${getPlayerName(client)} {MAINCOLOUR} set the pay for route {ALTCOLOUR}${getJobRouteData(jobId, jobRoute).name}{MAINCOLOUR} of the {jobYellow}${getJobData(jobId).name}{MAINCOLOUR} job to {ALTCOLOUR}$${makeLargeNumberReadable(amount)} {MAINCOLOUR} `); + messageAdmins(`{adminOrange}${getPlayerName(client)} {MAINCOLOUR} set the pay for route {ALTCOLOUR}${getJobRouteData(jobId, jobRoute).name}{MAINCOLOUR} of the {jobYellow}${getJobData(jobId).name}{MAINCOLOUR} job to {ALTCOLOUR}${getCurrencyString(amount)} {MAINCOLOUR} `); } // =========================================================================== @@ -3860,7 +3860,7 @@ function finishSuccessfulJobRoute(client) { let payout = toInteger(applyServerInflationMultiplier(jobRouteData.pay)); getPlayerData(client).payDayAmount = getPlayerData(client).payDayAmount + payout; - messageDiscordEventChannel(`💼 ${getCharacterFullName(client)} finished the ${jobRouteData.name} route for the ${getJobData(jobId).name} job and earned $${jobRouteData.pay}!`); + messageDiscordEventChannel(`💼 ${getCharacterFullName(client)} finished the ${jobRouteData.name} route for the ${getJobData(jobId).name} job and earned ${getCurrencyString(jobRouteData.pay)}!`); messagePlayerSuccess(client, replaceJobRouteStringsInMessage(jobRouteData.finishMessage, jobId, jobRouteData.index)); stopReturnToJobVehicleCountdown(client); @@ -3920,7 +3920,7 @@ function replaceJobRouteStringsInMessage(messageText, jobId, jobRouteId) { tempFind = `{JOBROUTEPAY}`; tempRegex = new RegExp(tempFind, 'g'); - messageText = messageText.replace(tempRegex, `$${tempJobRouteData.pay}`); + messageText = messageText.replace(tempRegex, `${getCurrencyString(tempJobRouteData.pay)}`); tempFind = `{JOBNAME}`; tempRegex = new RegExp(tempFind, 'g'); diff --git a/scripts/server/misc.js b/scripts/server/misc.js index f74db179..1ca906e5 100644 --- a/scripts/server/misc.js +++ b/scripts/server/misc.js @@ -144,7 +144,7 @@ function setNewCharacterMoneyCommand(command, params, client) { getServerConfig().newCharacter.cash = amount; getServerConfig().needsSaved = true; - messagePlayerNormal(client, `The new character money has been set to $${amount}`); + messagePlayerNormal(client, `The new character money has been set to ${getCurrencyString(amount)}`); return true; } @@ -457,7 +457,7 @@ function getPlayerInfoCommand(command, params, client) { ["Script Version", `${scriptVersion}`], ["Client Version", `${getPlayerData(targetClient).clientVersion}`], ["Client Version", `${getPlayerData(targetClient).clientVersion}`], - ["Cash", `$${getPlayerCurrentSubAccount(client).cash}`], + ["Cash", `${getCurrencyString(getPlayerCurrentSubAccount(client).cash)}`], ["Skin", `${skinName}{mediumGrey}[${skinModel}]{ALTCOLOUR}`], ["Clan", `${clan}`], ["Job", `${job}`], diff --git a/scripts/server/netevents.js b/scripts/server/netevents.js index c5f26451..4b6e93a8 100644 --- a/scripts/server/netevents.js +++ b/scripts/server/netevents.js @@ -1275,4 +1275,10 @@ function showSingleParticleEffect(position, particleEffectId, strength = 1.0, du sendNetworkEventToPlayer("agrp.particleEffectSingle", null, position, particleEffectId, strength, duration); } +// ========================================================================== + +function sendPlayerCurrencyString(client) { + sendNetworkEventToPlayer("agrp.currencyString", client, getEconomyConfig().currencyString); +} + // ========================================================================== \ No newline at end of file diff --git a/scripts/server/staff.js b/scripts/server/staff.js index b3542b94..dd505f8a 100644 --- a/scripts/server/staff.js +++ b/scripts/server/staff.js @@ -1181,9 +1181,9 @@ function givePlayerMoneyCommand(command, params, client) { givePlayerCash(targetClient, toInteger(amount)); updatePlayerCash(targetClient); - //messagePlayerSuccess(client, `You gave {ALTCOLOUR}$${amount} {MAINCOLOUR}to {ALTCOLOUR}${getCharacterFullName(targetClient)}`); - messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} gave {ALTCOLOUR}$${amount}{MAINCOLOUR} to {ALTCOLOUR}${getCharacterFullName(targetClient)}`) - messagePlayerAlert(targetClient, `An admin gave you {ALTCOLOUR}$${amount}`); + //messagePlayerSuccess(client, `You gave {ALTCOLOUR}${getCurrencyString(amount)} {MAINCOLOUR}to {ALTCOLOUR}${getCharacterFullName(targetClient)}`); + messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} gave {ALTCOLOUR}${getCurrencyString(amount)}{MAINCOLOUR} to {ALTCOLOUR}${getCharacterFullName(targetClient)}`) + messagePlayerAlert(targetClient, `An admin gave you {ALTCOLOUR}${getCurrencyString(amount)}`); } // =========================================================================== diff --git a/scripts/server/vehicle.js b/scripts/server/vehicle.js index 30be3981..5cba6636 100644 --- a/scripts/server/vehicle.js +++ b/scripts/server/vehicle.js @@ -659,7 +659,7 @@ function vehicleAdminLiveryCommand(command, params, client) { } if (getPlayerCurrentSubAccount(client).cash < getGlobalConfig().repairVehicleCost) { - messagePlayerError(client, `You don't have enough money to change the vehicle's livery (need $${makeLargeNumberReadable(getGlobalConfig().resprayVehicleCost - getPlayerCurrentSubAccount(client).cash)} more!)`); + messagePlayerError(client, `You don't have enough money to change the vehicle's livery (need ${getCurrencyString(getGlobalConfig().resprayVehicleCost - getPlayerCurrentSubAccount(client).cash)} more!)`); return false; } @@ -1084,7 +1084,7 @@ function setVehicleRentPriceCommand(command, params, client) { getVehicleData(vehicle).rentPrice = amount; getVehicleData(vehicle).needsSaved = true; - messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set their {vehiclePurple}${getVehicleName(vehicle)}{MAINCOLOUR} rent price to {ALTCOLOUR}$${makeLargeNumberReadable(amount)}`); + messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set their {vehiclePurple}${getVehicleName(vehicle)}{MAINCOLOUR} rent price to {ALTCOLOUR}${getCurrencyString(amount)}`); } // =========================================================================== @@ -1113,7 +1113,7 @@ function setVehicleBuyPriceCommand(command, params, client) { getVehicleData(vehicle).buyPrice = amount; getVehicleData(vehicle).needsSaved = true; - messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set their {vehiclePurple}${getVehicleName(vehicle)}'s{MAINCOLOUR} buy price to {ALTCOLOUR}$${makeLargeNumberReadable(amount)}`); + messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set their {vehiclePurple}${getVehicleName(vehicle)}'s{MAINCOLOUR} buy price to {ALTCOLOUR}${getCurrencyString(amount)}`); } // =========================================================================== From 78959dbef96bf50380e3edb2a27b5abfbfce53ed Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Tue, 23 Aug 2022 14:28:51 -0500 Subject: [PATCH 004/221] Move client init func to client.js --- scripts/server/account.js | 88 -------------------------------------- scripts/server/client.js | 89 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 88 deletions(-) diff --git a/scripts/server/account.js b/scripts/server/account.js index e923a0c2..9eec97a4 100644 --- a/scripts/server/account.js +++ b/scripts/server/account.js @@ -1440,94 +1440,6 @@ function savePlayerToDatabase(client) { // =========================================================================== -function initClient(client) { - logToConsole(LOG_DEBUG, `[VRR.Account] Initializing client ${getPlayerDisplayForConsole(client)} ...`); - - if (isConsole(client)) { - logToConsole(LOG_DEBUG | LOG_ERROR, `[VRR.Account] Client initialization failed for ${getPlayerDisplayForConsole(client)}! (is console client)`); - return false; - } - - logToConsole(LOG_DEBUG, `[VRR.Account] Initializing client ${getPlayerDisplayForConsole(client)} ...`); - - if (playerInitialized[client.index] == true) { - logToConsole(LOG_DEBUG | LOG_ERROR, `[VRR.Account] Client initialization failed for ${getPlayerDisplayForConsole(client)}! (already initialized)`); - return false; - } - - playerInitialized[client.index] = true; - - //setEntityData(client, "agrp.isInitialized", true, false); - - logToConsole(LOG_DEBUG, `[VRR.Account] Initializing GUI for ${getPlayerDisplayForConsole(client)} ...`); - sendPlayerGUIColours(client); - sendPlayerGUIInit(client); - updatePlayerSnowState(client); - - //logToConsole(LOG_DEBUG, `[VRR.Account] Showing connect camera to ${getPlayerDisplayForConsole(client)} ...`); - //showConnectCameraToPlayer(client); - - messageClient(`Please wait ...`, client, getColourByName("softGreen")); - - logToConsole(LOG_DEBUG, `[VRR.Account] Waiting for 2.5 seconds to prevent race attack ...`); - setTimeout(function () { - if (client != null) { - clearChatBox(client); - logToConsole(LOG_DEBUG, `[VRR.Account] Loading account for ${getPlayerDisplayForConsole(client)}`); - let tempAccountData = loadAccountFromName(getPlayerName(client), true); - - logToConsole(LOG_DEBUG, `[VRR.Account] Loading subaccounts for ${getPlayerDisplayForConsole(client)}`); - let tempSubAccounts = loadSubAccountsFromAccount(tempAccountData.databaseId); - - getServerData().clients[getPlayerId(client)] = new ClientData(client, tempAccountData, tempSubAccounts); - - getServerData().clients[getPlayerId(client)].sessionId = saveConnectionToDatabase(client); - getServerData().clients[getPlayerId(client)].connectTime = getCurrentUnixTimestamp(); - requestClientInfo(client); - - if (tempAccountData != false) { - sendPlayerLocaleId(client, getPlayerData(client).accountData.locale); - if (isAccountAutoIPLoginEnabled(tempAccountData) && getPlayerData(client).accountData.ipAddress == getPlayerIP(client)) { - messagePlayerAlert(client, getLocaleString(client, "AutoLoggedInIP")); - loginSuccess(client); - playRadioStreamForPlayer(client, getServerIntroMusicURL(), true, getPlayerStreamingRadioVolume(client)); - } else { - if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { - logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI.`); - showPlayerLoginGUI(client); - } else { - logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled).`); - messagePlayerNormal(client, getLocaleString(client, "WelcomeBack", getServerName(), getPlayerName(client), "/login"), getColourByName("softGreen")); - - //if(checkForGeoIPModule()) { - // let iso = module.geoip.getCountryISO(getPlayerIP(client)); - // let localeId = getLocaleFromCountryISO(iso); - //} - //showSmallGameMessage(client, getLocaleString(client, "LocaleOffer", `/lang ${getLocaleData(localeId)[2]}`), getColourByName("white"), 10000, "Roboto"); - } - startLoginTimeoutForPlayer(client); - playRadioStreamForPlayer(client, getServerIntroMusicURL(), true, getPlayerStreamingRadioVolume(client)); - } - } else { - sendPlayerLocaleId(client, 0); - if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { - logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the register GUI.`); - showPlayerRegistrationGUI(client); - } else { - logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the register message (GUI disabled).`); - messagePlayerNormal(client, getLocaleString(client, "WelcomeNewPlayer", getServerName(), getPlayerName(client), "/register"), getColourByName("softGreen")); - } - playRadioStreamForPlayer(client, getServerIntroMusicURL(), true, getPlayerStreamingRadioVolume(client)); - } - - getServerData().clients[getPlayerId(client)].keyBinds = loadAccountKeybindsFromDatabase(getServerData().clients[getPlayerId(client)].accountData.databaseId); - sendAccountKeyBindsToClient(client); - } - }, 2500); -} - -// =========================================================================== - function saveConnectionToDatabase(client) { let dbConnection = connectToDatabase(); if (dbConnection) { diff --git a/scripts/server/client.js b/scripts/server/client.js index 9037c59c..9a646fc8 100644 --- a/scripts/server/client.js +++ b/scripts/server/client.js @@ -192,4 +192,93 @@ function kickAllClients() { }) } +// =========================================================================== + +function initClient(client) { + logToConsole(LOG_DEBUG, `[VRR.Account] Initializing client ${getPlayerDisplayForConsole(client)} ...`); + + if (isConsole(client)) { + logToConsole(LOG_DEBUG | LOG_ERROR, `[VRR.Account] Client initialization failed for ${getPlayerDisplayForConsole(client)}! (is console client)`); + return false; + } + + logToConsole(LOG_DEBUG, `[VRR.Account] Initializing client ${getPlayerDisplayForConsole(client)} ...`); + + if (playerInitialized[client.index] == true) { + logToConsole(LOG_DEBUG | LOG_ERROR, `[VRR.Account] Client initialization failed for ${getPlayerDisplayForConsole(client)}! (already initialized)`); + return false; + } + + playerInitialized[client.index] = true; + + //setEntityData(client, "agrp.isInitialized", true, false); + + logToConsole(LOG_DEBUG, `[VRR.Account] Initializing GUI for ${getPlayerDisplayForConsole(client)} ...`); + sendPlayerCurrencyString(client); + sendPlayerGUIColours(client); + sendPlayerGUIInit(client); + updatePlayerSnowState(client); + + //logToConsole(LOG_DEBUG, `[VRR.Account] Showing connect camera to ${getPlayerDisplayForConsole(client)} ...`); + //showConnectCameraToPlayer(client); + + messageClient(`Please wait ...`, client, getColourByName("softGreen")); + + logToConsole(LOG_DEBUG, `[VRR.Account] Waiting for 2.5 seconds to prevent race attack ...`); + setTimeout(function () { + if (client != null) { + clearChatBox(client); + logToConsole(LOG_DEBUG, `[VRR.Account] Loading account for ${getPlayerDisplayForConsole(client)}`); + let tempAccountData = loadAccountFromName(getPlayerName(client), true); + + logToConsole(LOG_DEBUG, `[VRR.Account] Loading subaccounts for ${getPlayerDisplayForConsole(client)}`); + let tempSubAccounts = loadSubAccountsFromAccount(tempAccountData.databaseId); + + getServerData().clients[getPlayerId(client)] = new ClientData(client, tempAccountData, tempSubAccounts); + + getServerData().clients[getPlayerId(client)].sessionId = saveConnectionToDatabase(client); + getServerData().clients[getPlayerId(client)].connectTime = getCurrentUnixTimestamp(); + requestClientInfo(client); + + if (tempAccountData != false) { + sendPlayerLocaleId(client, getPlayerData(client).accountData.locale); + if (isAccountAutoIPLoginEnabled(tempAccountData) && getPlayerData(client).accountData.ipAddress == getPlayerIP(client)) { + messagePlayerAlert(client, getLocaleString(client, "AutoLoggedInIP")); + loginSuccess(client); + playRadioStreamForPlayer(client, getServerIntroMusicURL(), true, getPlayerStreamingRadioVolume(client)); + } else { + if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { + logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI.`); + showPlayerLoginGUI(client); + } else { + logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled).`); + messagePlayerNormal(client, getLocaleString(client, "WelcomeBack", getServerName(), getPlayerName(client), "/login"), getColourByName("softGreen")); + + //if(checkForGeoIPModule()) { + // let iso = module.geoip.getCountryISO(getPlayerIP(client)); + // let localeId = getLocaleFromCountryISO(iso); + //} + //showSmallGameMessage(client, getLocaleString(client, "LocaleOffer", `/lang ${getLocaleData(localeId)[2]}`), getColourByName("white"), 10000, "Roboto"); + } + startLoginTimeoutForPlayer(client); + playRadioStreamForPlayer(client, getServerIntroMusicURL(), true, getPlayerStreamingRadioVolume(client)); + } + } else { + sendPlayerLocaleId(client, 0); + if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { + logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the register GUI.`); + showPlayerRegistrationGUI(client); + } else { + logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the register message (GUI disabled).`); + messagePlayerNormal(client, getLocaleString(client, "WelcomeNewPlayer", getServerName(), getPlayerName(client), "/register"), getColourByName("softGreen")); + } + playRadioStreamForPlayer(client, getServerIntroMusicURL(), true, getPlayerStreamingRadioVolume(client)); + } + + getServerData().clients[getPlayerId(client)].keyBinds = loadAccountKeybindsFromDatabase(getServerData().clients[getPlayerId(client)].accountData.databaseId); + sendAccountKeyBindsToClient(client); + } + }, 2500); +} + // =========================================================================== \ No newline at end of file From 34e5748df9c42999a411354b7ee372db03a5c001 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Wed, 24 Aug 2022 20:34:33 -0500 Subject: [PATCH 005/221] Add game areas array for GTA 3 --- scripts/shared/gamedata.js | 45 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/scripts/shared/gamedata.js b/scripts/shared/gamedata.js index d0c24551..cba047bf 100644 --- a/scripts/shared/gamedata.js +++ b/scripts/shared/gamedata.js @@ -6710,6 +6710,51 @@ let gameData = { GunMuzzleFlashStays: 20, SingleSparking: 21, } + }, + mapAreas: { + [AGRP_GAME_GTA_III]: [ + [ROADBR1, 1, [[617.442, -958.347, 6.26083], [1065.44, -908.347, 206.261]], 1], + [PORT_W, 0, [[751.68, -1178.22, -13.8723], [1065.68, -958.725, 136.128]], 1], + [FISHFAC, 2, [[944.208, -1149.81, -9.72576], [1016.14, -1076.01, 40.2742]], 1], + [PORT_S, 0, [[1065.88, -1251.55, -13.5049], [1501.88, -1069.93, 136.495]], 1], + [PORT_E, 0, [[1363.68, -1069.65, -18.8643], [1815.68, -613.646, 131.136]], 1], + [PORT_I, 0, [[1065.88, -1069.85, 1.49868], [1363.38, -742.054, 151.499]], 1], + [CHINA, 0, [[745.421, -908.289, -21.203], [1065.42, -463.69, 129.593]], 1], + [REDLIGH, 0, [[745.378, -463.616, -22.6676], [1065.38, -282.616, 147.332]], 1], + [TOWERS, 0, [[745.421, -282.4, -13.4117], [1065.42, -78.7699, 136.588]], 1], + [LITTLEI, 0, [[1065.9, -512.324, -14.296], [1388.9, -78.324, 135.704]], 1], + [HARWOOD, 0, [[745.979, -78.1778, -48.5832], [1388.98, 322.676, 101.417]], 1], + [EASTBAY, 0, [[1389.37, -613.467, -29.883], [1797.6, 199.628, 120.117]], 1], + [S_VIEW, 0, [[1066.1, -741.806, -34.2068], [1363.6, -512.806, 115.793]], 1], + [COPS_1, 2, [[1135.8, -695.021, 6.9661], [1182.36, -631.021, 56.9661]], 1], + [HOSPI_1, 2, [[1136.09, -609.976, 6.287], [1182.09, -521.167, 56.287]], 1], + [IND_ZON, 0, [[617.151, -1329.72, -117.535], [1902.66, 434.115, 482.465]], 1], + [ROADBR2, 1, [[444.768, -958.298, 30.7441], [614.878, -908.298, 180.744]], 2], + [FILLIN1, 2, [[1363.77, -613.339, -4.43849], [1389.17, -512.539, 70.4322]], 1], + [CONSTRU, 0, [[239.878, -411.617, 7.62939], [614.322, -61.6167, 163.819]], 2], + [STADIUM, 0, [[-225.764, -412.604, -9.53674], [116.236, 160.496, 120.271]], 2], + [YAKUSA, 0, [[199.766, -1672.42, -61.7588], [577.766, -1059.93, 432.688]], 2], + [SHOPING, 0, [[-224.438, -1672.05, -61.3183], [99.562, -1004.45, 432.352]], 2], + [COM_EAS, 0, [[200.107, -1059.19, -0.000144958], [615.107, -412.193, 198.864]], 2], + [PARK, 0, [[-121.567, -1003.07, -46.7463], [199.271, -413.068, 224.163]], 2], + [UNIVERS, 0, [[117.268, -411.622, 0.000190735], [239.268, -61.6218, 166.36]], 2], + [HOSPI_2, 0, [[117.236, -61.1105, -17.071], [615.236, 268.889, 83.754]], 2], + [AIRPORT, 0, [[-1632.97, -1344.71, -45.9404], [-468.629, -268.443, 254.696]], 3], + [PROJECT, 0, [[-811.835, -268.074, -45.8745], [-371.041, 92.7263, 254.241]], 3], + [SWANKS, 0, [[-867.229, 93.3882, -50.1134], [-266.914, 650.058, 250.426]], 3], + [SUB_IND, 0, [[-1407.57, -267.966, -49.6792], [-812.306, 92.7559, 250.437]], 3], + [BIG_DAM, 0, [[-1394.5, 93.4441, -46.7412], [-867.52, 704.544, 253.344]], 3], + [MAIN_D1, 2, [[1037.53, -907.274, 0.0, 1065.16], [-637.689, 30.0069]], 1], + [MAIN_D2, 2, [[966.079, -637.366, 0.0, 1064.83], [-609.557, 30.0789]], 1], + [MAIN_D3, 2, [[965.795, -608.99, 0.0, 995.306], [-470.23, 30.9302]], 1], + [MAIN_D4, 2, [[995.59, -511.092, 0.0, 1065.11], [-470.23, 30.0789]], 1], + [MAIN_D5, 2, [[1035.88, -463.56, 0.0, 1064.8], [85, -179.224, 30.6465]], 1], + [SUB_ZON, 0, [[-1644.64, -1351.38, -117.0], [-266.895, 1206.35, 483.0]], 3], + [COM_ZON, 0, [[-265.479, -1719.97, -114.769], [615.52, 367.265, 485.231]], 1], + [SUB_ZO2, 0, [[-265.444, 161.113, -41.7094], [-121.287, 367.043, 358.291]], 1], + [SUB_ZO3, 0, [[-265.434, 79.0922, -45.8201], [-226.334, 161.064, 354.18]], 1], + [WEE_DAM, 2, [[-1238.59, 306.841, -0.48605], [-910.445, 504.646, 39.514]], 3], + ] } }; From f634acbcb8f7e0df1cb1280d2e70531218f524ab Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Sun, 4 Sep 2022 15:47:12 -0500 Subject: [PATCH 006/221] Update locale stuff --- config/client/locale.json | 30 ++++++++++++++++++++++++++++++ config/locale.json | 30 ++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/config/client/locale.json b/config/client/locale.json index 62caa2db..d9c883c3 100644 --- a/config/client/locale.json +++ b/config/client/locale.json @@ -108,5 +108,35 @@ "countries": ["fi"], "requiresUnicode": false, "contributor": "SIMBA_MEOW" + }, + { + "id": 11, + "englishName": "Lithuanian", + "stringsFile": "lithuanian.json", + "isoCode": "lt", + "flagImageFile": "lt.png", + "countries": ["lt"], + "requiresUnicode": false, + "contributor": "dovis" + }, + { + "id": 12, + "englishName": "Latvian", + "stringsFile": "latvian.json", + "isoCode": "lv", + "flagImageFile": "lv.png", + "countries": ["lv"], + "requiresUnicode": false, + "contributor": "YuOn" + }, + { + "id": 13, + "englishName": "Persian", + "stringsFile": "persian.json", + "isoCode": "fa", + "flagImageFile": "ir.png", + "countries": ["ir"], + "requiresUnicode": true, + "contributor": "bigmohammad" } ] \ No newline at end of file diff --git a/config/locale.json b/config/locale.json index 5a68a5de..3ab7e59e 100644 --- a/config/locale.json +++ b/config/locale.json @@ -112,6 +112,36 @@ "countries": ["fi"], "requiresUnicode": false, "contributor": "SIMBA_MEOW" + }, + { + "id": 11, + "englishName": "Lithuanian", + "stringsFile": "lithuanian.json", + "isoCode": "lt", + "flagImageFile": "lt.png", + "countries": ["lt"], + "requiresUnicode": false, + "contributor": "dovis" + }, + { + "id": 12, + "englishName": "Latvian", + "stringsFile": "latvian.json", + "isoCode": "lv", + "flagImageFile": "lv.png", + "countries": ["lv"], + "requiresUnicode": false, + "contributor": "YuOn" + }, + { + "id": 13, + "englishName": "Persian", + "stringsFile": "persian.json", + "isoCode": "fa", + "flagImageFile": "ir.png", + "countries": ["ir"], + "requiresUnicode": true, + "contributor": "bigmohammad" } ] } \ No newline at end of file From 1ebbcb2a86b2cc0dd3fbb13b4711d164c99d514a Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Sun, 4 Sep 2022 15:47:21 -0500 Subject: [PATCH 007/221] Add client-side economy.js --- meta.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/meta.xml b/meta.xml index 0cef5db5..33f9142e 100644 --- a/meta.xml +++ b/meta.xml @@ -111,6 +111,7 @@