Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/15/21 in Files

  1. Version 1.0.0

    522 downloads

    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
    1 point
  2. Version 2.0

    1340 downloads

    This script allows developers to run and test their code while in game using their favorite code editor. Preview: https://streamable.com/3fz1ck Features: Executes the code once you save the file Auto destroys the old entities created by hotloader to prevent duplicated entities created and improve rapid developing. Auto destroy old event listeners created by hotloader (`let myEvent = new mp.Event('render', ()=> {})`) , read below. Runs code server-side (hotloader/server/*) Runs code client-side (hotloader/client/*) Note this is not meant to be used in in production. How to use: Drag all the folders into server root (place the packages folder into your server/packages, and the hotloader folder in the server root) in root/hotloader you can do your testing in client.js or server.js or you can create new files in the same directory. You have to save the file to apply the chagnes. Auto entity/event remover is activated only when you declare entities with let/var in the main scope (not in if statements or functions) For events dont use mp.events.add, rather use `let myEvent = new mp.Event('eventName', function)` so hotloader can kill the event listener
    1 point
  3. Version 1.1.4

    104 downloads

    There is a server-side/client-side snippet which helps to registry any commands to Rage API with the simple interface by using decorators. Install via npm/yarn: $ npm i --save rage-decorators // or $ yarn add rage-decorators Docs and examples: https://github.com/READYTOMASSACRE/rage-decorators#readme Install (older version): If you're using typescript, make sure there two options (experimentalDecorators, emitDecoratorMetadata) are true in your tsconfig.json: { "compilerOptions": { "experimentalDecorators": true, "emitDecoratorMetadata": true }, } Interface command decorator /** * Decorator for adding commands to RAGE API * * @param {string | string[]} cmd - command(s) name, which will be added to mp.events.addCommand * @param {string | { group?: string, desc?: string }} params - additional params, add to group or add to description * * Supports templates in the desc param: * @template cmdName - name of command * @template groupName - name of group (if added in the additional params) * * @example desc parameter template: * `Usage: /{{cmdName}} id` * `Usage: /{{groupName}} {{cmdName}} id` * * decorator usage: * command("foo") * command(["bar", "baz"]) * command("foo", "foogroup") * command("bar", { group: "foogroup", desc: "Custom description"}) * */ export const command = (cmd: string | string[], params?: string | { group?: string, desc?: string }): MethodDecorator Interface event decorator /** * Decorator for adding events into RAGE API * * @param {string | string[]} eventName - event(s) name, which will be added to mp.events.add * * @example * decorator usage: * event("playerJoin") * event(["playerDeath", "playerQuit"]) */ export const event = (eventName: string | string[]): MethodDecorator Forum discussion:
    1 point
×
×
  • Create New...