Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/19/19 in all areas

  1. 2 points
  2. Version 1.0.0

    277 downloads

    ~~PLEASE LEAVE FEEDBACK ON MULTIPLAYER FUNCTIONALITY~~ Hello! I'm MC, and I developed this blackjack mod from scratch. The goal was to create an interactive blackjack experience with full UI support. If you decide to give it a go, please make sure to leave some feedback as to whether it works properly or not. Thanks! Here's a demo of the mod in action: Features: When a player creates a table, they will automatically be assigned the HOUSE role for that table. The house player has the following UI options: - OPEN TABLE: If the table is currently closed, it will open the table. All tables are open by default. - CLOSE TABLE: The table will close for all players, except for the house player. This is used to prevent players from joining a private game, or a game in progress. It can also be used to temporarily close the table for an extended period of time. - RESHUFFLE: The tables deck is reshuffled, with all players hands being reset and the house having a new hand dealt. This reuses the same number of decks that was originally equipped with the table. - DESTROY TABLE: Destroys the table, deleting all resources associated with it. This will close any open UI for all players currently in the table, and the house player. - LEAVE GAME: This just leaves the table. If the house player leaves the table, the current state of the table is lost. Clicking on any player name will 'hit' the player. Additionally, clicking on a card on the table will flip the card over.Players will only see the house's hand and their own hand. They only have the option to leave the game. That's it! Any future adjustments to this mod will be based purely on the feedback received. Check me out on Twitch if you ever want to catch me occasionally coding RageMP mods live, support future mod development, or if you just want to come say hi: https://www.twitch.tv/mctheboss
    1 point
  3. Hello everyone! In this tutorial I will try to show you how to create a Web map of your server. Stage 0 - Some usefull stuff We need to walk around GTA map, so lets create a resource to make it easier: mp.events.addCommand('veh', (player, veh)=> { mp.vehicles.new(veh, player.position) }) // Create a vehicle mp.events.addCommand('tp', (player, _, x, y, z)=> { player.giveWeapon(0xFBAB5776, 2) // Parachute, you need this, trust me player.position = new mp.Vector3(parseInt(x), parseInt(y), parseInt(z)) }) // Teleport a player mp.events.addCommand('pos', (player)=>{ console.log(player.position.x + ' ' + player.position.y + ' ' + player.position.z) }) // Get player coords at write it to console Stage 1 - Frontend Step 1: Get a map image, you can find some good images here: https://gtaforums.com/topic/595113-high-resolution-maps-satellite-roadmap-atlas/ I will use 4096*4096 satellite map. http://blog.damonpollard.com/wp-content/uploads/2013/09/GTAV_SATELLITE_4096x4096.png Step 2: Create a html file for our map: <img src='http://blog.damonpollard.com/wp-content/uploads/2013/09/GTAV_SATELLITE_4096x4096.png' style="position: absolute"> <canvas id='map' style='height: 4096px; width: 4096px; position: absolute; z-index: 9999'> This code adds a picture and then puts a canvas over it, so we can draw above our map. Step 3: Lets make some calculations 0) First of all, install commands from Stage 0 to your gamemode and then connect to your server. 1) Open your map picture with Paint 2) Determine zero point Teleport to (0, 0, 72) position and determine this location at your map inside paint (put pointer on it), write down coordinates 3) Determine map scale Choose two points at map. I will use the most northen island and LS Aiport Write down 'paint' coordinates for both. It is (1889, 232) (1570, 3939) for me (if you use map with another size, you will get different numbers). Calculate range between this coords, it is 3720.7002 for me. Then go to GTA and walk to both points Write /pos to output your position to console 34.01333999633789 7689.458984375 2.8789443969726562 - northen island -933.9918823242188 -3570.4599609375 14.037487030029297 - airport corner Then calculate distance between this points only with x and y axis. Result: 11301.451622046046 (meters) Now lets finally get map scale: for me it is 11301.451622046046 (meters) / 3720.7 (pixels) = 3.037861303705727 (meters per pixel) 4) Determine axises Red is world coords, green - picture/html coords Step 4: Lets start with a code First of all, we need a function that converts world coordinates to picture coordinates. const ZeroX = 1903 const ZeroY = 2690 const Scale = 3.037861303705727 function getPictureCoords(x, y) { x = x/Scale y = y/Scale return {x: ZeroX + x , y: ZeroY - y} // Invert Y-axis } You can test it by teleporting to random coords and then finding that place in paint Now it's time to start drawing. const ctx = document.getElementById('map').getContext('2d') Lets make a function that draws a player marker (red circle and a name above it) function drawPlayerMarker(x, y, name) { newCoords = getPictureCoords(x, y) x = newCoords.x y = newCoords.y ctx.fillStyle = 'red' ctx.beginPath() ctx.arc(x, y, 5, 0, 2 * Math.PI) ctx.fill() ctx.font = "25px Arial"; ctx.fillText(name, x - 15, y - 15) } Lets test it! It works! Stage 2 - Backend We will use socket.io to communicate between browser and server. Step 0: Install express and socket.io packages. Run windows command line -> change directory to your /server-files directory -> run npm install express npm install socket.io Step 1: Create express app //load map.html and socket.io var fs = require('fs') const port = 3000 var mapHTML = fs.readFileSync("./webmap/map.html", "utf8") var socketIO = fs.readFileSync("./webmap/socket.io.js", "utf8") //create app var app = require('express')(); var http = require('http').Server(app); var io = require('socket.io')(http); //listen 3000 port http.listen(3000, function(){ console.log('webMap is active at 3000 port!'); }); //send map.html and socket.io to every client app.get('/', function (req, res) { res.send(mapHTML); }); app.get('/socket.io.js', function (req, res) { res.send(socketIO); }) Put your map.html file to /server-files/webmap folder Then go to \server-files\node_modules\socket.io-client\dist, find socket.io.js file and put it to server-files/webmap folder Step 2: Prepare and send data to client function prepareAndSendPlayersData() { var toSend = [] mp.players.forEach((player)=> { toSend.push({ x: player.position.x, y: player.position.y, name: player.name }) }) sendPlayersData(toSend) } function sendPlayersData(data) { io.sockets.emit('playersData', data) // Send our data to every client } Step 3: Create interval setInterval(prepareAndSendPlayersData, 200) // Update every 200 ms Stage 3 - Receiving data on client Step 1: Add socket.io script to your html file <script src="/socket.io.js"></script> Step 2: Add variable and event to handle data var playersData = [] var socket = io('localhost:3000') // Your server ip here socket.on('playersData', (data) => { playersData = data redraw() }) Step 3: Redraw map with new data function redraw() { ctx.clearRect(0, 0, 4096, 4096); playersData.forEach((player)=> { drawPlayerMarker(player.x, player.y, player.name) }) Thats all! You can run your server, then open browser and go to youserverip:3000 and test it. map.js (server package) map.html (put it to server-files/webmap folder) This tutorial will be continued Have a good day!
    1 point
  4. Version 1.0.1

    572 downloads

    (EN) This script allow you to play emergency alert sound (2 sounds: tornado siren, alert siren), coming soon: amber alert with sound&pop-up (FR) Ce script vous permet de déclencher des sirènes d'alertes (sirène tornade, sirène d'alerte), à venir: alerte enlèvement avec son&popup ----- HOW TO INSTALL ----- 1) Unpack RAGEMP Alert v0.1 2) Drop the content of "client_packages" folder inside your client folder 3) Drop the content of "packages" folder inside your server folder 4) Add in your server index.js : require('./Alert/sAlert'); 5) Add in your client index.js : require('./Alert/cAlert'); 6) Do not forget to change link of mp.browsers.new in Alert/cAlert.js if needed ----- HOW TO USE ----- /alert tornado {repeat time} --> {repeat time} FROM 1 TO 9 TIMES Duration: EACH time: 9sec (min: 9sec, max: 81sec) /alert siren {repeat time} --> {repeat time} FROM 1 TO 9 Duration: START: 5sec / ACTIVE: 12sec (repeat from 1 to 9) / END: 13sec (min: 30sec, max: 126sec) /alert siren stop --> stop the siren immediatly if activated (duration: 13sec) ----- DEMO ----- Tornado Siren: Alert siren: Amber alert (coming soon):
    1 point
  5. Bevor ich das nächste Update auf Github hochlade möchte ich noch einiges hinzufügen und fixen damit es sich auch wirklich lohnt
    1 point
  6. Version 1.0.0

    1233 downloads

    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
    1 point
×
×
  • Create New...