Jump to content

Blips are not deleted


hdrtop

Recommended Posts

Hello, I'm trying to make a Gangwar gamemode and I'm having some problems with Blips. I create blips with a command, that's fine but there's a problem, when I log out and log in again the blip is beign duplicated. I have this code, for when the player enter to the server the blips must be deleted (but not):

function clearBlips() {
    natives.SET_THIS_SCRIPT_CAN_REMOVE_BLIPS_CREATED_BY_ANY_SCRIPT(true)
    let last_blip = natives.GET_FIRST_BLIP_INFO_ID(5)
    while (natives.DOES_BLIP_EXIST(last_blip)) {
        mp.game.ui.removeBlip(last_blip)
        last_blip = natives.GET_NEXT_BLIP_INFO_ID(5)
        mp.gui.chat.push("blip deleted");
    }
	mp.game.wait(50)
}

everytime I login to the server, the message of blip deleted is showed but it's showed as many times as blips I have, but blips don't disappear.

I'm callling this function inside a clientside event from the server:

Quote

player.call("client:clearBlips")

When the player logins. I only get the map empty of blips if I close RageMP and open again (restarting the server doesn't work).

Link to comment
Share on other sites

17 hours ago, MrPancakers said:

You need to show how you're creating the blips too cause then you could possibly be given a better way to be clearing blips.

Hey, I'm using this code

// Serverside (zones.js)

createZone: function(player, name){
	let playerPos = player.position;
	
	let turf = {
		turfName: name
		pos: new mp.Vector3(playerPos.x, playerPos.y, playerPos.z),
		factOwnId: 1,
		color: 37,
		rotation: player.heading
	};
		// I don't know if this is really necessary, all the online players	must see the blip (is this correct?)
	mp.players.forEach((CurrentPlayer) => {			
		CurrentPlayer.call('client:createZoneFromServer', [JSON.stringify(turf)]);
	});
		
}

// Clientside (zones.js)
mp.events.add('client:createZoneFromServer', (obj) => {
	
	obj = JSON.parse(obj);
	let color = obj.color;
	let turfBlip = mp.game.ui.addBlipForRadius(obj.pos.x, obj.pos.y, 1, 50);
	natives.SET_BLIP_SPRITE(turfBlip, 5);
	natives.SET_BLIP_ALPHA(turfBlip, 70);
	natives.SET_BLIP_COLOUR(turfBlip, color);
	natives.SET_BLIP_ROTATION(turfBlip, obj.rotation);
	obj.colShape = mp.colshapes.newSphere(obj.pos.x, obj.pos.y, obj.pos.z, 50, 0);
	
	gangZones.push({blip: turfBlip, idTurf: obj.turfName});
	gangZoneSphere.push({sphere: obj.colShape});
	
});

 

Edited by hdrtop
Link to comment
Share on other sites

I think it's because you have to create blips like so:

 

mp.blips.new(sprite, position,
{
    name: name,
    scale: scale,
    color: color,
    alpha: alpha,
    drawDistance: drawDistance,
    shortRange: shortRange,
    rotation: rotation,
    dimension: dimension,
    radius: radius,
});

Any other way of creating blips will not reset them at re-connect.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...