Libraries
59 files
-
NativeUI
By GamingMaster
NativeUI for RageMP!
This can only be used Clientside!
Documentation: Click
Github: Click
16380 downloads
-
Efficient Attachment Sync
By ragempdev
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
-
Custom chat
By ynhhoJ
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
0 comments
Updated
-
Inventory API
By rootcause
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
-
Weapon Component Sync
By rootcause
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
-
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
-
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
0 comments
Updated
-
Currency API
By rootcause
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
0 comments
Updated
-
Voice Chat
By Tellarion
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
- voice chat
- vc
- (and 3 more)
0 comments
Updated
-
Weapon Tint Sync
By rootcause
This resource provides serverside weapon tint API for developers and syncs applied weapon tints.
Installing
Put the files you downloaded in their respective places Add require('weapontints') to client_packages/index.js All done
Serverside API
PRO TIP: Check RAGEMP Wiki for tints.
/** * Sets the tint of the player's specified weapon. * @param {Number} weaponHash The weapon hash. * @param {Number} tintIndex The tint index. * @throws {TypeError} If any of the arguments is not a number. */ player.setWeaponTint(weaponHash, tintIndex); /** * Gets the tint of the player's specified weapon. * @param {Number} weaponHash The weapon hash. * @returns {Number} Tint of the specified weapon. * @throws {TypeError} If weaponHash argument is not a number. */ player.getWeaponTint(weaponHash); /** * Returns an object that contains all weapon tints of the player. Key: weapon hash | Value: tint index * @returns {Object} */ player.getAllWeaponTints(); /** * Resets tints of the player's all weapons. */ player.resetAllWeaponTints();
Example Commands
These are the commands I used while testing this script.
// Example: /settint carbinerifle 3 mp.events.addCommand("settint", (player, _, weapon, tint) => { weapon = mp.joaat(`weapon_${weapon}`); tint = Number(tint); player.setWeaponTint(weapon, tint); }); // Example: /gettint carbinerifle mp.events.addCommand("gettint", (player, _, weapon) => { const weaponHash = mp.joaat(`weapon_${weapon}`); player.outputChatBox(`Tint of ${weapon}: ${player.getWeaponTint(weaponHash)}`); }); mp.events.addCommand("resettints", (player) => { player.resetAllWeaponTints(); });
Notes
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.1241 downloads
-
Better Clientside Commands
By rootcause
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
0 comments
Updated
-
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
0 comments
Updated
-
Inventory | Only HTML / CSS Design
This is a Inventory, 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.
840 downloads
0 comments
Updated
-
Custom Sound CEF
By nns
Simple CEF to play custom mp3's in the background. The CEF autodestroys after the sound has finished to not use our beloved PC resources.
Copy client_packages and packages content in their respective directory, then import them.
You can put your mp3's inside client_packages/Sound/sounds/ and trigger them with their filename. Only mp3 is supported right now, although ogg works as well, it's easily exchangeable and/or extensible to allow for both.
As of right now, you can play a sound with the "/playsound NAME" command. You can use this as you want, this is only a barebones example to show how it works.
I have not experimented when it comes to max sound length / filesize. I'd like to know though
760 downloads
-
Native Menu
By Blue Dadjun
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
-
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
0 comments
Updated
-
NativeUI Improved
By Kar
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
-
camerasManager
By kemperrr
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
0 comments
Updated
-
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
0 comments
Updated
-
[C#]RAGE:MP Discord Integration
By Jer
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
-
Login Window | Only HTML / CSS Design
This is a Login window, 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.
598 downloads
0 comments
Updated
-
Synced Time Progression
By Angel
I posted this in the forum, but it is probably better suited here.
This is a very simple script that gives the same time progression experience as single player mode. The source for the time is current GMT time and the calculation rolls this time into an in-game day 24 hour period that lasts 48 minutes (IRL time). Note that as the calculations are based off GMT (and not local time) all clients using this will have the same in game time (dependent on whether their computer's time and timezone is set up correctly).
To use it, simply copy the file somewhere and "require" it in your client_resources script.
There's nothing to configure.
Known Bugs:
Because the date is not recalculated, it continues to reflect the current real world date regardless of how many in game 24 hour periods there are within the game.576 downloads
-
[PHP][Discord] Show Player Count directly in Discord
By Wdoyle
In this file I will get you started on how you can use Discord to show your current player count.
First step is to create an application at:
https://discord.com/developers/applications
Once created click Bot on the left hand side.
Click "Add Bot" and then "Yes, do it!"
Change your Icon to something more pretty
Click "COPY" underneath "Click to reveal token"
Open the file in the ZIP.
Install PHP composer if not already installed.
Run composer require team-reflex/discord-php
Edit the example_rage.php file and change the "Discord Token here" to the token you copied earlier
Change line 17 IP:PORT to your Server IP and Port
When ready run the file with php -q example_rage.php
This script must always be running for it to appear on the Discord member section. Therefore I would recommend running Linux Screen and running the php -q command then detaching the screen to run it in the background.
The script uses the Discord Heartbeat to keep it active within the list. It will also only poll the server after running the heartbeat 5 times which is every 42 seconds.
To set it up with your Discord server you must do the following:
Take the link you were at to setup your bot - it should look like: https://discord.com/developers/applications/IDHERE/bot
Where it says IDHERE - take it and insert it here: https://discord.com/api/oauth2/authorize?client_id=IDHERE&scope=bot&permissions=1
Once this page loads - select your discord server that you are an admin of.
This will authorize your bot to submit to your server.
To make your bot appear at the top of the list, simply create a new permission role called Server
Give it permission to send messages
Set it a nice colour
Drag it to the top of your list
Go to the User that is now in your Member list showing player details and give the role of the server you just created
Have fun!
522 downloads
-
[JS] Clientside Polygons API (Dynamic Colshapes!)
By n0minal
I recently needed a polygons library like this for my gamemode to define some companies, houses, gangzones and other kind of establishments boundaries, so I decided to create this resource previously based on abmn's zone manager, but the code was terrible and I decided to rewrite my own from scratch and improving the functionality.
Basically you'll be able to create any kind of colshape you want, without worring about combining colshapes to fit your needs, you can just define the points and the height of the shape and it'll be created easily!
You can set boundaries for houses to move furnitures, for companies to accomplish the job, for mountains in hunting animals scripts and anything else your creativity takes you, just use it!
Demos
https://streamable.com/w7l4h6
https://youtu.be/OxSPcVQrWrY
Advantages
The main advantages of using this resource instead of abmn's are:
These polygons are dynamic, you can modify, move, rotate, basically do anything to the polygon vertices array in real time and it'll work instantaneously, updating the collisions with players. This script is way more optimized and lightweight than the other version. You can choose the color for the lines of the polygon and set them visible or not by just modifying the polygon `visible` property. This script supports different kind of heights for detecting collision (eg.: slopes), it's accurate (may not work as you think it should depending on the slope degree and the polygon height), and supports even colshapes for mountains. You can add more vertex at any time you want to existing polygons, by just pushing a new vector3 position to `polygon.vertices` array.
API Functions
/* Creates a new polygon and return it's instance */ mp.polygons.add(vertices: Vector3Mp[], height: number, options = { visible: false, lineColorRGBA: [255,255,255,255], dimension: 0 }): Polygon /* Removes a polygon */ mp.polygons.remove(polygon: Polygon): void /* Check if a polygon exists */ mp.polygons.exists(polygon: Polygon): boolean /* Check if a position is contained within a given polygon */ mp.polygons.isPositionWithinPolygon(position: Vector3Mp, polygon: Polygon): boolean /* Examples */ // Creating a new polygon const polygon = mp.polygons.add([new mp.Vector3(10, 10, 5), new mp.Vector3(15, 15, 5), new mp.vector3(5, 5, 5)], 10, { visible: false, lineColorRGBA: [255,255,255,255], dimension: 0 }); // Set the polygon lines visible polygon.visible = true; // Modifying a polygon height polygon.height = 100; // Modifying a polygon color (RGBA) polygon.lineColorRGBA = [255, 155, 0, 255]; // Modifying a polygon dimension polygon.dimension = 30; /* Events*/ // Event called when player enter a polygon (clientside) mp.events.add('playerEnterPolygon', (polygon) => mp.gui.chat.push(`You entered the polygon ${polygon.id}!`)); // Event called when the local player leaves a polygon (clientside) mp.events.add('playerLeavePolygon', (polygon) => mp.gui.chat.push(`You left the polygon ${polygon.id}.`)); How to install
Download the zip folder Extract it on your clientside folder Require the index file from the polygons folder. Enjoy it!
See you on the next release!
- n0minal
509 downloads
0 comments
Updated