Этот ресурс сам по себе ничего не сохраняет. Я также рекомендую вам не иметь более 2 миллиардов любой валюты.
Автор: rootcause
Установка
Поместите файлы, которые вы скачали, в соответствующие места
Проверьте документацию и примеры
Все сделано
Currency API
const currencyAPI = require("../currency-api");
/** * Adds a currency to the system. * @param {String} key Currency identifier. (such as vip_tokens) * @param {String} name Currency's human readable name. (such as VIP Tokens) * @param {Boolean} isShared Whether the currency will use shared data or not. Useful if you want to have a money HUD etc. * @return {Object} The added currency object, will be null if there were any mistakes. * @fires currencyDefined */ currencyAPI.addCurrency(key, name, isShared); /** * Returns whether the specified key is a registered currency or not. * @param {String} key Currency identifier. * @return {Boolean} */ currencyAPI.hasCurrency(key); /** * Returns the specified currency's object. * @param {String} key Currency identifier. * @return {Object} The currency object, will be undefined if the key isn't registered. */ currencyAPI.getCurrency(key); /** * Returns an array of all registered currency identifiers. * @return {String[]} */ currencyAPI.getAllCurrencies(); /** * Returns the human readable name of the specified currency. * @param {String} key Currency identifier. * @return {String} Human readable name, will be Invalid Currency if the key isn't registered. */ currencyAPI.getCurrencyName(key); /** * Returns whether the specified currency is shared or not. * @param {String} key Currency identifier. * @return {Boolean} */ currencyAPI.getCurrencyIsShared(key); /** * Returns the sync key of the specified currency. Sync key is used with player.setVariable() * @param {String} key Currency identifier. * @return {String} Sync key of the currency, will be null if the key isn't registered. */ currencyAPI.getCurrencySyncKey(key);
Currency API Events
/** * currencyDefined * This event is called when a currency is added to the system with currencyAPI.addCurrency * @param {String} key Currency identifier. * @param {String} name Human readable name of the currency. * @param {Boolean} isShared Whether the currency is shared or not. * @param {String} syncKey If the currency is shared, this string will be used with player.setVariable() to transfer data to clientside. */ currencyAPI.on("currencyDefined", (key, name, isShared, syncKey) => { // Your code here }); /** * walletReplaced * This event is called when a player's wallet object gets replaced by player.setWallet() * @param {Player} player The player who had a wallet change. * @param {Object} oldWallet Old wallet object of the player. * @param {Object} newWallet New wallet object of the player. */ currencyAPI.on("walletReplaced", (player, oldWallet, newWallet) => { // Your code here }); /** * currencyUpdated * This event is called when a player's wallet has a currency change. * @param {Player} player The player who had a currency change. * @param {String} currencyKey Currency identifier. * @param {Number} oldAmount The player's old amount of currency. * @param {Number} newAmount The player's new amount of currency. * @param {String} source Name of the function that triggered this update, will either be "setCurrency" or "changeCurrency". */ currencyAPI.on("currencyUpdated", (player, currencyKey, oldAmount, newAmount, source) => { // Your code here });
Player API
/** * Returns the wallet object of the player. * @return {Object} */ player.getWallet(); /** * Replaces the wallet object of the player with the specified one. * @param {Object} newWallet * @return {Boolean} True if successful, false otherwise. * @fires walletReplaced */ player.setWallet(newWallet); /** * Returns the amount of specified currency the player has in their wallet. * @param {String} currencyKey Currency identifier. * @return {Number} */ player.getCurrency(currencyKey); /** * Sets the amount of specified currency the player has in their wallet. * @param {String} currencyKey Currency identifier. * @param {Number} newAmount New amount of specified currency. * @return {Boolean} True if successful, false otherwise. * @fires currencyUpdated */ player.setCurrency(currencyKey, newAmount); /** * Changes the amount of specified currency the player has in their wallet by specified amount. * @param {String} currencyKey Currency identifier. * @param {Number} amount * @return {Boolean} True if successful, false otherwise. */ player.changeCurrency(currencyKey, amount);
Примеры
Полный тестовый скрипт обновит GTAV money hud, если вы дадите себе «наличную» валюту. (Используется при разработке)
// SERVERSIDE CODE const currencyAPI = require("../currency-api"); // Events currencyAPI.on("currencyDefined", (key, name, isShared, syncKey) => { console.log(`Currency defined, key: ${key} | name: ${name} | isShared: ${isShared ? `yes, sync key: ${syncKey}` : "no"}`); }); currencyAPI.on("walletReplaced", (player, oldWallet, newWallet) => { console.log("=============================="); console.log(`${player.name} had their wallet replaced.`); console.log(`Old wallet currencies: ${Object.keys(oldWallet).join(",")}`); console.log(`New wallet currencies: ${Object.keys(newWallet).join(",")}`); console.log("=============================="); }); currencyAPI.on("currencyUpdated", (player, currencyKey, oldAmount, newAmount, source) => { const diff = newAmount - oldAmount; console.log(`${player.name} ${diff < 0 ? "lost" : "got"} ${Math.abs(diff)} ${currencyAPI.getCurrencyName(currencyKey)} (${currencyKey}). (caused by: ${source})`); }); // Register currencies currencyAPI.addCurrency("cash", "Money", true); // since isShared is true, we can use currency_cash shared variable on clientside currencyAPI.addCurrency("vip_tokens", "VIP Currency", false); // Test commands const fs = require("fs"); const path = require("path"); // Do /savewallet to save your wallet to a JSON file. (file path will be printed to console) mp.events.addCommand("savewallet", (player) => { const saveDir = path.join(__dirname, "wallets"); if (!fs.existsSync(saveDir)) fs.mkdirSync(saveDir); const playerPath = path.join(saveDir, `${player.socialClub}.json`); fs.writeFileSync(playerPath, JSON.stringify(player.getWallet(), null, 2)); player.outputChatBox("Wallet saved."); console.log(`Player ${player.name} saved their wallet. (${playerPath})`); }); // Do /loadwallet to load your wallet from a JSON file. mp.events.addCommand("loadwallet", (player) => { const playerPath = path.join(__dirname, "wallets", `${player.socialClub}.json`); if (fs.existsSync(playerPath)) { player.setWallet(JSON.parse(fs.readFileSync(playerPath))); player.outputChatBox("Wallet loaded."); } else { player.outputChatBox("Wallet file not found."); } }); // Do /mytokens to see your VIP tokens currency amount. mp.events.addCommand("mytokens", (player) => { player.outputChatBox(`Your VIP tokens: ${player.getCurrency("vip_tokens")}`); }); // Do /wallet to list the currencies you have. mp.events.addCommand("wallet", (player) => { const wallet = player.getWallet(); player.outputChatBox("Your wallet:"); for (const [key, value] of Object.entries(wallet)) player.outputChatBox(`${currencyAPI.getCurrencyName(key)}: ${value}`); }); // Do /setcurrency [key] [amount] to set your currency amount. mp.events.addCommand("setcurrency", (player, _, currencyKey, amount) => { amount = Number(amount); if (player.setCurrency(currencyKey, amount)) { player.outputChatBox(`Set ${currencyAPI.getCurrencyName(currencyKey)} (${currencyKey}) to ${amount}.`); } else { player.outputChatBox("Failed to set currency."); } }); // Do /changecurrency [key] [amount] to change your currency amount by specified value. mp.events.addCommand("changecurrency", (player, _, currencyKey, amount) => { amount = Number(amount); if (player.changeCurrency(currencyKey, amount)) { player.outputChatBox(`${currencyAPI.getCurrencyName(currencyKey)} (${currencyKey}) changed by ${amount}.`); } else { player.outputChatBox("Failed to change currency."); } });
// CLIENTSIDE CODE mp.events.addDataHandler("currency_cash", (entity, value) => { if (entity.handle === mp.players.local.handle) { mp.game.stats.statSetInt(mp.game.joaat("SP0_TOTAL_CASH"), value, false); mp.gui.chat.push(`(clientside) currency_cash updated, new value: ${value}`); } });Исходный код доступен на GitHub, если вы не хотите загружать: https://github.com/root-cause/ragemp-currency-api
Спасибо Lorc за предоставление значка ресурса: https://game-icons.net/1x1/lorc/cash.html
Внимание!
Если у вас есть вопросы и вам нужна помощь по серверам, скриптам или моду.
Наша группа ВконтактеНаш Telegram
Наш Discord
Наш Форум

НОВЫЙ REDUX GTA 5 RP (RAGE MP) STEAM EPIC GAMES
Скорость увеличивает на Gta5 rp Да или нет?

[GTA 5] Установка сервера Union RP
nice

[GTA 5] Стрельбище
отлично выглядит, хорошая работа

[GTA 5] Сборка сервера RedAge RP 2.0 (RAGE:MP 1.1)
Не очень сборка

[GTA 5] Открытый интерьер полицейского участка Лос Сантоса
А где он находиться?

[GTA 5] Колёсо фортуны из Казино
Чтоделать если не крутиться, а в консоли пишет INTERACTIONCHECK IS 0

[GTA V] Маппинг на сервере RAGE Multiplayer / Mapping (CodeWalker/dlc)
На 1.1 не актуально

GTA 5: Готовый сервер: Готовая сборка сервера AMP Role Play (AMP-RP / WEST RP)
У кого-нибудь удалось запустить на linux? У меня JS Fatal error: Reinstall the server package.

[GTA 5] Сборка сервера RedAge RP 2.0 (RAGE:MP 1.1)
А тебя не смущает, что это версия 1.1 (bridge.dll - не нужен!). DLC выгружать сюда! server-files\client_packages\game_resources\dlcpacks (Инфо:

Дизайн авторизации и регистрации для сервера GTA 5
this good very
Готовый RPG сервер для Rage:MP от Hurdock (база данных MongoDB).
Слив сборки сервера RedAge 2.0 - RageMP 1.1
Как установить сервер RAGE Multiplayer на Linux(Ubuntu)?
Как подключить базу данных к серверу RAGE Multiplayer?
Как добавить новые машины на сервер?
Как добавить новые скины на сервер?
Как заменить модели оружий на сервере?
Как создавать маркеры? Типы маркеров
Как создавать лейблы?
Как создавать машины? Список машин
Как создавать блипы? Список блипов и цветов
Установка и настройка сервера
Как создавать чекпоинты?
Как установить пакеты node.js для сервера?
Как создавать объекты на сервере?
Как создавать колшейпы?
Как сделать колшейп функционирующим?
Как правильно сделать drawText?
Как сделать уведомления на сервере?
Как выдавать себе оружие? Список оружий