Jump to content

Libraries

59 files

  1. NativeUI

    NativeUI for RageMP!
    This can only be used Clientside!
    Documentation: Click
    Github: Click

    16380 downloads

       (20 reviews)

    18 comments

    Updated

  2. Inventory API

    This resource provides an inventory API to server developers.
    This resource will not save anything on its own, it just provides you the functions to make your own inventory system using CEF/NativeUI/commands.
     
    Installing
    Put the files you downloaded in their respective places Read the documentation and examples to set up some items etc. All done  
    Features
    Easy to use (hopefully!) Events Custom attributes for items (see examples)  
    Inventory API
    const invAPI = require("../inventory-api"); /** * Adds an item to the inventory system. * @param {string} key Item identifier, such as "item_medkit". * @param {string} name Item name, such as "Medkit". * @param {string} description Item description, such as "Gives you 10 health". * @param {function} [onUse] Optional - Function that gets called when the item is used. * @param {function} [nameFunc] Optional - Function that gets called when getItemName() is used. * @param {function} [descFunc] Optional - Function that gets called when getItemDescription() is used. * @return {object} The added item, will be null if there are any mistakes. * @fires itemDefined */ invAPI.addItem(key, name, description, onUse, nameFunc, descFunc); /** * Returns whether the specified key is a registered or not. * @param {string} key Item identifier, such as "item_medkit". * @return {Boolean} True if registered, false otherwise. */ invAPI.hasItem(key); /** * Returns the specified item. * @param {string} key Item identifier, such as "item_medkit". * @return {object} The item at the specified key, will be undefined if the key isn't registered. */ invAPI.getItem(key); /** * Returns all registered item identifiers. * @return {string[]} An array of registered item identifiers. */ invAPI.getAllItems(); /** * Returns the human readable name of the specified item. * @param {string} key Item identifier, such as "item_medkit". * @param {string} [data] Optional - An object that has item attributes. * @return {string} Human readable item name. */ invAPI.getItemName(key, data); /** * Returns the description of the specified item. * @param {string} key Item identifier, such as "item_medkit". * @param {string} [data] Optional - An object that has item attributes. * @return {string} Item's description. */ invAPI.getItemDescription(key, data);  
    Inventory API Events
    /** * itemDefined * This event is called when an item is added to the system with invAPI.addItem() * @param {string} key Item identifier. * @param {string} name Human readable name of the item. * @param {string} description Description of the item. */ invAPI.on("itemDefined", (key, name, description) => { // Example: console.log(`Item defined, key: ${key} | name: ${name} | description: ${description}`); }); /** * itemAdded * This event is called when a player receives an item. * @param {player} player The player who received the item. * @param {string} key Item identifier. * @param {number} amount Amount the player received. * @param {object} data Item attributes. */ invAPI.on("itemAdded", (player, key, amount, data) => { // Example: console.log(`${player.name} received ${amount}x ${key}.`); }); /** * itemUsed * This event is called when a player uses an item. * @param {player} player The player who used the item. * @param {number} invIdx Index of the item in player's inventory. * @param {string} key Item identifier. * @param {object} data Item attributes. */ invAPI.on("itemUsed", (player, invIdx, key, data) => { // Example: console.log(`${player.name} used ${key}.`); }); /** * itemRemoved * This event is called when an item is removed from a player's inventory. * @param {player} player The player who lost an item. * @param {number} invIdx Index of the item that got removed in player's inventory. * @param {string} key Item identifier. * @param {number} amount Removed item amount. * @param {object} data Item attributes. */ invAPI.on("itemRemoved", (player, invIdx, key, amount, data) => { // Example: console.log(`${player.name} lost ${amount}x ${key}.`); }); /** * itemRemovedCompletely * This event is called when an item is no longer in a player's inventory. * @param {player} player The player who lost an item. * @param {string} key Item identifier. * @param {object} data Item attributes. */ invAPI.on("itemRemovedCompletely", (player, key, data) => { // Example: console.log(`${player.name} no longer has ${key} (${data ? "with data" : "without data"}) in their inventory.`); }); /** * inventoryReplaced * This event is called when a player's inventory array gets changed by player.setInventory() * @param {player} player The player who had an inventory change. * @param {object[]} oldInventory The player's old inventory array. * @param {object[]} newInventory The player's new inventory array. */ invAPI.on("inventoryReplaced", (player, oldInventory, newInventory) => { // Example: console.log(`${player.name} had their inventory replaced. (Old item count: ${oldInventory.length}, new: ${newInventory.length})`); });  
    Player API
    /** * Returns the inventory array of the player. * @return {object[]} An array that holds all items of the player. */ player.getInventory(); /** * Replaces the inventory array of the player with the specified one. * @param {Array} newInventory An array that's going to be the new inventory of the player. * @return {Boolean} True if successful, false otherwise. * @fires inventoryReplaced */ player.setInventory(newInventory); /** * Returns whether the player has the specified item or not. * @param {string} itemKey Item identifier. * @return {Boolean} True if player has the item, false otherwise. */ player.hasItem(itemKey); /** * Same as hasItem but for items with custom attributes. * @param {string} itemKey Item identifier. * @param {object} data An object that has item attributes. * @return {Boolean} True if player has the item, false otherwise. */ player.hasItemWithData(itemKey, data); /** * Gets the item's index in the player's inventory. * @param {string} itemKey Item identifier. * @return {number} Index of the item, -1 if not found. */ player.getItemIndex(itemKey); /** * Same as getItemIndex but for items with custom attributes. * @param {string} itemKey Item identifier. * @param {object} data An object that has item attributes. * @return {number} Index of the item, -1 if not found. */ player.getItemIndexWithData(itemKey, data); /** * Gets how many of the specified item exists in the player's inventory. * @param {string} itemKey Item identifier. * @return {number} Item amount. */ player.getItemAmount(itemKey); /** * Same as getItemAmount but for items with custom attributes. * @param {string} itemKey Item identifier. * @param {object} data An object that has item attributes. * @return {number} Item amount. */ player.getItemAmountWithData(itemKey, data); /** * Gets total amount of items the player has in their inventory. * @return {number} Amount of all items. */ player.getTotalItemAmount(); /** * Gives the specified item to the player. * @param {string} itemKey Item identifier. * @param {number} amount Amount to give. * @param {object} [data] Optional - An object that has item attributes. * @return {Boolean} True if successful, false otherwise. * @fires itemAdded */ player.giveItem(itemKey, amount, data); /** * Uses the item at the specified index of the player's inventory array. * @param {number} itemIdx Index of the item in player's inventory array. * @return {Boolean} True if successful, false otherwise. * @fires itemUsed */ player.useItem(itemIdx); /** * Removes the item at the specified index of the player's inventory array. * @param {number} itemIdx Index of the item in player's inventory array. * @param {number} [amount] Optional - Amount to remove. * @return {Boolean} True if successful, false otherwise. * @fires itemRemoved * @fires itemRemovedCompletely */ player.removeItem(itemIdx, amount);  
    Examples
    Full Test Script (used during development): https://gist.github.com/root-cause/6f15f0ee2276872c2d15a5333fed6a10
    Name/Description Function Test Script: https://gist.github.com/root-cause/500b6e197348e941aeebfa8f883486bb
    Source code is available on GitHub in case you don't want to download: https://github.com/root-cause/ragemp-inventory-api

    2649 downloads

       (11 reviews)

    4 comments

    Updated

  3. Efficient Attachment Sync

    Most of the server developers (ones that don't patiently wait for *something large*, though this resource is powerful enough) use their own server-side object attachments implementation that represents some large JSON with all the object and attachment information. This resource lets you cache "static attachments" in the client-side code so thanks to efficient utilization of the shared data it just uses a small shared variable to do the attachment processing without any need to create server-side objects nor send its data.
     
    For example, if you want to attach a specific object to specific ped bone with spefic bone offset and object rotation, this will only use a ~4-8 byte shared variable keeping it accurate. User-made implementations I have seen before usually take ~100 bytes per an object.
     
    API: Client-side
    mp.attachmentMngr.register(attachmentId, model, bone, offset, rotation) mp.attachmentMngr.addLocal(attachmentId) (synced!) mp.attachmentMngr.removeLocal(attachmentId) (synced!)  
    API: Server-side
    player.addAttachment(attachmentId, remove) player.hasAttachment(attachmentId)  
    Example Resource
    There's an example resource in /client-packages/epic-attachments folder. It lets you toggle attachments (there are like 30 attachments) using a NativeUI-based menu. Thanks to root for his contributions made to the example resource.
     
     
     

    4039 downloads

       (14 reviews)

    7 comments

    Updated

  4. Custom chat

    This is a simple example of using a custom chat in RAGE MP.
    You can set time of hide chat from chat.js:
    hide_chat: 15000 // in milliseconds  

    3649 downloads

       (4 reviews)

    0 comments

    Updated

  5. Improved Commands

    This resource adds a very flexible command handler for serverside JavaScript.
     
    Installing
    Drag and drop the improved-commands folder to your server-files/packages/ folder.
    NOTE: The archive also contains a folder named improved-commands-example, it's an example resource so don't install it along with the library.
     
    Features
    Command aliases Capture command requests (and cancel them if you want to) Somewhat customizable command not found message (like serverside C#) beforeRun property that lets you do final checks before a command actually runs (see example)  
    API
    Instead of extending the global mp object, I've decided to export CommandEvents and CommandRegistry objects. You can access to the library by doing:
    const { CommandEvents, CommandRegistry } = require("../improved-commands");  
    API Properties
    /** * This property is used to toggle the "command not found" message feature. * Default value: false */ CommandRegistry.notFoundMessageEnabled; // get CommandRegistry.notFoundMessageEnabled = bool; // set /** * This property is used to set the "command not found" message. * Default value: "SERVER: Command not found." */ CommandRegistry.notFoundMessage; // get CommandRegistry.notFoundMessage = string; // set  
    API Functions
    /** * Adds a command to the registry. * The command object must contain "name" (string) and "run" (function) properties at the very least. * Optionally, the command object can have "aliases" (array of strings) and "beforeRun" (function, needs to return true for further execution) properties. * Other properties will be collected into an "extra" (object) property, which is useful for storing data on commands. */ CommandRegistry.add(command); /** * Returns all command names, aliases not included. * @return {string[]} */ CommandRegistry.getNames(); /** * Returns all command names with aliases. * @return {string[]} */ CommandRegistry.getNamesWithAliases(); /** * Returns the command object for the specified command name/alias. * @param {string} commandName * @return {Object|undefined} Will be undefined if there is no command with the given name/alias. */ CommandRegistry.find(commandName);  
    Events
    /** * receive * This event is emitted when a player tries to run a command. * @param {mp.Player} player The player who is trying to use the command. * @param {Object} command The command object. * @param {string} fullText All arguments that will be passed to the command, as one string. * @param {string[]} commandArgs All arguments that will be passed to the command. * @param {Object} cancel Whether the execution should be cancelled. Set this object's cancel property to true to stop further processing of the command. */ CommandEvents.on("receive", function (player, command, fullText, commandArgs, cancel) { // your code }); /** * fail * This event is emitted when an error is thrown during command execution. * @param {mp.Player} player The player whose command execution failed. * @param {Object} command The command object. * @param {string} fullText All arguments that were be passed to the command, as one string. * @param {string[]} commandArgs All arguments that were be passed to the command. * @param {Error} error The error that was thrown during command execution. */ CommandEvents.on("fail", function (player, command, fullText, commandArgs, error) { // your code });  
    Example
    const { CommandEvents, CommandRegistry } = require("../improved-commands"); // Should we inform the player when they enter an invalid command? Probably... // Note that commands added with mp.events.addCommand aren't known by this resource so they'll trigger the not found message // This is disabled by default CommandRegistry.notFoundMessageEnabled = true; // Events // Example: Players can't use commands in a vehicle CommandEvents.on("receive", function (player, command, fullText, commandArgs, cancel) { if (player.vehicle) { player.outputChatBox("You cannot use commands in a vehicle."); cancel.cancel = true; } }); // Example: Send a message to the player and print the error to the console on execution failure CommandEvents.on("fail", function (player, command, fullText, commandArgs, error) { player.outputChatBox(`Failed to run command "${command.name}".`); console.error(error.stack || error); }); // Commands // Example: /argtest lorem ipsum dolor sit amet -> results in "You wrote: lorem ipsum dolor sit amet" CommandRegistry.add({ name: "argtest", aliases: ["echo", "combineargs"], beforeRun: function (player, fullText) { if (fullText.length === 0) { player.outputChatBox("No arguments provided."); return false; } return true; }, run: function (player, fullText) { player.outputChatBox(`You wrote: ${fullText}`); } }); // Example: /freemode_male_only -> will only work when player's model is mp_m_freemode_01 CommandRegistry.add({ name: "freemode_male_only", beforeRun: function (player) { return player.model === mp.joaat("mp_m_freemode_01"); }, run: function (player) { player.outputChatBox("Yes, only freemode male can run this command."); } }); // Example: /boom -> will emit "fail" event CommandRegistry.add({ name: "boom", run: function (player) { throw new Error("error thrown"); } }); // Properties that aren't named "name", "aliases", "beforeRun" or "run" will be collected into the "extra" property // Example: /getweapon weapon_carbinerifle 500 -> will only work when player's adminLevel property value is equal to or higher than cmdAdminLevel extra property CommandRegistry.add({ name: "getweapon", aliases: ["giveweapon"], // You can access this property in handlers by using "this.extra.cmdAdminLevel" if the handlers are regular functions (meaning it doesn't work with arrow functions!) cmdAdminLevel: 5, beforeRun: function (player) { return player.adminLevel >= this.extra.cmdAdminLevel; }, run: function (player, fullText, weaponName, ammo = 9999) { // You can do this in beforeRun as well (see argtest example) if (!weaponName || weaponName.length === 0) { player.outputChatBox("Syntax: /getweapon [name]"); return; } player.giveWeapon(mp.joaat(weaponName), Number(ammo)); player.outputChatBox(`Gave yourself ${weaponName} with ${ammo} ammo.`); } }); // Example: Extra property #2 CommandRegistry.add({ name: "count_runs", // You can access this property in handlers by using "this.extra.timesRan" if the handlers are regular functions (meaning it doesn't work with arrow functions!) timesRan: 0, beforeRun: function (player) { player.outputChatBox(`This command was used ${this.extra.timesRan} time(s).`); return true; }, run: function (player) { this.extra.timesRan++; player.outputChatBox(`Now it's used ${this.extra.timesRan} time(s).`); } }); // Example: List all commands CommandRegistry.add({ name: "commands", aliases: ["cmds"], run: function (player) { const commands = CommandRegistry.getNamesWithAliases(); commands.sort(); player.outputChatBox(`Commands: ${commands.join(", ")}`); } }); // Example: Async beforeRun (v1.1 and above) // Important: You should check if player object is still valid by mp.players.exists(player) after awaiting // sleep function can be found here: https://stackoverflow.com/a/39914235 CommandRegistry.add({ name: "async", beforeRun: async function (player) { // Getting data from slow API await sleep(5000); const result = Math.random() < 0.5; if (result) { player.outputChatBox("You're allowed..."); } else { player.outputChatBox("You're not allowed..."); } return result; }, run: async function (player) { // Getting data from slow API again await sleep(2000); if (Math.random() < 0.5) { player.outputChatBox("You waited for nothing!"); } else { throw new Error("Failed so bad it caused an error"); // should emit fail } } });  
    Notes
    This resource does not know about commands added with mp.events.addCommand or C# commands. Meaning if you're using the command not found message feature, addCommand and C# commands will also result in command not found message. Commands are case insensitive. Also on GitHub: https://github.com/root-cause/ragemp-improved-commands

    294 downloads

       (5 reviews)

    1 comment

    Updated

  6. Currency API

    This resource provides a currency API to server developers.
    This resource will not save anything on its own. I'd also recommend you to not have over 2 billion of any currency.
     
    Installing
    Put the files you downloaded in their respective places Check the documentation and examples All done  
    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 {Number} syncType Sharing type of the currency. (0 = not shared with clients, 1 = shared with everyone, 2 = shared with just the wallet owner) * @return {Object} The added currency object. * @fires currencyDefined */ currencyAPI.addCurrency(key, name, syncType); /** * 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 iterator of all registered currency identifiers. * @return {Iterator.<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 the sync type of the specified currency. * @param {String} key Currency identifier. * @return {Number} Sync type of the currency. (0 = not shared with clients, 1 = shared with everyone, 2 = shared with just the wallet owner) */ currencyAPI.getCurrencySyncType(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 {Number} syncType Sharing type of the currency. (0 = not shared with clients, 1 = shared with everyone, 2 = shared with just the wallet owner) * @param {String} syncKey If the currency is shared, this string will be used with player.setVariable() or player.setOwnVariable() to transfer data to clientside. */ currencyAPI.on("currencyDefined", (key, name, syncType, 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);  
    Examples
    Full Test Script, will update GTAV money hud if you give yourself "cash" currency. (Used during development)
    // SERVERSIDE CODE const currencyAPI = require("../currency-api"); const SYNC_TYPE_NONE = 0; const SYNC_TYPE_EVERYONE = 1; const SYNC_TYPE_PLAYER = 2; // Events currencyAPI.on("currencyDefined", (key, name, syncType, syncKey) => { const syncTypes = ["none", "everyone", "player"]; console.log(`Currency defined, key: ${key} | name: ${name} | syncType: ${syncTypes[syncType]} | syncKey: ${syncKey}`); }); 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", SYNC_TYPE_PLAYER); // So that we can use currency_cash shared variable on clientside currencyAPI.addCurrency("vip_tokens", "VIP Currency", SYNC_TYPE_NONE); // 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."); } }); // Do /currencies to get all registered currency identifiers and their names. mp.events.addCommand("currencies", (player) => { for (const key of currencyAPI.getAllCurrencies()) { player.outputChatBox(`${key} - Name: ${currencyAPI.getCurrencyName(key)}`); } }); // 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}`); } }); Source code is available on GitHub in case you don't want to download: https://github.com/root-cause/ragemp-currency-api
    Thanks to Lorc for providing the resource icon: https://game-icons.net/1x1/lorc/cash.html

    1451 downloads

       (5 reviews)

    0 comments

    Updated

  7. Weapon Component Sync

    This resource provides serverside weapon component API for developers and syncs applied weapon components.
     
    Installing
    Put the files you downloaded in their respective places Add require('weaponcomponents') to client_packages/index.js All done  
    Serverside API
    PRO TIP: Check RAGEMP Wiki or my weapon data resource for component names/hashes.
    /** * Adds the specified component to the player's specified weapon. * @param {Number} weaponHash The weapon's hash. * @param {Number} componentHash The component's hash. * @throws {TypeError} If any of the arguments is not a number. */ player.giveWeaponComponent(weaponHash, componentHash); /** * Returns whether the player's specified weapon has the specified component or not. * @param {Number} weaponHash The weapon's hash. * @param {Number} componentHash The component's hash. * @returns {Boolean} * @throws {TypeError} If any of the arguments is not a number. */ player.hasWeaponComponent(weaponHash, componentHash); /** * Returns the components of the player's specified weapon. * @param {Number} weaponHash The weapon's hash. * @returns {Number[]} An array of component hashes. * @throws {TypeError} If weaponHash argument is not a number. */ player.getWeaponComponents(weaponHash); /** * Removes the specified component from the player's specified weapon. * @param {Number} weaponHash The weapon's hash. * @param {Number} componentHash The component's hash. * @throws {TypeError} If any of the arguments is not a number. */ player.removeWeaponComponent(weaponHash, componentHash); /** * Removes all components of the player's specified weapon. * @param {Number} weaponHash The weapon's hash. * @throws {TypeError} If weaponHash argument is not a number. */ player.removeAllWeaponComponents(weaponHash); /** * Resets all components of the player's all weapons. */ player.resetAllWeaponComponents();  
    Example Commands
    1) /prosniper and /loudsniper
    Use /prosniper to get a sniper rifle with components and use /loudsniper to remove the suppressor.
    const sniperHash = mp.joaat("weapon_sniperrifle"); // Will give the player a sniper rifle and components (suppressor, advanced scope and luxury finish) mp.events.addCommand("prosniper", (player) => { player.giveWeapon(sniperHash, 9999); player.giveWeaponComponent(sniperHash, mp.joaat("COMPONENT_AT_AR_SUPP_02")); player.giveWeaponComponent(sniperHash, mp.joaat("COMPONENT_AT_SCOPE_MAX")); player.giveWeaponComponent(sniperHash, mp.joaat("COMPONENT_SNIPERRIFLE_VARMOD_LUXE")); }); // Will remove the suppressor from the player's sniper rifle mp.events.addCommand("loudsniper", (player) => { player.removeWeaponComponent(sniperHash, mp.joaat("COMPONENT_AT_AR_SUPP_02")); });  
    2) Test commands
    These are the commands I used while testing this script. 
    // /weapon is taken from freeroam gamemode mp.events.addCommand('weapon', (player, _, weaponName) => { if (weaponName.trim().length > 0) player.giveWeapon(mp.joaat(`weapon_${weaponName}`), 9999); else player.outputChatBox(`<b>Command syntax:</b> /weapon [weapon_name]`); }); // Example: /addcomp carbinerifle COMPONENT_CARBINERIFLE_CLIP_03 mp.events.addCommand("addcomp", (player, _, weapon, compName) => { player.giveWeaponComponent(mp.joaat("weapon_" + weapon), mp.joaat(compName)); }); // Example: /remcomp carbinerifle COMPONENT_CARBINERIFLE_CLIP_03 mp.events.addCommand("remcomp", (player, _, weapon, compName) => { player.removeWeaponComponent(mp.joaat("weapon_" + weapon), mp.joaat(compName)); }); // Example: /remallcomps carbinerifle mp.events.addCommand("remallcomps", (player, _, weapon) => { player.removeAllWeaponComponents(mp.joaat("weapon_" + weapon)); }); // Example: /resetcomps mp.events.addCommand("resetcomps", (player) => { player.resetAllWeaponComponents(); });  
    Notes
    Thanks to @ragempdev and @Jaimuzu for their contributions and help during the tests. If there are any reproducible bugs, feel free to report them. This resource will be obsolete after 0.4's weapon attachment/customization API arrives. JS was a mistake.

    1820 downloads

       (6 reviews)

    1 comment

    Updated

  8. Voice Chat

    Hi, my realization voice chat on cef in the RAGE:MP
    Voice working by distance position (noice control), activation F8 (push and talk)
    Installing
    1. Read all .js comments and put code in your gamemode
    2. Prepare security Web Server and start peer js server, generate crt files and put with server in one folder
    3. Change all urls my web project on yours
    For peerjs server, use next package install: npm install fs peer
    P.s, i dont know would be new version that scripts, but if you want himself update and i can upload its here
    Date Build: 22 feb 2018

    1415 downloads

       (6 reviews)

    0 comments

    Updated

  9. NativeUI Improved

    Improvements over the previous nativeui:
    Added `UIMenuDynamicListItem`. Descriptions are no longer cut off at 99 characters, but now support 99 * 3. `UIMenuListItem` and `UIMenuSliderItem` can now store extra data. Improved description line wrapping. Description caption is now only updated when necessary. Description background is now only updated (recalculated) when necessary. Bettered the position of the left arrow for list items. Added new badges (Sale, Arrows and Voice Icons). Added `Menu.RemoveItem(item: UIMenuItem)`. When binding an item to a menu, automatically add that item if it isn't in the menu items list already. Added `MenuOpen` event when `menu.Visible` is changed. When hovering over the currently selected ListItem's title text, the cursor will be MiddleFinger, just like in the original menus. `GoLeft` and `GoRight` now correctly handles disabled items. Added experimental automated menu pool system (It's a bit effy right now). MENUS ARE NO LONGER SHOWN BY DEFAULT. Added `closeChildren: boolean = false` parameter to `menu.Close()`. An optional parameter specifiing whether or not you want to close all children with the menu. NOTE BRIEFLY:
    The description and optimization updates for me saved over 20-30 FPS while a menu is open. You might want to be careful with menu pools right now. I haven't went deep into it but for simple menu pools it works GREAT. `MenuClose` event is NOT emitted when Visible is set to false. This is to allow users to reopen menus at it's same state, for e.g searching through a store. The GitHub will not match the file here. So please download the file from GitHub (dist/index.ts) or compile it yourself.  
    https://github.com/karscopsandrobbers/RAGEMP-NativeUI

    701 downloads

       (6 reviews)

    3 comments

    Updated

  10. [C#]RAGE:MP Discord Integration

    RAGEMP-DiscordIntegration
    This wrapper allows you easily create an instance of a discord bot within your RAGE:MP server.
    Features:
    1. Send messages to discord from your RAGE:MP Server.
    2. Send messages to your RAGE:MP Server from your Discord server.
    3. Register specific channel for the bot to listen. (Can be changed during runtime).
    3. Remove specific channel for the bot to STOP listening. (Can be changed during runtime).
    4. Update bot status on setup and/or during runtime
     
    How to use the wrapper
    1. Add the RAGEMP-DiscordIntegration.dll as a reference to your project in visual studio.
    2. Make sure to place the three provided Discord.Net.xx.dll into your server/runtime folder.
    3. Enjoy))))
    How to set up
    1. Create a new application on Discord Developers
    2. Create a bot.
    3. Invite bot to discord server.
    4. Use the token from your bot to initialize the bot as shown in the example below.
    5. Register/Remove channels from where your bot sends to all players.
    Example script.
    using GTANetworkAPI; using System; using System.Collections.Generic; using System.Text; public class Yes : Script { public Yes() { NAPI.Util.ConsoleOutput("Loaded: yes"); } [ServerEvent(Event.ResourceStart)] public void OnResourceStart() { Integration.DiscordIntegration.SetUpBotInstance("TOKEN_HERE", "RAGE:MP", Discord.ActivityType.Playing, Discord.UserStatus.DoNotDisturb); } [ServerEvent(Event.ChatMessage)] public async void OnChatMessage(Player player, string strMessage) { string strFormatted = $"[RAGE:MP] {player.Name}: {strMessage}"; await Integration.DiscordIntegration.SendMessage(3897429387492374, strFormatted, true).ConfigureAwait(true); } [Command("registerchannel")] public void RegisterDiscord(Player player, ulong discordChannelID) { bool bSuccess = Integration.DiscordIntegration.RegisterChannelForListenting(discordChannelID); player.SendChatMessage(bSuccess ? "Success" : "No Success"); } [Command("removechannel")] public void RemoveDiscordChannel(Player player, ulong discordChannelID) { bool bSuccess = Integration.DiscordIntegration.RemoveChannelFromListening(discordChannelID); player.SendChatMessage(bSuccess ? "Success" : "No Success"); } [Command("botstatus")] public async void UpdateBotStatusCommand(Player player, string gameName, Discord.ActivityType eActivityType, Discord.UserStatus eUserStatus) { await Integration.DiscordIntegration.UpdateBotStatus(gameName, eActivityType, eUserStatus).ConfigureAwait(true); } } Source code can be found on my github: https://github.com/JeremyEspresso/RAGEMP-DiscordIntegration

    Bugs or feature requests and what not. Just open an issue on the github and I will take a look soon™️.

    613 downloads

       (11 reviews)

    1 comment

    Updated

  11. ZoneManager

    RageMP-ZoneManager
    A very useful client-side system which let you create four squares or hexagons in any shape like colshapes which support Z axis
    GIT REPO
    Why i needed something like this
    I was creating a traffic system which needed me to be able to check if a guy entered any crossroads and colshapes wasn't the thing i wanted + i wanted to sell farms by their shape and some of them wasn't shaped exaclty foursquare and i needed a little more, so i craeted this script to be able to make those things possible easily.
    Features
    You can create 4 types of zone which are defined az mp.zones.types in the script. You can loop through your zones and remove them. You can register zones by desired name. You may delete any zone any time. Server-side events also included. It supports Z axis which is still not very clever since it's not a big deal, all i needed was to prevent people to trigger some events from above the ground Have 4 testing functions which let you draw your zone on the map to see how it fits You can now register zones by any vector pointes above 2 Functions (Client-Side)
    /* Check if a zone is registered by it's name and it's dimension */ mp.zones.isZoneRegistered(zoneName, dimension) /* Unregister a zone by it's name and dimension */ mp.zones.unRegisterZone(zoneName, dimension) /* Register a zone by a list of vectors, height , zoneName, type, dimension Vectors: an arrayList of vectors depending on the type of the zone you are choosing to create for example if you are creating a 2PointZone all you need is 2 Vectors inside an array which are the starting point and the ending point and you have to pass height as -1 since it's not used in that type of zone if you are creating a 4PointZone you need to have an arrayList of vectors with 4 Vectors inside and height is used this time, same as 4PointZone in 6PointZone you need to pass 6 vectors and the height. Returns ZoneObject (contains name, type, positions, and zone.data [which never used it my self]) */ mp.zones.registerZone(Vectors, height, zoneName, type, dimension) /* Get ZoneObject by it's name and dimension */ mp.zones.getZoneByName(zoneName, dimension) /* Draw a 2PointZone for testing Requires 2 vectors */ mp.zones.drawZoneBy2(startPosition, endPosition) /* Draw a 4PointZone for testing Requires 4 vectors and height */ mp.zones.drawZoneBy4(Vectors, height) /* Draw a 6PointZone for testing Requires 6 vectors and height */ mp.zones.drawZoneBy6(Vectors, height) /* Draw a NPointZone for testing Requires array of vectors and height Unlimited number of points supported by this code */ mp.zones.drawZoneByN(Vectors, height) /* Check whether a point on the map is inside the zone or not */ mp.zones.isPointInZone(point, zoneName, dimension) /* This is a list of registered zone names used for looping through zones */ mp.zones.registered Events (Server-Side/Client-Side)
    On client side the player parameter is mostly the local player it self.
    /* mp.events.add('ZoneManager_PlayerEnterZone', (player, zoneName) => { //Your Code }) mp.events.add('ZoneManager_PlayerExitZone', (player, zoneName) => { //Your Code }) */ Changelog
    4/1/2020 - v0.0.1 - Added support for dimension - Addes support for NPointZone type which let you create zones by any number of points - Changed some functions to support dimensions, if you already used the script you may need to change them - getZoneByName now returns undefined if the zone on the dimension does not exists (this thing existed before but i forgot to mention it before)

    265 downloads

       (4 reviews)

    0 comments

    Updated

  12. Native Menu

    Here is an open-source native menu implementation for Rage-MP. (the documentation is not ready)
    https://github.com/BlueDadjun/Native-Menu-RageMP

    744 downloads

       (2 reviews)

    2 comments

    Updated

  13. Tire Smoke Color Sync

    This resource provides 3 serverside functions to work with tire smoke color feature of GTA V.
     
    Installing
    Put the files you downloaded in their respective places Add require('tiresmoke') to client_packages/index.js All done  
    Serverside API
    /** * Sets the tire smoke color of a vehicle. * @param {Number} red * @param {Number} green * @param {Number} blue */ vehicle.setTyreSmokeColor(red, green, blue); /** * Gets the tire smoke color of a vehicle. * @return {Object} Tire smoke color, will be null if the vehicle doesn't have one set. */ vehicle.getTyreSmokeColor(); /** * Resets the tire smoke color of a vehicle. */ vehicle.resetTyreSmokeColor();  
    Example Code
    // Example: /setsmokecol 255 0 0 mp.events.addCommand("setsmokecol", (player, _, r, g, b) => { if (!player.vehicle) { player.outputChatBox("not in vehicle"); return; } player.vehicle.setTyreSmokeColor(Number(r), Number(g), Number(b)); player.outputChatBox("smoke color set"); }); // Output: "smoke color: {"r":255,"g":0,"b":0}" or "smoke color: null" if you haven't used setsmokecol before mp.events.addCommand("getsmokecol", (player) => { if (!player.vehicle) { player.outputChatBox("not in vehicle"); return; } player.outputChatBox(`smoke color: ${JSON.stringify(player.vehicle.getTyreSmokeColor())}`); }); mp.events.addCommand("remsmokecol", (player) => { if (!player.vehicle) { player.outputChatBox("not in vehicle"); return; } player.vehicle.resetTyreSmokeColor(); player.outputChatBox("smoke color reset"); });  
    Notes
    Since this script toggles the tire smoke mod (toggleMod 20), it may not work with your car customization script. Setting the tire smoke color of a vehicle, then changing its model will cause visual desync. Apply tire smoke color again/reset it after changing a vehicle's model to not have this issue. Even though NativeDB says setting the RGB to 0, 0, 0 applies independence day tire smoke, all it did for me was make the tire smoke invisible. Future versions of RAGEMP might add tire smoke color sync, if it happens you should stop using this resource.  
    Source code is available on GitHub in case you don't want to download: https://github.com/root-cause/ragemp-tire-smoke

    190 downloads

       (4 reviews)

    0 comments

    Updated

  14. [C++] L5RP Framework

    I wish to share this framework for ragempcppsdk, that L5RP team has created while we were developing for ragemp. Using C++ for serverside
    This framework worth both on Windows and on Linux operating systems. (Haven't tested it on mac OS).
    This framework contains some additional util features which are not present in cppsdk by default:
    Callable system for parsing command/event/console input/socket input arguments. Script system, which helps developers to split the code into seperate scripts. Some utilities such as Player and Vehicle components to fully utilize script system. Threaded CURL support (Could be used to call api calls in website to load/save server data) Threaded TCP Socket support (Could be used to integrate server with 3rd party applications such as discord bot, live players map and a lot more) (Currently only works on linux) Has been designed with an possibility in mind that rage-mp could die and scripts code could be lifted to other modifications. (Of course integration layer would be needed to be developed, but the thing is that once that would be developed scripts code wouldn't need to change at all) Command and Event system. (Currently its done in a bit weird way, where each player has his own set of commands. But Its not really good time for me to go and refactor one of the core parts of the framework) A lot of small utilites that makes developer's life easier whilst developing on cppsdk. Some bugfixes which are not present in ragemp. Timer/Promise support. (Promise is the same thing as a timer, but only executes once) Threaded Console Input/Output. Console Output being done through spdlog, having different severity levels and being logged into file. Ideas for the future:
    Example gamemode utilizing functions from this framework. Support for multi-language scripts. Some kind of documentation for this framework. In order to download/review this framework please use git: https://gitlab.com/l5rp/l5rp-api
    If you have any suggestions or improvements for this framework feel free to contact me in ragemp discord or in comment section. I'll also be reviewing pull request section from time to time.

    450 downloads

       (3 reviews)

    0 comments

    Updated

  15. UI | Only HTML / CSS Design

    This is a UI for food, drink, money... its only a design. maked with html and css,
    you must script it on your server.
     
    If your Server has more than 100 registered players, than you must make a link with my rage.mp profile on your website.

    1716 downloads

       (0 reviews)

    2 comments

    Updated

  16. Playerinteraction Menu | Only HTML / CSS Design

    This is a Playerinteraction Menu its only a design. maked with html and css,
    you must script it on your server.
     
    If your Server has more than 100 registered players, than you must make a link with my rage.mp profile on your website.

    1559 downloads

       (2 reviews)

    0 comments

    Updated

  17. RageMP-BigData

    RageMP-BigData
    This plugin was created for experiment and might not be what you are looking for, this is intended to be used for sending big data to clients in chunks to make the size unlimited for the server owners, this will eliminate original rage-mp events limit and will be as fast as them when being used for small data, but i suggest that you use original ones just in case.
    This is still experimental and the way it works might change in a future update

    GITHUB LINK : https://github.com/safra36/RageMP-BigData
    API
    for obvious reasons i made this only to go from server-side to client-side and not client-side to server-side, there is a commented code about this and with a bit of knowlegde you can get it to work but it's not recommended since it will basically flood your server if you have many players so stay of it!
    Server-Side Functions
    /** Send a big data to a player @param player valid muliplayer player object @param eventName the event which is defined on client-side (just a normal event name) @param DataArray It's an array of data like how player.call works, and it supports all types of data (objects, numbers, strings with no effect on the typing!) @callback dataReceived Optional callback triggers when the data is received in full by the client @param retry Optional param which is true by default, pass false to disable auto retry (this will cause the data to be lost, added by request but don't use it!) */ player.callBig(eventName, DataArray, dataReceived, &retry) /** Send a big data to all players @param eventName the event which is defined on client-side (just a normal event name) @param DataArray It's an array of data like how player.call works, and it supports all types of data (objects, numbers, strings with no effect on the typing! */ mp.players.callBig(eventName, DataArray) /** Set a big shared variable on players @param name name of the data @param data any type of data @callback dataReceived Optinal callback triggers when the data is received in full by the client @param retry Optional param which is true by default, pass false to disable auto retry (this will cause the data to be lost, added by request but don't use it!) */ player.setBigVariable(name, data, dataReceived, &retry) /** Get a previously set shared data on the client @param name name of the data */ player.getBigVariable(name) /** Set a big private data on client which is only set on a certain client, access it on server-side with player.privateData[dataName] You can use player.pdata.name instead from 0.0.3 @param name name of the data @param data any type of data @callback dataReceived Optinal callback triggers when the data is received in full by the client @param retry Optional param which is true by default, pass false to disable auto retry (this will cause the data to be lost, added by request but don't use it!) */ player.setPrivateData(name, data, dataReceived, &retry) /** Delete private data on server-side and client-side @param name name of the data */ player.deletePrivateData(name) Server-Side Variables
    /** * Setter * Sets private data on client like setPrivateData but without optional retry * Use with try catch, it can only be set if there is no other pending data on the target name (throw error if there is a pending data) */ player.pdata.dataName = value /** * Getter * Get private data which was set, must be used with await since the data may take time to reach client; */ var data = await player.pdata.dataName; Server-Side Events
    /** Detemine if a data has been fully received by the client @param player playerObject which has sent this signal @param id Id of the data sending session @param eventName Name of the even you have been called on the client previously using callBig */ mp.events.add('DataSender:End', (player, id, eventName) => {}) /** This will be called when the sent data was failed (there is an auto retry to put the data on player for sure but see this as a notification) @param id Id of the data sending session @param dataName Name of the data you have been set on the client @param errorCode -1 Means the data could not be parsed on client, -2 means there was some data chunks lost on the send proccess */ mp.events.add('DataSender:Failed', (id, dataName, errorCode) => {}) Client-Side Functions
    /** Get a shared variable of a player @param name data name that was set on the player */ player.getBigVariable(name) Client-Side Variables
    You can get client private data using mp.players.local.privateData[dataName] Client-Side Events
    /** Get notified when a shared data get's updated on server-side @param dataName shared data name @param entityId id of the entity which this it's shared data has been updated (currently it's only a player) @param type get type of entity which is updated (player, object, vehicle, ped but currenly it's only player) @param oldData previously set data if it's forst time then it's undefined @param newData the latest data has been set on this name */ mp.events.addBigDataHandler(dataName, (entityId, type, oldData, newData) => {}) /** Get notified when a shared data get's updated on server-side @param dataName private data name @param oldData previously set data if it's forst time then it's undefined @param newData the latest data has been set on this name */ mp.events.addPrivateDataHandler(dataName, (oldData, newData) => {}) Example (BigData Event Sample)
    Server-Side
    // Big data is an array of rage-mp cloths (something around 15MB of data) and other ones are regular data (can be big data as well) player.callBig('GetBigData', [BigData, 'Some Other Test Arguments', 3]); Client-Side
    mp.events.add('GetBigData', (BigJSONData, args1, argg2) => { mp.gui.chat.push(`Data: ${BigJSONData['Tops']['Male']['NONE'][0].name} - Type: ${typeof(BigJSONData)}`); mp.gui.chat.push(`Data: ${args1} - Type: ${typeof(args1)}`); mp.gui.chat.push(`Data: ${argg2} - Type: ${typeof(argg2)}`); }) Results

    Benchmark
    Well, the time it takes to transfer the data really depends on player network speed, data chunk size and the size of the data it self. For testing, i sent a very big json file contaning all rage-mp clothing with their torsos and names and prices (which i use on server-side my self), the file is something around 15MB, it took something about ~3s to transfer the whole data to the client, this is a beta version of the library but any help is accepted for optimizations.
    Installation
    Copy all the files to your packages/client-packages Make sure to add the client-side file to your index.js Enjoy! Known Issues
    If your data fails and you set a new data which does not fail, the old data is probably gonna replace the new data over retry  

    104 downloads

       (2 reviews)

    4 comments

    Updated

  18. MC-RP Object Editor

    This is a public release of the object editor used on the Mafia City Roleplay server. 
    Usage client-side: 
    let obj = mp.objects.new(mp.game.joaat(model), new mp.Vector3(position.x, position.y, position.z)); mp.events.call('objecteditor:start', obj.id); mp.events.add('objecteditor:finish', (objId, pos, rot) => { if(obj.id == objId) { // send pos and rot to server and save or do whatever. return; } });  
    Github Link: https://github.com/Ahmad45123/ragemp-objecteditor

    391 downloads

       (2 reviews)

    6 comments

    Updated

  19. Zone API

    This resource adds 3 functions to the serverside mp.world object that provides zone name and type information.
     
    Serverside API
    /** * Returns the name of the area/zone at specified coords, ignores heights. * @param {object} coords An object with "x" and "y" properties. * @return {string} Zone name. */ mp.world.getNameOfZone2D(coords); /** * Returns the name of the area/zone at specified coords. * @param {object} coords An object with "x", "y" and "z" properties, such as mp.Vector3. * @return {string} Zone name. */ mp.world.getNameOfZone3D(coords); /** * Returns the type of the area/zone at specified coords. * @param {object} coords An object with "x" and "y" properties. * @return {string} Zone type, either "city" or "countryside". */ mp.world.getTypeOfZone(coords);  
    Example
    const coords = new mp.Vector3(1823.961, 4708.14, 42.4991); // Grapeseed Bunker console.log(`Name 2D: ${mp.world.getNameOfZone2D(coords)}`); // Expected output: Grapeseed console.log(`Name 3D: ${mp.world.getNameOfZone3D(coords)}`); // Expected output: Grapeseed console.log(`Zone Type: ${mp.world.getTypeOfZone(coords)}`); // Expected output: countryside  
    Notes
    Available on GitHub: https://github.com/root-cause/ragemp-zone-api N.O.O.S.E area returns Tataviam Mountains instead. There might be other areas with inaccuracies, feel free to share a fix in comments/send a pull request.

    94 downloads

       (3 reviews)

    0 comments

    Updated

  20. Speedometer | Only HTML / CSS Design

    This is a Speedometer, its only a design. maked with html and css,
    you must script it on your server.
     
    If your Server has more than 100 registered players, than you must make a link with my rage.mp profile on your website.

    732 downloads

       (3 reviews)

    0 comments

    Updated

  21. camerasManager

    This is a tool for using cameras.
    ONLY CLIENTSIDE;
    Using: 
    const camerasManager = require('./camerasManager.js'); //creating camera /** @param {String} - camera name @param {String} - type camera @param {Vector3} - position @param {Vector3} - rotation @param {Number} - fov */ const kemperrr_camera = camerasManager.createCamera('kemperrr_the_best?', 'default', new mp.Vector3(0, 0, 100), new mp.Vector3(), 50); //destroy camera /** @param {Camera} - destroyed camera */ camerasManager.destroyCamera(kemperrr_camera); //get camera by name /** @param {String} camera name */ const kemperrr_camera = camerasManager.getCamera('kemperrr_the_best?'); //activate camera /** @param {Camera} - camera to activate @param {Boolean} - toggle */ camerasManager.setActiveCamera(kemperrr_camera, true); //deactivate camera /** @param {Camera} - camera to activate @param {Boolean} - toggle */ camerasManager.setActiveCamera(kemperrr_camera, false); //activate with interpolation /** @param {Camera} - camera to activate @param {Vector3} - where the camera will fly @param {Vector3} - New camera rotation @param {Number} - The time for which the camera will fly by @param {Number} - hz @param {Number} - hz */ camerasManager.setActiveCameraWithInterp(kemperrr_camera, new mp.Vector3(100, 200, 100), new mp.Vector3(0, 0, 90), 5000, 0, 0); //get gameplay camera const gameplayCamera = camerasManager.gameplayCam; mp.game.notify(JSON.stringify(gameplayCamera.getDirection())); //get current active camera const activeCamera = camerasManager.activeCamera; mp.game.notify(JSON.stringify(activeCamera.getCoord())); //events //an event is triggered when any camera starts interpolating camerasManager.on('startInterp', (camera) => { mp.game.notify(JSON.stringify(camera.getCoord())); }); //the event is triggered when any camera has completed interpolation camerasManager.on('stopInterp', (camera) => { mp.game.notify(JSON.stringify(camera.getCoord())); });

    680 downloads

       (1 review)

    0 comments

    Updated

  22. Attachment Sync (C#)

    Source code : https://github.com/J4YT/RAGE-Multiplayer-Attachment-Sync

    C# Attachment sync for RAGE Multiplayer Server and Client. 
    Equivalent for the Efficient Attachment System made by ragempdev and rootcause
    https://rage.mp/files/file/144-efficient-attachment-sync
    Credits to DasNiels for the server-side Efficient Attachment Sync C#
    https://github.com/DasNiels/EfficientAttachmentSyncCSharp
    It has only been tested on RAGE Multiplayer 1.1
     

    475 downloads

       (3 reviews)

    1 comment

    Updated

  23. Simple ATM | Only HTML / CSS Design

    This is a ATM Menu, its only a design. maked with html and css,
    you must script it on your server.
     
    If your Server has more than 100 registered players, than you must make a link with my rage.mp profile on your website.

    642 downloads

       (4 reviews)

    0 comments

    Updated

  24. Death Screen with Loading | Only HTML / CSS Design

    This is a Death-Screen Loading-Screen, its only a design. maked with html and css,
    you must script it on your server.
     
    If your Server has more than 100 registered players, than you must make a link with my rage.mp profile on your website.

    854 downloads

       (2 reviews)

    0 comments

    Updated

  25. Better Clientside Commands

    This resource extends clientside mp.events object to make clientside command handling easier, which means no more splitting strings to use with if/else if or switch/case in playerCommand event
     
    Installing
    Put mp-commands into your server's client_packages directory, then add require('mp-commands'); to client_packages/index.js.
     
    Clientside API
    /** * Adds a clientside command. * @param {string} name Name of the command. * @param {function} handlerFn Function that will run when the command is used. * @throws {TypeError} name argument must be a string. * @throws {TypeError} handlerFn argument must be a function. * @throws {Error} Command with the given name already exists. */ mp.events.addCommand(name, handlerFn); /** * Returns clientside command names. * @return {string[]} */ mp.events.getCommandNames(); /** * Removes a clientside command. * @param {string} name Name of the command to remove. * @return {boolean} */ mp.events.removeCommand(name); /** * Removes all clientside commands. */ mp.events.removeAllCommands(); /** * (v2.0.0) Adds a console command. * @param {string} name Name of the console command. * @param {function} handlerFn Function that will run when the console command is used. * @throws {TypeError} name argument must be a string. * @throws {TypeError} handlerFn argument must be a function. * @throws {Error} Console command with the given name already exists. */ mp.console.addCommand(name, handlerFn); /** * (v2.0.0) Returns console command names. * @return {string[]} */ mp.console.getCommandNames(); /** * (v2.0.0) Removes a console command. * @param {string} name Name of the console command to remove. * @return {boolean} */ mp.console.removeCommand(name); /** * (v2.0.0) Removes all console commands. */ mp.console.removeAllCommands();  
    Example
    /* Looks like it's serverside code but it's not, updates GTA V's cash display. Usage: /updmoney [amount] */ mp.events.addCommand("updmoney", function (amount) { amount = Number(amount); if (!Number.isInteger(amount)) { mp.gui.chat.push("Invalid amount."); return; } mp.game.stats.statSetInt(mp.game.joaat("SP0_TOTAL_CASH"), amount, false); }); mp.events.addCommand("cmds", function () { mp.gui.chat.push(`Commands: ${mp.events.getCommandNames().join(", ")}`); });  
    Example (Console)
    NOTE: Console is a RAGE Multiplayer 1.1 feature, which means code below won't work on stable/prerelease/0.3.7 branch.
    // Write "hat 123 0" to the console and press enter to give yourself a cool helmet. mp.console.addCommand("hat", function (drawable, texture = 0) { drawable = Number(drawable); texture = Number(texture); if (!Number.isInteger(drawable) || !Number.isInteger(texture)) { mp.console.logError("Invalid drawable/texture."); return; } if (drawable < 0) { mp.players.local.clearProp(0); } else { mp.players.local.setPropIndex(0, drawable, texture, true); } }); // Write "cmds" to the console to see available console commands. mp.console.addCommand("cmds", function() { mp.console.logInfo(`Console commands: ${mp.console.getCommandNames().join(", ")}`); });  
    Notes
    I recommend loading mp-commands as the first script in client_packages/index.js so the functions become available in other scripts. Command names are case sensitive.

    1194 downloads

       (4 reviews)

    0 comments

    Updated


×
×
  • Create New...