ACTION Posted November 26, 2017 Posted November 26, 2017 Hello everyone, I just tested my server and I can not see my friends on the map. There is a type of script currently working so I can solve this.
GTADevLover Posted December 9, 2017 Posted December 9, 2017 (edited) Well, I was just trying to do the same thing, so here's what I just did. Copy this script in a new file and save it in your package with the name of "player_blips.js". //Initialize a object that will hold all blips of every player //We will use IDs to find out who is the owner of a blip var blips = {}; //Icon show in the minimap for the players const BlipIcon = 1; //A simple circle //Color for the icon const BlipColor = 4; //Light gray /* For a list of blip icons and colors just look at: https://wiki.rage.mp/index.php?title=Blips */ //Called when a player spawns mp.events.add('playerSpawn', (player) => { //Create a new blip for that player //using its ID for reference blips[player.id] = mp.blips.new(BlipIcon, player.position); blips[player.id].name = player.name; blips[player.id].dimension = player.dimension; blips[player.id].colour = BlipColor; }); //When a player have a bad luck of dying... mp.events.add('playerDeath', (player, reason, killer) => { //Destroy the blip of that player if it exists if (blips[player.id]) { blips[player.id].destroy(); } }); //When the player leaves the server... mp.events.add('playerQuit', (player, exitType, reason) => { //Destroy his/her blip if it exists if (blips[player.id]) { blips[player.id].destroy(); } }); //Update blip positions based on the positions of the players function UpdateBlipPositions() { //For every player... mp.players.forEach( (player, id) => { //Check if his/her blip exists and if they are alive... if (blips[player.id] && player.health > 0) { //And update the blip position blips[player.id].position = player.position; //Quick note: The 'player.health > 0' was necessary //because if we dont do that the server just crashes. //Looks like we can't get player position if he/she is dead. } }); } //Calls the update function every second setInterval(function(){ UpdateBlipPositions(); }, 1000); Then, in your main script (like index.js) add the following line in the top: require('./player_blips'); I haven't tested it with more than 1 player, but it should work just fine. If anything nasty happens, just PM me. Edited December 9, 2017 by GTADevLover 4
ragempdev Posted December 9, 2017 Posted December 9, 2017 11 hours ago, GTADevLover said: Well, I was just trying to do the same thing, so here's what I just did. Copy this script in a new file and save it in your package with the name of "player_blips.js". //Initialize a object that will hold all blips of every player //We will use IDs to find out who is the owner of a blip var blips = {}; //Icon show in the minimap for the players const BlipIcon = 1; //A simple circle //Color for the icon const BlipColor = 4; //Light gray /* For a list of blip icons and colors just look at: https://wiki.rage.mp/index.php?title=Blips */ //Called when a player spawns mp.events.add('playerSpawn', (player) => { //Create a new blip for that player //using its ID for reference blips[player.id] = mp.blips.new(BlipIcon, player.position); blips[player.id].name = player.name; blips[player.id].dimension = player.dimension; blips[player.id].colour = BlipColor; }); //When a player have a bad luck of dying... mp.events.add('playerDeath', (player, reason, killer) => { //Destroy the blip of that player if it exists if (blips[player.id]) { blips[player.id].destroy(); } }); //When the player leaves the server... mp.events.add('playerQuit', (player, exitType, reason) => { //Destroy his/her blip if it exists if (blips[player.id]) { blips[player.id].destroy(); } }); //Update blip positions based on the positions of the players function UpdateBlipPositions() { //For every player... mp.players.forEach( (player, id) => { //Check if his/her blip exists and if they are alive... if (blips[player.id] && player.health > 0) { //And update the blip position blips[player.id].position = player.position; //Quick note: The 'player.health > 0' was necessary //because if we dont do that the server just crashes. //Looks like we can't get player position if he/she is dead. } }); } //Calls the update function every second setInterval(function(){ UpdateBlipPositions(); }, 1000); Then, in your main script (like index.js) add the following line in the top: require('./player_blips'); I haven't tested it with more than 1 player, but it should work just fine. If anything nasty happens, just PM me. That's nice, but you had to use "player.createBlip" client-side.
ragempdev Posted December 9, 2017 Posted December 9, 2017 1 minute ago, kemperrr said: Well, this will work for players in stream but not for the whole map Then he has to increate stream range.
GTADevLover Posted December 9, 2017 Posted December 9, 2017 I did a simple test with two players in a LAN server, looks like it works:
LaurCzT Posted January 28, 2018 Posted January 28, 2018 On 1/17/2018 at 10:32 PM, aliakyurek said: please give me file just copy the code into a file called player_blips.js and then include the file in your index.js
ThatOneDude Posted February 27, 2018 Posted February 27, 2018 This works as advertised, but sometimes causes the server to crash with "Error: async hook stack has become corrupted (actual: 10, expected: 11)" when players die.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now