Scripts
207 files
-
Weather and Time changing GUI
By KGamer63
With this simple Script you can open an UI that allows you to change the Time and Weather.
Installation:
1. Copy the Files into your server-directory.
2. Add require("./weatherChanger"); to your index.js in the client_packages folder.
Usage:
Press F9 to open the UI.
1387 downloads
-
AnimPlayer
By TurEduard
Hi. To begin with, excuse me for my English.
I share my resource for playing the animation.
You can find animation on request.
I wrote it primarily for myself, do not blame me for nothing. Сan anyone need.
My resource is like Animation Viewer by Hazes but use another base and written in pure js.
How to install:
UnZip the file in server-files. How to use:
Use ~ or /animplayer to browse gui. /animplayer [request] for find animations coinciding with request. /animplayer [dist / dist+name] for find animation with id = dist and type = name. /animflag [up/down/number] increase, decrease, or set the flag for animation Use LEFT/RIGHT arrow keys to cycle through (dist) animations. Use CTRL + LEFT/RIGHT arrow keys to cycle through (dist) 100 animations at once. Use SHIFT + LEFT/RIGHT arrow keys to cycle through (dist) 10 animations at once. Use UP/DOWN arrow keys to cycle (name) animations. Use CTRL + UP/DOWN for increase or decrease flag. Use BACKSPACE to reset the search list. Use SPACE to play animation if you change parameter AnimPlayer.autoPlay in resource GitHub: https://github.com/TurEduard/rage.mp-animplayer
1333 downloads
-
CEF vehSpawner
By Anzo
Installing:
Place the files you downloaded in their locations.
Add "require('.vehSpawner');" to client_packages/index.js.
Controls:
F3 to toggle menu.
Everything else is done in cef interface.
Features:
Spawn any vehicle from https://wiki.rage.mp/index.php?title=Vehicles (2019-05-04).
All players can spawn up to 4 vehicles each.
Vehicles will despawn on server disconnect.
Choose vehicle color via a simple color picker.
Repair the vehicle you are in (2 min timer so you cant spam it).
Players have the ability to despawn (destroy) their vehicles.
Credits:
Josh Pullen for his color picker script at jsfiddle: https://jsfiddle.net/PullJosh/dpkP3/. Without this choosing vehicle colors would not be a feature.
P.S. SS's are in 1440p, side menus will be closer to center in 1080p and the larger vehicle categories will require scrolling.
1309 downloads
(5 reviews)0 comments
Updated
-
Hitmarker
By DevGrab
Use this script to implement hitmarkers to your script. As you can see at the screenshot, the health of the player will pop-up at the position of the player when you hit them.
Use:
Hits.add(amount, position);
Where you want to spawn a hitmark with the number or amount you want.
Enjoy!
1288 downloads
-
Courier
By rootcause
Requirements
You need to download & install these resources first:
NativeUI Efficient Attachment Sync
Currency API (after installing, define a currency named cash)
Installing
Put the files you downloaded in their respective places Set up some businesses and products (read below) All done
Basically
This script adds factories and buyers which sell and buy products, your job is to buy stuff from factories and sell them to buyers for profit.
Commands
/products: Accesses a vehicle's product inventory, you have to be at the back of the vehicle.
/takeproduct: Takes a product from the ground/factory.
/dropproduct: Drops a product from your hands to the ground/buyer.
JSON Files
Most of the changes are done by editing JSON files located in packages/courier/json/.
Remember to validate your changes here: https://jsonlint.com/
config.json
businessWorkInterval: Interval of the business work timer (used for factories to make product and buyers to sell product), default value is 60000.
worldCleanerInterval: Interval of the world cleaner timer (used for removing dropped products), default value is 60000.
droppedProductLife: Milliseconds a dropped product will stay for, default value is 600000.
dropProductOnDeath: If true, dying will cause players to drop the product they're carrying, default value is true.
dropProductOnDisconnect: If true, leaving the server will cause the players to drop the product they're carrying, default value is true.
vehicles.json
This file contains an object that keeps which vehicles are supported by this script in modelName: capacity format. (Vehicles List)
{ "burrito3": 6, // 6 products for burrito3 "rumpo": 6, // 6 products for rumpo "speedo": 4, // 4 products for speedo "youga": 4 // 4 products for youga }
products.json
This file contains the product information in object of objects format. A product has name, model, price, profit, businessTime, attachOffset and attachRotation properties.
name: The product's visible name.
model: Model name of the product, used for dropping and attaching.
price: Price of the product.
profit: Profit rate of the product. Price is multiplied by this value while selling products to a buyer.
businessTime: Milliseconds it takes for a factory to create one of this product/for a buyer to sell one of this product.
attachOffset: Attachment offset of the product model on player.
attachRotation: Attachment rotation of the product model on player.
// Example: Ammunition product "ammo": { "name": "Ammunition", "model": "gr_prop_gr_bulletscrate_01a", "price": 300, "profit": 1.2, "businessTime": 600000, "attachOffset": { "x": 0, "y": -0.18, "z": -0.18 }, "attachRotation": { "x": 0, "y": 0, "z": 0 } }
businesses.json
This file contains business information in array of objects format. A business has type, productType, initialStock, maxStock and position properties.
type: Business type, only factory and buyer are available.
productType: The product this business is interested in, only the values in products.json are available.
initialStock: How much product this business has on server start.
maxStock: Maximum product this business can have.
position: Location of the business.
// Example: Beer Factory & Buyer used in the video [ { "type": "factory", "productType": "beer", "initialStock": 100, "maxStock": 100, "position": { "x": 4.168992519378662, "y": 12.795921325683594, "z": 69.82928466796875 } }, { "type": "buyer", "productType": "beer", "initialStock": 0, "maxStock": 20, "position": { "x": 29.61789321899414, "y": 5.448328018188477, "z": 69.10714721679688 } } ]
businessTypes.json
This file contains business type information in object of objects format. You probably don't need to make any changes to this file, unless you want to add new business types. (which needs some scripting as well)
A business type has label and blipSprite properties.
label: Visible name, used for blip name and label.
blipSprite: Blip sprite of the business type. (Blip Sprite List)
// Example: Default business types { "factory": { "label": "Factory", "blipSprite": 615 }, "buyer": { "label": "Buyer", "blipSprite": 616 } }
Extensions
This script extends mp.Player and mp.Vehicle.
Player Functions
// Returns true if the player is carrying a product. player.isCarryingProduct(); // Returns the type of product the player is carrying, will be null if the player isn't carrying anything. player.getCarryingProduct(); // Makes the player start carrying a product. Type should be a valid product type and the player shouldn't be carrying a product, or it won't work. player.startCarryingProduct(type); // Makes the player stop carrying a product. player.stopCarryingProduct();
Vehicle Functions
IMPORTANT: Vehicles with models that are in vehicles.json automatically get an inventory when entityCreated event is called, so you don't need to use setProductInventory for them. (Unless you want to be 100% sure they have it)
// Sets the product inventory of a vehicle. newInventory must be an array created by the array constructor like "new Array(8)". vehicle.setProductInventory(newInventory); // Returns true if the vehicle has a product inventory. vehicle.hasProductInventory(); // Returns the product inventory of the vehicle, will be null if the vehicle doesn't have one. vehicle.getProductInventory(); // Adds a product to the vehicle product inventory, index must not have an item already and index must be within the bounds of product inventory array. Returns true if successful, false otherwise. vehicle.giveProduct(index, productType); // Returns the product at the specified index of vehicle product inventory, will be null if index doesn't have a product. vehicle.getProduct(index); // Removes the product at the specified index of vehicle product inventory. Returns true if successful, false otherwise. vehicle.removeProduct(index);
Source code is available on GitHub in case you don't want to download: https://github.com/root-cause/ragemp-courier
1266 downloads
-
Login / Register html template
By Tenchuu
https://www.dropbox.com/s/3ump4anqb45mm9x/1uJJ7nb7a9.mp4?dl=0
This is just a template for your login / register system.
1265 downloads
(1 review)0 comments
Submitted
-
GTAO Outfits
By rootcause
This script reads outfits from scriptmetadata.meta and lets you use them in game. There are currently 1382 outfits for both male and female freemode characters.
Using: /outfit [id]
Updating scriptmetadata.meta
scriptmetadata.meta gets more outfits with every update, here's how you can update it:
OpenIV:
Go to update\update.rpf\common\data Right click on scriptmetadata.meta Select save content/export Take the extracted file and replace it with the one your server is using CodeWalker RPF Explorer:
Go to update\update.rpf\common\data Right click on scriptmetadata.meta Select extract raw Take the extracted file and replace it with the one your server is using Notes
Some outfit IDs might do nothing, ask Rockstar In RAGE version 0.3, drawable IDs above 255 aren't supported so you might have some weird looking outfits. From what I heard this is not a problem in upcoming 0.4. Credits to OpenIV and CodeWalker devs, this script wouldn't be possible without their efforts.
1252 downloads
(6 reviews)0 comments
Updated
-
Simple Vehicle Performance Tuner
By Rozi
Hello, I've decided to upload one of my first creations on Rage, it being the CEF-based vehicle performance tuning menu.
You are free to use this to your liking and edit it as long as you leave the credits in.
Download:
https://github.com/Roziiii/ragecarmenu
!!!IMPORTANT!!! The download on here will only be updated when bigger changes occur, but if you want the latest updates you should always download from the github.
CURRENT VERSION ON HERE: 1.0.4
CURRENT GITHUB VERSION: 1.0.4
1251 downloads
-
Synced Vehicle Indicators
By rootcause
Installing
Put the files you downloaded in their respective places Add require('indicators') to client_packages/index.js All done Controls
Numpad 4 - Toggle left indicator Numpad 6 - Toggle right indicator1250 downloads
(4 reviews)0 comments
Updated
-
G button for Passenger
By Kudze
Improved version of already existing passenger script posted by George.
* Upon pressing G button this script searches for the first closest and free seat in the vehicle. If it finds one it makes player to enter into the seat.
1245 downloads
-
[3D] Client-side Sound API.
By Captien
Description:
This resources provides the ability to create/control sound in 3D via custom API. Also demonstrates the ability to use custom urls (Radio streams). 3D sound should be synced automatically without the need of extra work.
Notes:
- This resource represents basic functioning of CEF sounds using very basic 3D implementation
- This resource becomes obsolete when RAGEMP releases 1.1 dp2 which introduces 3D sound API.
- This resource doesn't support local mp3 due to some reason with soundManager2. I'll look into it later...
- This resource doesn't support Frontend sound atm, it's really easy to implement it yourself.
API:
// Client-side // FUNCTIONS mp.game.audio.playSound3D(url, pos, volume, range, dimension) /* * url: string (Required) [Links and local package:// protocol are supported] * pos: vector3 (Required) * volume: int (Optional, Default: 1) [Range: 0 to 1] * range: int (Optional, Default: 60) [Max Range: 60] * dimension: (Optional, Default: 0) * Returns Object. * Object Properties: - id (sound's ID) - url (sound's url) - pos (sound's position) - volume (sound's volume) - range (sound's max range) - dimension (sound's dimension) - listeners (players array that are listening to the sound) - paused (If sound is paused) */ mp.game.audio.setSoundVolume(id, volume); /* * id (Sound's ID) * volume (sound's volume) Range (0.1 - 1) */ mp.game.audio.setSoundPosition(id, pos); /* * Useful for portable sound * id (Sound's ID) * pos (sound's new position) */ mp.game.audio.setSoundRange(id, range); /* * id (Sound's ID) * range (Max Range 60) (Increase it by editing the maxRange...) */ // EVENTS: /* * EventName: audioFinish * params: soundID (Sound's ID that is finished Playing) */ /* * EventName: audioError * params: soundID (Sound's ID that had error), errorObject {code: 'error code', error: 'error description'} */ // Example let sound = mp.game.audio.playSound3D('http://rfcmedia.streamguys1.com/MusicPulse.mp3', pos, 60, 1, 0); sound.destroy(); // Destroys the sound sound.pause(); // Pauses the sound sound.resume(); // Resumes the sound If you have any issues or suggestions, you know the usual routine.
Credits:
- Thanks to George for his 3D voice method.
- Thanks to soundManager 2 for bringing music to life in CEF
I wish you'll enjoy some epic music.
1237 downloads
(7 reviews)0 comments
Updated
-
Electrician Job - Modern, fast, lightweight - JS only
By krane
Hello, this Electrician job was made last night, in an effort to get to understand the more complex and the workflow for RageMP, i find it really interesting and i'm looking for your feedback.
How does it work:
You will get a blip on the map
If you get there, you need to talk to the Electrician guy to hire yourself and get the garage access to spawn vehicles
Once you get in range for the Garage blip, you need to press `E` to spawn the job vehicle and to get missions to go to:
There is implemented an "inaccesible" script, that you can just be around the general entrance area, and you get teleported to the exit and the same for exit:
Once you get inside, you can go to the mission to repair the electric panel:
I do custom work and take script requests, feel free to message me: krane#2890 on discord
1236 downloads
- job
- electrician
- (and 2 more)
(4 reviews)0 comments
Submitted
-
(4 reviews)
0 comments
Submitted
-
Local Voice Chat (C#)
By ragempdev
A C# version of the local voice chat resource:
Note that you need client-side C# access to run it which is not public yet as of 22nd November 2018.
1232 downloads
-
Custom Pause Menu
By Larsalex
🔶 Custom Pause Menu 🔶
Using the game file pausemenu.xml to remove unnecessary/faulty items from the pause menu (esc) in RAGE Multiplayer.
Also fixed the radio volume control 😁
What was changed 🛠
Remote location 🗑
History, statistics, game, network, friends, gallery, store, rockstar editor Deleted sub-items 🗑
Voice chat, notifications, rockstar editor, save and launch Deleted options 🗑
❌ (TODO) Key assignment -> everything related to GTA Online Audio -> everything related to GTA Online & Self Radio Video -> Subs Added items 🛠
Video -> Language Fixed options 🛠
Audio -> Music volume Audio -> Radiostation Requirements ⚙️
RAGE Multiplayer server version 1.1+ Installation 💾
Copy the client_packages folder to the server folder Good guy's ❤️
hromik for the help Despair for playing World Of Tanks README 📒
README (RU)
LICENSES 📝
MIT License
GITHUB 📰
CLICK ME, BOY!
1227 downloads
-
RAGE 0.3.7 - Hitsync / Weaponsync
By DevGrab
This packages includes custom weapon synchronization and damage modification made with an own system. Weapon damage can handled server-side.
Make sure that you remove missing functions from the script, since the script is ripped out of my old source-code.
If you can read the code, it's pretty easy to implement hit indicators since the script already supports a lot of this. (headshot sound, hitmarker, ...)
Enjoy!
1179 downloads
-
(3 reviews)
0 comments
Updated
-
Light Control
By rootcause
This resource adds a light control menu to toggle the state of various lights in GTA V. Use /lcmenu command to access the menu.
Since this is a new feature of RAGEMP, light IDs don't have names/descriptions yet. (Maybe people will document them later, who knows...)
You might also want to check the screenshots for a preview of various light states.
Installing
Download & install the latest NativeUI if you haven't already, this script needs it Drop the lightcontrol folder to your server's client_packages Add require('lightcontrol') to client_packages/index.js All done
Q: "But I still have weird lights/fog around the city buildings?"
See:
1174 downloads
-
Inventory System
By shrox
RAGE Multiplayer Inventory System
A simple inventory system with plenty of features and a neat UI!
*This script does not provide a saving or loading system, that's your doing, there's a 'save' method in the inventory class where you can implement your own saving system depending on what database you're using.
*Comes in typescript & javascript version.
*The keys binded in the clientside script are temporary, you should change them based on your preference.
*Easy to use & implement.
> Will be generally maintained and updated.
Items
Down below is a list of item properties, each property has its own unique use so read it please.
type: ITEM_TYPES; //item type typeCategory: ITEM_TYPE_CATEGORY; //item category see ITEM_TYPE_CATEGORY enum in index.d.ts isPlaced: boolean; //whether item is 'placed' in clothes quality: number; //item quality level image: string; //item image hash: string; //unique item hash, also used as linked to a child item key: string; //item key which contains clothes data only (such as component id, drawable and texture) render: string; //item render image which later on can be used in CDN if you have plenty items. name: string; //item name description: string; //item description count: number; //item count, also determines whether you can split an item up weight: number; //item weight maxStack: number; //max stack determines how many items can be stacked in one slot options: string[]; //item options (to be used when you right click an item) such gender: number | null; //item gender, used on clothes whether the clothe is for female or male modelHash?: string; //prop model name or hash that will be used to create object when dropping item ammoType?: string; //ammo type that a weapon will contain ammoInClip?: number; //ammo in weapon clip amount?: number; //used for armor to contain its amount effect?: { //a feature to be developed whether the item will have an effect or not [key: string]: number; }; components?: Array<number>; //will be used for weapon attachments in future
Class Structure
The Inventory class is the main class for managing player inventories in a game. It extends from other classes such as InventoryClothes, QuickUse, and InventoryItem.
InventoryBase: Base class for inventory management. It initializes the inventory structure and handles basic operations. InventoryItem: Extends InventoryBase and adds methods for managing individual items in the inventory. QuickUse: Extends InventoryItem and adds methods for managing quick-use slots. InventoryClothes: Extends QuickUse and adds methods for managing clothing items in the inventory. This class provides comprehensive functionality for managing player inventories, including adding, removing, equipping, and using items.
Properties
items: Contains the player's inventory items, divided into pockets and clothes. quickUse: Contains items assigned to quick-use slots. weight: Represents the total weight capacity of the inventory. equippedWeapons: Keeps track of equipped weapons. Constructor
Initializes the inventory with player-specific data such as clothes, pockets, and quick-use items. Methods
addItem: Adds an item to the inventory's pockets. addClothingItem: Adds a clothing item to the inventory. removeClothes: Removes a clothing item from the player's character. loadClothes: Loads clothing items onto the player's character. setClothes: Sets clothing items on the player's character. reloadClothes: Reloads clothing items onto the player's character. getFreeSlot: Retrieves a free slot in the inventory pockets. getTotalFreeSlots: Counts the total number of free slots in the inventory. getClothingIndex: Retrieves the index of a specific clothing item type. resetItemData, resetClothingItemData, resetBackpackItemData: Resets item data in the inventory. updateOnScreenPed: Updates the player's character appearance on-screen. getItemModel: Retrieves the model hash of an item type. getItemAndStack, getItemsByHashName, getItemsInCategoryByHashName, getItemsByHashNameEx: Methods for retrieving items by their type or category. getItemByUUID: Retrieves an item by its UUID. hasPistolItem, hasShotgun, hasAssault, hasSMG, hasWeaponInFastSlot: Methods for checking if the inventory contains specific weapon types. getActualWeight, getWeight, getItemsWeight: Methods for calculating the weight of the inventory and its items. checkWeight: Checks if adding a new item will exceed the weight limit. getFreeSlotCount: Retrieves the count of free slots in the inventory. dropItem, splitStack, addPlayerItem, addPlayerItemEx, addMultipleItems, addCountToPlayerItem, manageFastSlots, pickupItem, moveItem, openItem, useItem: Methods for managing inventory actions such as dropping, splitting, adding, and using items. deleteItemStack, deleteItem: Methods for deleting items from the inventory. checkQuickUse: Checks if an item is in a quick-use slot.
Adding new items:
Javscript
-> Navigate to Items.module.js located inside inventory folder, there you can see a list of already added items, and you can follow the path, after adding an item there make sure the item image exists in the frontend, if it doesn't then add it and rebuild the frontend.
Typescript
-> Navigate to Items.module.ts located inside inventory folder, there you can see a list of already added items, and you can follow the path, after adding an item there make sure the item image exists in the frontend, if it doesn't then add it and rebuild the frontend.
Getting Started with Development
Install the required packages by executing `npm install`
If you're on typescript version after installing packages you can execute `npm run watch:server` to watch/build server side and `npm run watch:client` to watch/build client side, if you're on the javascript version, you don't have to do anything.
Getting started with frontend.
In your terminal navigate to the frontend folder (cd frontend)
Run frontend in development mode by executing: `npm run start`
Build the frontend (inventory ui) by executing `npm run build`
After you're done see the gifs below what to do next:
Creating package2 folder:
https://github.com/shr0x/ragemp-inventory-system/raw/main/gifs/create_package2.gif
Building Inventory UI:
https://github.com/shr0x/ragemp-inventory-system/raw/main/gifs/build_frontend.gif
Moving built files to package2:
https://github.com/shr0x/ragemp-inventory-system/raw/main/gifs/move_to_package2.gif
1173 downloads
(1 review)0 comments
Updated
-
Simple MoneyHUD
By MiMIMi
What is this?
This is a simple money HUD for rage It is easy to add and use in your existing application or a new one! It is very similiar to SAMP's money HUD It contains nice animations on money adding/removing (Check the included GIF) How to install?
Extract the MoneyHUD.js file in your client_packages and include it in your index.js require('./MoneyHUD.js'); Note
This was created in version 0.3.7 How to use?
Call event moneyhud:set on player initialization/connect to initialize player's starting money - Example: client.TriggerEvent("moneyhud:set", 5000); Call event moneyhud:add to add money to the HUD - Example: client.TriggerEvent("moneyhud:add", 1500); Call event moneyhud:remove to remove money from the HUD - Example: client.TriggerEvent("moneyhud:remove", 1500); Extra settings
You can change the MINIMUM_LENGTH constant to determine how long should the money HUD be by minimum1165 downloads
(2 reviews)0 comments
Updated
-
Manage Weather Time
By Nov4tO266
Basic script to sync time of the game in custom cicles
That script just change the time of the game based on the configuration cicle time and real life.
every 0 hour and 12 hours the weather is changed in random mod to another weather.
The cicle of Timeout will adjust to read the script every hour in the game.
How to use:
Just place de script in your server-side (Package) and change the "const cicleTime" to your
size of a day cicle. Use real life minutes for that. Exemple: "30" will be 15 minutes in real life day
and 15 minutes night.
Notes:
If you place some value in cicle time that a hour in the game last less then one minute in real life,
dont will work (if you know how to fix comment please ).
Future Updates:
Smoth transition, show time and date on UI
1138 downloads
(1 review)0 comments
Updated
-
Headshots
By rootcause
Small script that adds instantly killing headshots.
Installing
Put headshots into your server's client_packages directory, then add require('headshots'); to client_packages/index.js.
1137 downloads
(6 reviews)0 comments
Submitted
-
[DEPRECATED] Vehicle Indicators
By Captien
Vehicle indicators are the main thing in role-play. Without it you can't role-play while driving or you can cause accidents.
So i did that simple resource to give some help to the community
Keys:
Press X for Warning Lights Press left_arrow for Left indicator Press right_arrow for Right Indicator
Use root's resource for synced indicators
1106 downloads
-
Basic Menu (Discontinued)
By rootcause
This project is discontinued, consider using NativeUI instead.
Bare-bones menu script.
Installing:
Put basicmenu into your server's client_packages directory, then you can add const whatever = require("basicmenu"); to the clientside scripts that you want to add a menu. Example code explains this better.
Properties & Functions:
BasicMenu
title | Get & Set | Title of the menu. (string) x | Get & Set | X position of the menu. (float) y | Get & Set | Y position of the menu. (float) items | Get & Set | An array containing all items of the menu. (MenuItem array) hoverItem | Get & Set | Index of the item you're hovering on with your cursor, -1 if not hovering on anything. (int) visible | Get & Set | Visibility of the menu. (bool) disableESC | Get & Set | Allow/disallow menu from being closed by pressing ESC key. (bool) titleFont | Get & Set | Font ID of the title. (int) titleColor | Get & Set | Text color of the title. (array containing rgba) itemsPerPage | Get & Set | How many items are visible on a page of the menu. (int) currentPage | Get & Set | Current page of the menu. (int) setBanner(lib, banner) | Sets the menu's banner to another texture, setBanner("shopui_title_carmod", "shopui_title_carmod") will set the menu banner to be Los Santos Customs one for example. MenuItem
title | Get & Set | Title of the item. (string) disabled | Get & Set | Whether the item is able to be selected or not. (bool) textColor | Get & Set | Color of the item's title. (array containing rgba) bgColor | Get & Set | Color of the item's background. (array containing rgba) icon | Get & Set | ID of the item's icon. (int) font | Get & Set | Font ID of the title. (int) outline | Get & Set | Outline of the item. (bool) shadow | Get & Set | Shadow of the item. (bool) rightText | Get & Set | Right text of the item. (string) Icon IDs:
You can put icons to menu items (even though there are only 3 options) if you want to. Just do myMenuItem.icon = desired icon ID.
MenuItemIcons.None (0) = No icon
MenuItemIcons.Lock (1) = Lock icon
MenuItemIcons.Tick (2) = Tick/checkmark icon
Events:
There are three events, see example for how to use them.
OnMenuItemSelected(menu, selectedMenuItem, selectedMenuItemIndex) /* Will be called when a menu item is clicked on/selected. menu - The menu that contained the selected item. (BasicMenu) selectedMenuItem - The menu item that was selected. (MenuItem) selectedMenuItemIndex - Index of the menu item on the selected menu. (int) */ OnMenuPageChanged(menu, oldPage, newPage) /* Will be called when a menu's page is changed. menu - The menu that had a page change. (BasicMenu) oldPage - Old page. (int) newPage - New page. (int) */ OnMenuClosed(menu) /* Will be called when a menu is closed. menu - The menu that was closed. (BasicMenu) */ Controls:
Hovering on an item and left clicking - select item
ESC - close menu (if disableESC isn't set to true)
Left Arrow - previous page
Right Arrow - next page
Example Script:
const menuLib = require("basicmenu"); // Creating a menu // you can just do: let exampleMenu = new menuLib.BasicMenu("Test Menu", 0.5, 0.4); let exampleMenu = new menuLib.BasicMenu("Test Menu", 0.5, 0.4, "commonmenu", "interaction_bgd", { itemSelected: function(item, itemIndex) { mp.gui.chat.push(`MenuEvent(${this.title}) - itemSelected: ${item.title} - ${itemIndex}`); }, pageChanged: function(oldPage, newPage) { mp.gui.chat.push(`MenuEvent(${this.title}) - pageChanged: ${oldPage} to ${newPage}`); }, closed: function() { mp.gui.chat.push(`MenuEvent(${this.title}) - close`); } }); exampleMenu.itemsPerPage = 5; // make the menu show 5 items per page, this is default by 10 let normalItem = new menuLib.MenuItem("Normal Item"); normalItem.rightText = "Free"; exampleMenu.items.push(normalItem); let redBackground = new menuLib.MenuItem("Red Background Item", [255, 255, 255, 255], [255, 0, 0, 200]); redBackground.rightText = "~g~$500"; exampleMenu.items.push(redBackground); let greenText = new menuLib.MenuItem("Green Text Item", [0, 255, 0, 255]); exampleMenu.items.push(greenText); // You won't be able to click on disabled items. let disabledItem = new menuLib.MenuItem("Disabled Item"); disabledItem.disabled = true; exampleMenu.items.push(disabledItem); let itemWithIcon = new menuLib.MenuItem("Item with Icon", [255, 255, 255, 255], [0, 0, 0, 200], function() { mp.gui.chat.push("You selected the item with icon, why?"); }); itemWithIcon.icon = menuLib.MenuItemIcons.Tick; itemWithIcon.rightText = "Pretty cool"; exampleMenu.items.push(itemWithIcon); let disabledWithIcon = new menuLib.MenuItem("Top Secret"); disabledWithIcon.disabled = true; disabledWithIcon.icon = menuLib.MenuItemIcons.Lock; exampleMenu.items.push(disabledWithIcon); // You can disable ESC menu closing by using disableESC property. exampleMenu.disableESC = true; // This is important as menus are not visible by default. exampleMenu.visible = true; // Events // OnMenuItemSelected, will be called when a menu item is clicked on. mp.events.add("OnMenuItemSelected", (menu, selectedItem, selectedItemIndex) => { mp.gui.chat.push(`Item selected on menu (${menu.title}) - ${selectedItem.title} (Index: ${selectedItemIndex})`); }); // OnMenuPageChanged, will be called when a menu's current page changes. mp.events.add("OnMenuPageChanged", (menu, oldPage, newPage) => { mp.gui.chat.push(`Menu page changed (${menu.title}) - ${oldPage} to ${newPage}`); }); // OnMenuClosed, will be called when a menu item is closed. mp.events.add("OnMenuClosed", (menu) => { mp.gui.chat.push(`Menu closed (${menu.title})`); }); // F6 key will toggle the visibility of exampleMenu mp.keys.bind(0x75, false, () => { exampleMenu.visible = !exampleMenu.visible; });
1070 downloads
(5 reviews)0 comments
Updated
