Jump to content

Libraries

59 files

  1. 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)

    267 downloads

       (4 reviews)

    0 comments

    Updated

  2. 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  

    3691 downloads

       (5 reviews)

    0 comments

    Updated

  3. DavWebCreator

    DavWebCreator
    DavWebCreator is a C# class 'library' which provides you the possibility to generate HTML structures with according styles and logic behind each element.
    There are already plenty of examples online here: https://DavWebCreator.com
    But anyway I will provide you here at least one example 🙂
    Compatible with 1.1.0.0
     
    If you want to report a bug or just want some help join my discord: https://discord.gg/JYNDrSh
     
    Preview

     
    Code behind:
    [Command("yesno")] public void YesNoDialogExample(Client player) { // Generate the Browser Browser browser = new Browser("YesNoDialog", BrowserType.Custom, BrowserContentAlign.Center, "520px", "100%"); // Create the dialog. (Most of the elements will get a default value) var yesNoDialog = browser.GetYesNoDialog("YES_NO_EXAMPLE", "Character Deletion", "WARNING", "Do you really want to delete your character?", "Yes", "No"); // Customize for example the font size and the margin. yesNoDialog.Card.ContentTitle.FontSize = "30px"; yesNoDialog.Card.Margin = "33% 0 0 0"; // Add to the browser browser.AddYesNoDialog(yesNoDialog); // Finally open the browser for the desire player. browser.OpenBrowser(player); } //This event will be called when a button was clicked. [RemoteEvent("YES_NO_EXAMPLE")] public void YesNoExample(Client player, params object[] args) { if (args == null) return; // This is just a list of reponses. (You can bind for example 3 textboxes to a button and when someone click on that button, all 3 binded textboxes will be in the response, with their hidden values. List<BrowserEventResponse> responses = JsonConvert.DeserializeObject<List<BrowserEventResponse>>(args[0].ToString()); // For some reason we know that a YesNoDialog only gives you one response, because only the clicked button will be returned. BrowserEventResponse buttonResponse = responses[0]; player.SendChatMessage(buttonResponse.Value + " Clicked"); player.SendChatMessage(buttonResponse.HiddenValue + " This is our secret hidden value. e.g. some id"); // Close the browser player.TriggerEvent("CLOSE_BROWSER"); // Do stuff }  
    Installation
    Download the .rar Open the "DavWebCreator_Installation.rar" and open the directory called "DavWebCreator_GetStarted". Open the directory "Server Resources" and Copy and paste the directory "DavWebCreator" in to your"Visual Studio" server project. Go back to the directory called "DavWebCreator_GetStarted". Now open the directory "Client Resources" and Copy and paste the directory "DavWebCreator" in to your "Visual Studio" client project. Your solution should now look like this.

          6. Go back to the directory called"DavWebCreator_GetStarted".
          7. Now open the directory "Client Frontend" and copy and paste the directory "DavWebCreator" in to your RageMp "client_packages" directory.
     
    This is how it should look now:

    Done. Lets start with some examples…
    The project stays under the MIT license, feel free to contribute: https://github.com/davidowiz/DavWebBrowser 🙂
    Maybe the installation procedure will be improved. But as you all now, time is limited.
    Best regards,
    Davidowiz

    229 downloads

       (3 reviews)

    0 comments

    Updated

  4. Texture Variation Sync

    Requires RAGE Multiplayer 1.1.0 and above.
    This resource adds 2 new functions to mp.Object that provides texture variation sync.
    If you don't know the purpose of prop texture variations, you should check out GTA Online's stunt maps/props and yacht styles.
     
    Installing
    Put the files you downloaded in their respective places Add require('texturevariation') to client_packages/index.js All done  
    Serverside API
    /** * Sets the texture variation of the object. * @param {number} textureVariation Texture variation index. */ object.setTextureVariation(textureVariation); /** * Returns the texture variation of the object. * @return {number} */ object.getTextureVariation();  
    Example
    This snippet was used during development:
    const gamerChair = mp.objects.new("gr_prop_highendchair_gr_01a", new mp.Vector3(-425.517, 1123.620, 325.8544)); gamerChair.setTextureVariation(1); mp.events.addCommand("chaircol", (player, colorIndex) => { colorIndex = Number(colorIndex); if (!Number.isInteger(colorIndex)) { player.outputChatBox("Usage: /chaircol [color index]"); return; } gamerChair.setTextureVariation(colorIndex); }); mp.events.addCommand("spawntube", (player, colorIndex) => { colorIndex = Number(colorIndex); if (!Number.isInteger(colorIndex)) { player.outputChatBox("Usage: /spawntube [color index]"); return; } const tube = mp.objects.new("bkr_prop_biker_tube_xxs", player.position); tube.setTextureVariation(colorIndex); });  

    130 downloads

       (3 reviews)

    0 comments

    Submitted

  5. Popup Window | Only HTML / CSS Design

    This is a Popup 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.

    199 downloads

       (1 review)

    0 comments

    Updated

  6. 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.

    644 downloads

       (4 reviews)

    0 comments

    Updated

  7. 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.

    857 downloads

       (2 reviews)

    0 comments

    Updated

  8. 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

  9. 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

  10. 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

  11. 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

  12. Fake Pickups

    Requires RAGE Multiplayer 1.1.0 and above.
    This resource adds the ability to create classic GTA style pickups we all love.
     
    Installing
    Put the files you downloaded in their respective places Add require('fake-pickups') to client_packages/index.js All done  
    Serverside API
    Global mp object extension:
    // Properties /* Returns the amount of existing pickups. */ mp.fakePickups.length; // Functions /* Creates a pickup. * model - Model name or hash, such as prop_armour_pickup. * position - Position of the pickup, recommended: mp.Vector3 instance * pickupRange - Collection range of the pickup. * respawnTime - Respawn time of the pickup after collection, values less than 1 will disable respawning of the pickup. * dimension - Dimension of the pickup. */ mp.fakePickups.new(model, position, pickupRange, respawnTime, dimension = 0); /* Returns the pickup instance with specified ID. */ mp.fakePickups.at(id); /* Returns whether a pickup with specified ID exists. */ mp.fakePickups.exists(id); /* Returns an array of existing pickups. */ mp.fakePickups.toArray();  
    FakePickup class:
    // Properties /* ID of the pickup, read only. */ instance.id; /* Model hash of the pickup, read only. */ instance.model; /* Position of the pickup, read only. */ instance.position; /* Collection range of the pickup, read only. */ instance.pickupRange; /* Respawn time of the pickup, can be changed. */ instance.respawnTime; /* Light data of the pickup, read only. */ instance.lightData; /* Whether the pickup is collected, read only. */ instance.isCollected; /* Dimension of the pickup, can be changed. */ instance.dimension; // Functions /* Allows you to set light data of the pickup, argument names should be obvious. If you want to remove the pickup's light, use resetLightData instead of this function with weird values. */ instance.setLightData(red, green, blue, range, intensity, shadow); /* Resets light data of the pickup. */ instance.resetLightData(); /* Respawns the pickup. (if collected) */ instance.respawn(); /* Destroys the pickup. */ instance.destroy();  
    Events:
    /* fakePickupSpawn is called when a pickup's prop is created. (Basically when it's created and respawned) */ mp.events.add("fakePickupSpawn", (pickup) => { // code here }); /* playerCollectFakePickup is called when a player collects a pickup. This event is cancelable. (Check example script) */ mp.events.add("playerCollectFakePickup", (player, pickup, cancel) => { // code here });  
    Example Script
    // setLightData calls are optional and you don't have to use them, just makes the pickups stand out at night time. const moneyPickup = mp.fakePickups.new("ex_prop_exec_cashpile", new mp.Vector3(1571.681, 3163.909, 40.331), 1.0, 5000); moneyPickup.setLightData(114, 204, 114, 2.0, 2.5, 15.0); const healthPickup = mp.fakePickups.new("prop_ld_health_pack", new mp.Vector3(1568.648, 3166.397, 40.331), 1.0, 5000); healthPickup.setLightData(53, 154, 71, 2.0, 2.5, 15.0); const armorPickup = mp.fakePickups.new("prop_armour_pickup", new mp.Vector3(1567.359, 3169.639, 40.331), 1.0, 5000); armorPickup.setLightData(93, 182, 229, 2.0, 2.5, 15.0); const weaponPickup = mp.fakePickups.new("w_mg_combatmg", new mp.Vector3(1569.465, 3172.773, 40.331), 1.0, 5000); weaponPickup.setLightData(255, 133, 85, 2.0, 2.5, 15.0); // You're better off using custom properties with your pickup instance, this code is for testing purposes. mp.events.add("playerCollectFakePickup", (player, pickup, cancel) => { if (pickup === moneyPickup) { player.outputChatBox("You picked up some money."); } else if (pickup === healthPickup) { if (player.health >= 75) { player.outputChatBox("You're just fine, no need to waste a health pack."); // Doing cancel.cancel = true; prevents the pickup from being marked as collected. cancel.cancel = true; return; } player.health = 100; player.outputChatBox("Health refilled."); } else if (pickup === armorPickup) { if (player.armour > 0) { player.outputChatBox("You already have armor."); // Doing cancel.cancel = true; prevents the pickup from being marked as collected. cancel.cancel = true; return; } player.armour = 100; player.outputChatBox("You picked up some armor."); } else if (pickup === weaponPickup) { player.giveWeapon(mp.joaat("weapon_combatmg"), 9999); player.outputChatBox("You picked up Combat MG."); } }); mp.events.add("fakePickupSpawn", (pickup) => { switch (pickup.model) { case mp.joaat("ex_prop_exec_cashpile"): mp.players.broadcast("The money pickup has respawned."); break; case mp.joaat("prop_ld_health_pack"): mp.players.broadcast("The health pickup has respawned."); break; case mp.joaat("prop_armour_pickup"): mp.players.broadcast("The body armor pickup has respawned."); break; case mp.joaat("w_mg_combatmg"): mp.players.broadcast("The Combat MG pickup has respawned."); break; } });  
    Source code is available on GitHub in case you don't want to download: https://github.com/root-cause/ragemp-fake-pickups

    243 downloads

       (6 reviews)

    0 comments

    Updated

  13. 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

  14. 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

    1416 downloads

       (6 reviews)

    0 comments

    Updated

  15. Glowing Players

    Requires RAGE Multiplayer 1.1.0 and above.
    This resource allows you to apply a glowing effect to players.
     
    Installing
    Put the files you downloaded in their respective places Add require('playerglow') to client_packages/index.js All done  
    API (Serverside)
    /** * Sets the glow color of a player. * @param {Number} red * @param {Number} green * @param {Number} blue */ player.setGlowColor(red, green, blue); /** * Gets the glow color of a player. * @return {Object} Glow color, will be null if the player doesn't have one. */ player.getGlowColor(); /** * Disables the glowing effect of a player. */ player.resetGlowColor();  
    Example
    mp.events.addCommand("setglow", (player, _, red, green, blue) => { player.setGlowColor(Number(red), Number(green), Number(blue)); }); mp.events.addCommand("getglow", (player) => { player.outputChatBox(`Current glow color: ${JSON.stringify(player.getGlowColor())}`); }); mp.events.addCommand("resetglow", (player) => { player.resetGlowColor(); });  
    Notes
    The effect is not really noticeable during daytime. If you have glowing players in your stream range and reconnect via F1 menu, their particle effect(s) will stay there until GTAV is restarted. This is because of particle handles being lost during reconnection and since they aren't managed by RAGEMP, they won't get removed.  
    Source code is available on GitHub in case you don't want to download: https://github.com/root-cause/ragemp-player-glow

    161 downloads

       (5 reviews)

    0 comments

    Submitted

  16. [JS] Clientside Polygons API (Dynamic Colshapes!)

    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

    522 downloads

       (5 reviews)

    0 comments

    Updated

  17. [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.

    453 downloads

       (3 reviews)

    0 comments

    Updated

  18. cefManager

    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

  19. GTA V: Web Fonts

    Here is the .woff version of the fonts of GTA 5 i could find on their website.

    224 downloads

       (1 review)

    0 comments

    Updated

  20. Shared World Data

    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

  21. 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

    1468 downloads

       (5 reviews)

    0 comments

    Updated

  22. rage_utils

    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

  23. Maze Bank UI with CSS

    A free Maze Bank UI. Have fun
     

    436 downloads

       (0 reviews)

    0 comments

    Submitted

  24. [C# Server-Side] Events+Commands at Runtime

    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

  25. RAGE MP + React

    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


×
×
  • Create New...