Libraries
59 files
-
ZoneManager
By noBrain
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)267 downloads
- Zones
- client-side
- (and 1 more)
(4 reviews)0 comments
Updated
-
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.1229 downloads
(4 reviews)0 comments
Updated
-
mp.game.data
By rootcause
This resource adds wrappers for these natives:
GET_TATTOO_SHOP_DLC_ITEM_DATA GET_SHOP_PED_COMPONENT GET_SHOP_PED_PROP GET_DLC_WEAPON_DATA GET_DLC_WEAPON_COMPONENT_DATA GET_PED_HEAD_BLEND_DATA GET_WEAPON_HUD_STATS GET_WEAPON_COMPONENT_HUD_STATS GET_DLC_VEHICLE_DATA GET_SHOP_PED_OUTFIT GET_SHOP_PED_OUTFIT_PROP_VARIANT GET_SHOP_PED_OUTFIT_COMPONENT_VARIANT Before 1.1.0, you couldn't use these natives because they needed pointers to their respective structures but since 1.1 allows developers to use ArrayBuffers, that is no longer a problem. Thing is, you still need to create a buffer, invoke the native and read the data from your buffer. (too much work)
This resource is made to prevent that.
Installing
Put gamedata into your server's client_packages directory, then add require('gamedata'); to client_packages/index.js.
Clientside API
This resource extends "mp.game" by adding a "data" object that contains multiple functions.
/* Returns information about a decoration/tattoo. characterType: * 0 = Michael * 1 = Franklin * 2 = Trevor * 3 = MPMale * 4 = MPFemale decorationIndex: * Decoration/tattoo index between 0 and GET_NUM_TATTOO_SHOP_DLC_ITEMS(characterType). Returned object: * { lockHash, id, collection, preset, cost, eFacing, updateGroup, textLabel } This native was researched & documented by TomGrobbe. (https://github.com/TomGrobbe) */ mp.game.data.getTattooShopDlcItemData(characterType, decorationIndex); /* Returns information about a clothing item. componentHash: * Obtained by GET_HASH_NAME_FOR_COMPONENT. Returned object: * { lockHash, uniqueNameHash, locate, drawableIndex, textureIndex, cost, eCompType, eShopEnum, eCharacter, textLabel } */ mp.game.data.getShopPedComponent(componentHash); /* Returns information about a clothing item. (prop) propHash: * Obtained by GET_HASH_NAME_FOR_PROP. Returned object: * { lockHash, uniqueNameHash, locate, propIndex, textureIndex, cost, eAnchorPoint, eShopEnum, eCharacter, textLabel } */ mp.game.data.getShopPedProp(propHash); /* Returns information about a ped's headblend data. entityOrHandle: * Entity (mp.players.local) or handle (mp.players.local.handle) of the ped you want to get headblend data of. Returned object: * { shapeFirstId, shapeSecondId, shapeThirdId, skinFirstId, skinSecondId, skinThirdId, shapeMix, skinMix, thirdMix, isParent } */ mp.game.data.getPedHeadBlendData(entityOrHandle); /* Returns information about a weapon's HUD stats. weaponHash: * Hash of the weapon you want to get HUD stats of. Returned object: * { hudDamage, hudSpeed, hudCapacity, hudAccuracy, hudRange } */ mp.game.data.getWeaponHudStats(weaponHash); /* Returns information about a weapon component's HUD stats. componentHash: * Hash of the weapon component you want to get HUD stats of. Returned object: * { hudDamage, hudSpeed, hudCapacity, hudAccuracy, hudRange } */ mp.game.data.getWeaponComponentHudStats(componentHash); /* Returns information about a DLC weapon. dlcWeaponIndex: * DLC weapon index between 0 - GET_NUM_DLC_WEAPONS(). Returned object: * { lockHash, weaponHash, id, cost, ammoCost, ammoType, defaultClipSize, textLabel, weaponDesc, weaponTT, weaponUppercase } */ mp.game.data.getDlcWeaponData(dlcWeaponIndex); /* Returns information about a DLC weapon's component. dlcWeaponIndex: * DLC weapon index between 0 - GET_NUM_DLC_WEAPONS(). dlcWeaponComponentIndex: * DLC weapon component index between 0 - GET_NUM_DLC_WEAPON_COMPONENTS(dlcWeaponIndex). Returned object: * { attachBone, isDefault, lockHash, componentHash, id, cost, textLabel, componentDesc } */ mp.game.data.getDlcWeaponComponentData(dlcWeaponIndex, dlcWeaponComponentIndex); /* Returns information about a DLC vehicle. dlcVehicleIndex: * DLC vehicle index between 0 - GET_NUM_DLC_VEHICLES(). Returned object: * { lockHash, modelHash, cost } */ mp.game.data.getDlcVehicleData(dlcVehicleIndex); /* Returns information about an outfit. outfitHash: * uniqueNameHash of the outfit. Returned object: * { lockHash, uniqueNameHash, cost, numProps, numComponents, eShopEnum, eCharacter, textLabel } */ mp.game.data.getShopPedOutfit(outfitHash); /* Returns information about an outfit's component. outfitHash: * uniqueNameHash of the outfit. componentIndex: * index of the outfit's component. Returned object: * { uniqueNameHash, enumValue, eCompType } */ mp.game.data.getShopPedOutfitComponentVariant(outfitHash, componentIndex); /* Returns information about an outfit's prop. outfitHash: * uniqueNameHash of the outfit. propIndex: * index of the outfit's prop. Returned object: * { uniqueNameHash, enumValue, eAnchorPoint } */ mp.game.data.getShopPedOutfitPropVariant(outfitHash, propIndex);
Example Script
Writes bunch of information to the console. (which you can access by pressing F11)
mp.keys.bind(0x75, false, () => { // First freemode male tattoo const tattooData = mp.game.data.getTattooShopDlcItemData(3, 0); if (tattooData) { mp.console.logInfo(`Tattoo data: ${JSON.stringify(tattooData)}`); } // Player's top const component = 11; const componentHash = mp.game.invoke("0x0368B3A838070348", mp.players.local.handle, component, mp.players.local.getDrawableVariation(component), mp.players.local.getTextureVariation(component)); const topData = mp.game.data.getShopPedComponent(componentHash); if (topData) { mp.console.logInfo(`Top data: ${JSON.stringify(topData)}`); } // Player's hat const prop = 0; const propHash = mp.game.invoke("0x5D6160275CAEC8DD", mp.players.local.handle, prop, mp.players.local.getPropIndex(prop), mp.players.local.getPropTextureIndex(prop)); const hatData = mp.game.data.getShopPedProp(propHash); if (hatData) { mp.console.logInfo(`Hat data: ${JSON.stringify(hatData)}`); } // Headblend mp.players.local.setHeadBlendData(21, 2, 0, 21, 2, 0, 0.75, 0.5, 0.0, false); const blendData = mp.game.data.getPedHeadBlendData(mp.players.local.handle); if (blendData) { mp.console.logInfo(`Headblend data: ${JSON.stringify(blendData)}`); } // Current weapon HUD stats const weaponData = mp.game.data.getWeaponHudStats(mp.players.local.weapon); if (weaponData) { mp.console.logInfo(`Current weapon HUD stats: ${JSON.stringify(weaponData)}`); } // COMPONENT_AT_MUZZLE_04 HUD stats const componentData = mp.game.data.getWeaponComponentHudStats(mp.game.joaat("COMPONENT_AT_MUZZLE_04")); if (componentData) { mp.console.logInfo(`Component HUD stats: ${JSON.stringify(componentData)}`); } // DLC weapon data const dlcWeaponIndex = 7; const dlcWeaponData = mp.game.data.getDlcWeaponData(dlcWeaponIndex); if (dlcWeaponData) { mp.console.logInfo(`DLC weapon data: ${JSON.stringify(dlcWeaponData)}`); // First component of weapon const dlcWeaponCompData = mp.game.data.getDlcWeaponComponentData(dlcWeaponIndex, 0); if (dlcWeaponCompData) { mp.console.logInfo(`DLC weapon first component data: ${JSON.stringify(dlcWeaponCompData)}`); } } // DLC vehicle data const dlcVehicleIndex = 21; const dlcVehicleData = mp.game.data.getDlcVehicleData(dlcVehicleIndex); if (dlcVehicleData) { mp.console.logInfo(`DLC vehicle data: ${JSON.stringify(dlcVehicleData)}`); } // Outfit data const outfitHash = mp.game.joaat("DLC_MP_SUM24_M_OUTFIT_0"); // Pizza This... Outfit const outfitData = mp.game.data.getShopPedOutfit(outfitHash); if (outfitData) { mp.console.logInfo(`Outfit data: ${JSON.stringify(outfitData)}`); // First component of outfit if (outfitData.numComponents > 0) { const outfitComponentData = mp.game.data.getShopPedOutfitComponentVariant(outfitHash, 0); if (outfitComponentData) { mp.console.logInfo(`First component of outfit: ${JSON.stringify(outfitComponentData)}`); } } // First prop of outfit if (outfitData.numProps > 0) { const outfitPropData = mp.game.data.getShopPedOutfitPropVariant(outfitHash, 0); if (outfitPropData) { mp.console.logInfo(`First prop of outfit: ${JSON.stringify(outfitPropData)}`); } } } });
Notes
If mp.game.invoke fails (trying to get non-DLC item data/invalid params etc.), return value of the function will be null. Most non-DLC items (core GTAV weapons like Pistol, Assault Rifle etc, initial freemode tattoos, initial freemode clothes) are not supported by the natives. Strings returned by the functions (textLabel, componentDesc etc.) are GXT entries. You're supposed to use them with getLabelText or GXT::get.429 downloads
(2 reviews)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
715 downloads
-
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.581 downloads
-
Zone API
By rootcause
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
-
Tire Smoke Color Sync
By rootcause
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
193 downloads
(4 reviews)0 comments
Updated
-
[TypeScript] Client-Framerate library
This TypeScript library allows you to request the current clientside FPS.
Licensed under the MIT License (see README.md for more info).
Sincerely,
~Vincent
Used icon: https://www.shareicon.net/screen-monitor-93177
295 downloads
- typescript
- fps
- (and 2 more)
(1 review)0 comments
Updated
-
Colshape Handler
By nns
Simple CommonJS singleton module to handle colshape entering and exiting.
Copy the Colshapes folder inside packages inside your packages folder. See the Examples folder for an example.
Simply create your colshape like this:
const colshape = mp.colshapes.newSphere(34, 15, 69, 15, 0) colshape.name = 'example' and then pull in the colshapeHandler singleton to add it to the array the following:
const colshapeHandler = require('../Colshapes/index').getInstance() colshapeHandler.addColshape('example') If a player enters the specified colshape, the colshape name will be pushed towards a colshapes array as a player property, like this. Definition of this is inside the "playerJoin" event in the Colshapes\index.js. The specified colshape name will then be removed from the array again if the player exits the colshape.
player.colshapes = [];
83 downloads
(0 reviews)0 comments
Submitted
-
rage-progressbar
By nns
rage-progressbar
Very simple Progress Bar to delay event execution.
How to use:
Put the "progress" folder inside "client_packages" into your "client_packages" folder (or wherever you have your client files).
Import the "progress/index.js" in your main "index.js" like it is done in my main "index.js"
You can then create a Progress Bar on the server-side with the following code:
player.call('progress:start', [SECONDS, TASK, DIRECTION, EVENT, PARAMS]);
SECONDS
How many seconds is the Progress Bar running
TASK
String which is displayed inside the progress bar
DIRECTION
Is the event which is called after the bar has finished a server-side or client-side event
EVENT
The event to be called afterwards
PARMS
Additional params to send to the following event
That's pretty much it. Customize it as you want, this is as basic as possible.
"packages/Progress/index.js" contains an example with an example /progress command and a follow-up event.
315 downloads
(1 review)0 comments
Updated
-
RAGE MP + React
By ynhhoJ
To install all packages, use: yarn install or npm install.
For running this example, use: yarn run start or npm start.
For building project, use: yarn run build or npm run build.
In client_packages is an example of how you can use compiled RAGE MP functions and React.
Credits to Mispon(rage-mp-react-ui) for branch example.
The principal difference between our examples is hot reload and more understandable example of code in my version.
Repo: https://github.com/Corso-Project/RAGE-MP-React-Example
388 downloads
(0 reviews)0 comments
Submitted
-
[C# Server-Side] Events+Commands at Runtime
By robearded
Github page: https://github.com/robertnisipeanu/ragemp-server-events
ragemp-server-events
OOP Implementation of the RAGEMP server events (so you don't have to use [Command] or [ServerEvent] annotations). It allows you to add event handlers and commands at runtime.
How to use
Copy /client_packages/cs_packages/CustomCommands.cs to your server client resources (server-files/client_packages/cs_packages).
From folder 'server' import Delegates.cs and Events.cs into your server-side project.
Add using robearded; at the top of the files where you want to use my API.
Use Events.*EventName* += EventHandler; to add an event handler and Events.AddCommand("*commandName*", CommandHandler); to add a command handler.
Added events
OnPlayerReady(Client client) -> This event is not available by default on the C# API If any other events will be custom implemented they will be added here ^
Example
You can find an example inside the 'example' folder.
Need help?
Please do not contact me if you didn't followed the above steps, I'm not gonna tell you again the steps in private when you have them here.
If you need any other help, feel free to contact me on Discord at @rumble06#4127 or on RAGE.MP Forums at https://rage.mp/profile/45121-robearded/
92 downloads
(2 reviews)0 comments
Updated
-
(0 reviews)
0 comments
Submitted
-
rage_utils
By ShrewdSpirit
A bunch of utility functions for rage (cross environment: server, client, browser) that are not easy to implement in JS specially for client and browser! Also you can use this package for projects other than rage.
If you want a new feature in utilities that you think others might use too, submit an issue on github page
Install instructions, features and documentation are all available on npm registery and github page
I highly recommend visiting the linked pages and using npm/yarn for installing
107 downloads
(1 review)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
1468 downloads
(5 reviews)0 comments
Updated
-
Shared World Data
By rootcause
If you ever used GTA Network's setWorldSyncedData/SetWorldSharedData, you probably have an idea of what this resource does. If you haven't used those, this resource lets you set variables that will be synced to all clients.
Installing
Put the files you downloaded in their respective places Add require('worlddata') to client_packages/index.js, preferably as the first module you require All done
Using
There isn't much to it, you can do one of these to set shared data:
mp.world.data.myDataKey = myValue; mp.world.data["myDataKey"] = myValue; you can do one of these to get shared data:
mp.world.data.myDataKey mp.world.data["myDataKey"] and you can do one of these to remove shared data:
delete mp.world.data.myDataKey; delete mp.world.data["myDataKey"]; (1.1) now you can do this to set multiple shared data at once, thanks to @kemperrr:
mp.world.setData(updatedObject); // see examples You can use setting/deleting code on clientside as well but it won't affect the data on serverside. If anything your changes will get overriden when myDataKey is updated, so there's no point in using setting/deleting code on clientside.
Events (Clientside)
// worldDataReady is called when the player receives all shared data. mp.events.add("worldDataReady", () => { // Example, print all data keys to chat mp.gui.chat.push(`World data ready! ${Object.keys(mp.world.data).join(",")}`); }); // worldDataChanged is called when shared data changes. mp.events.add("worldDataChanged", (key, oldValue, newValue) => { // Example, show which data key changed with its old and new value mp.gui.chat.push(`World data changed: ${key} | old: ${oldValue} | new: ${newValue}`); }); // worldDataRemoved is called when shared data is removed. mp.events.add("worldDataRemoved", (key) => { // Example, show which data key got removed mp.gui.chat.push(`World data removed: ${key}`); });
Example (Serverside)
let gameSeconds = 0; // Increase gameSeconds every second and update the world data every 5 seconds, for no reason... setInterval(() => { gameSeconds++; if (gameSeconds % 5 === 0) { // You can use mp.world.data["exampleVariable"] as well mp.world.data.exampleVariable = gameSeconds; console.log(`exampleVariable is now ${mp.world.data.exampleVariable}`); } }, 1000); // Will update serverUpdated, serverName, serverWebsite shared data. mp.world.setData({ "serverUpdated": Date.now(), "serverName": "RAGE Multiplayer Server #545" "serverWebsite": "https://rage.mp/" }); Source code is available on GitHub in case you don't want to download: https://github.com/root-cause/ragemp-world-data
174 downloads
(3 reviews)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.1255 downloads
-
cefManager
By KifKick
A library to easier manage CEF windows.
Creating a CEF Window
Function is based on Promise because I need this in my own resources. Promise return a CEF window object.
cef window name (string)
url (string)
parameters to exec (array) - take a look on Executing a function into a CEF Window for parameters
cefManager.createCef(cef window name, url, parametersToExec).then(cef => {}) cefManager.createCef('hud', 'package://rage/browsers/hud/index.html').then(cef => {}) Executing a function into a CEF Window
Again function is based on Promise but returns nothing.
cef window name (string)
[function name (string), args how much you need(number, string, boolean etc.)]
cefManager.executeCef(cef window name, [function name, args]).then(() => {}) cefManager.executeCef('hud', ['console.log', mp.players.length]).then(() => {}) Checking if CEF with name exists
cef window name (string)
cefManager.existsCef(cef window name) const exists = cefManager.existsCef('hud') Get CEF window object
cef window name (string)
cefManager.getCef(cef window name) const cef = cefManager.getCef('hud') Get CEF window current URL
cef window name (string)
cefManager.getCurrentCefURL(cef window name) const url = cefManager.getCurrentCefURL('hud') Get CEF window URL which was set in creating CEF window
cef window name (string)
cefManager.getCefURL(cef window name) const url = cefManager.getCefURL('hud') Reload CEF window
Again Promise
cef window name (string)
ignore cache (boolean) - true to ignore cache (Browser::reload)
cefManager.reloadCef(cef window name, ignore cache) cefManager.reloadCef('hud', true).then(() => {})
ps. no support from me for this library, if something works bad fix it.
137 downloads
(0 reviews)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
1416 downloads
- voice chat
- vc
- (and 3 more)
(6 reviews)0 comments
Updated
-
PayCheck - Popup | Only HTML / CSS Design
This is a PayCheck - Popup, 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.
269 downloads
(0 reviews)0 comments
Updated
-
Input Window | Only HTML / CSS Design
This is a Input Window, its only a design. maked with html and css,
you must script it on your server.
there are more windows for more options inside the html
If your Server has more than 100 registered players, than you must make a link with my rage.mp profile on your website.
197 downloads
(0 reviews)0 comments
Updated
-
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.
1721 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.
739 downloads
(3 reviews)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.
842 downloads
(0 reviews)0 comments
Updated
-
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.
1566 downloads
(2 reviews)0 comments
Updated
