Jump to content

How to remove blip?


Recommended Posts

Salute dear programmers. How to remove the blip icon on the map? I indicated in the code the creation of an icon by coordinates and ID, but how can I do this deleting an icon by coordinates that I also indicated in the code? help, I beg you.

Spoiler

local blip = createBlip ( -715.8314, 2328.1269, 44.1525, 41, 2, 255, 0, 0, 255, 0, 1000 )
	setTimer(function()
	addCommandHandler ( "blip", 
    function ( thePlayer ) 
        for index, element in ipairs ( getAttachedElements ( thePlayer ) ) do 
            if ( getElementType ( element ) == "blip" ) then 
                destroyElement ( element ) 
            end 
        end 
    end 
) 
	end, 5000, 0)
end

function finish()
how to do it here --> removeBlip ( -715.8314, 2328.1269, 44.1525, 41, 2, 255, 0, 0, 255, 0, 0 )
end

 

 

Link to post
local theBlip = createBlip(0, 0, 4, 2, 255, 255, 255, 255)

function removeBlip(posX, posY, posZ)
   for _,blip in ipairs(getElementsByType("blip")) do
      local x,y,z = getElementPosition(blip)
      if(posX == x and posY == y and posZ == z) then
         destroyElement(blip)
      end
   end
end

removeBlip(0, 0, 4)

 

  • Thanks 1
Link to post
On 08/06/2021 at 15:59, Burak5312 said:

local theBlip = createBlip(0, 0, 4, 2, 255, 255, 255, 255)

function removeBlip(posX, posY, posZ)
   for _,blip in ipairs(getElementsByType("blip")) do
      local x,y,z = getElementPosition(blip)
      if(posX == x and posY == y and posZ == z) then
         destroyElement(blip)
      end
   end
end

removeBlip(0, 0, 4)

 

And how to do this in the work resource, here in the goo window I will click to start work how to make the mark disappear?

Link to post
On 09/06/2021 at 17:29, saluta said:

And how to do this in the work resource, here in the goo window I will click to start work how to make the mark disappear?

I don't understand. Do you want to create a panel for this function?

Edited by Burak5312
Link to post
2 hours ago, Burak5312 said:

Я не понимаю. Вы хотите создать панель для этой функции?

No, I have a quest system and a miner's work, in general, a quest appears there a mark appears that I have already done a person reaches the mark clicks start work and the mark must disappear exactly 41 id blip radar_waypoint icons. How to implement and do it.

Link to post
function removeBlip(posX, posY, posZ)
   for _,blip in ipairs(getElementsByType("blip")) do
      local x,y,z = getElementPosition(blip)
      if(posX == x and posY == y and posZ == z) then
         destroyElement(blip)
      end
   end
end

local blip = createBlip (-715.8314, 2328.1269, 44.1525, 41, 2, 255, 0, 0, 255, 0, 1000)

	setTimer(function()
	addCommandHandler ( "blip", 
    function ( thePlayer ) 
        for index, element in ipairs ( getAttachedElements ( thePlayer ) ) do 
            if ( getElementType ( element ) == "blip" ) then 
                destroyElement ( element ) 
            end 
        end 
    end 
) 
	end, 5000, 0)
end

function finish()
   removeBlip (-715.8314, 2328.1269, 44.1525)
end

maybe something like this?

Edited by Burak5312
Link to post

The problem is that getElementPosition returns exact coordinates (in this case X coordinate is "-715.83142089844").
And you are comparing it with "-715.8314".

To make it work you will have to round the coordinates.
You can either use the useful function math.round or do it like this:

local theBlip = createBlip(-715.8314, 2328.1269, 44.1525, 41, 2, 255, 0, 0, 255, 0, 1000)

function removeBlip(posX, posY, posZ)
	for _,blip in ipairs(getElementsByType("blip")) do
		local x,y,z = getElementPosition(blip)
		if(math.ceil(posX) == math.ceil(x) and math.ceil(posY) == math.ceil(y) and math.ceil(posZ) == math.ceil(z)) then
			destroyElement(blip)
		end
	end
end

addCommandHandler("blip", function () -- the cmd way is for an example
	removeBlip(-715.8314, 2328.1269, 44.1525)
end)

*Changed @Burak5312's code a bit.
Note that this way it won't be very accurate but if you don't plan to have close blips it should not cause any problems.
Otherwise use the math.round function I mentioned above and specify how many digits to have after the decimal point.

Edited by SpecT
  • Thanks 1
Link to post

 

16 minutes ago, SpecT said:

The problem is that getElementPosition returns exact coordinates (in this case X coordinate is "-715.83142089844").
And you are comparing it with "-715.8314".

To make it work you will have to round the coordinates.
You can either use the useful function math.round or do it like this:


local theBlip = createBlip(-715.8314, 2328.1269, 44.1525, 41, 2, 255, 0, 0, 255, 0, 1000)

function removeBlip(posX, posY, posZ)
	for _,blip in ipairs(getElementsByType("blip")) do
		local x,y,z = getElementPosition(blip)
		if(math.ceil(posX) == math.ceil(x) and math.ceil(posY) == math.ceil(y) and math.ceil(posZ) == math.ceil(z)) then
			destroyElement(blip)
		end
	end
end

addCommandHandler("blip", function () -- the cmd way is for an example
	removeBlip(-715.8314, 2328.1269, 44.1525)
end)

*Changed @Burak5312's code a bit.
Note that this way it won't be very accurate but if you don't plan to have close blips it should not make any problems.

it didn’t work as a miner, in general I figured out how to do it. you can create a marker and when you get up on the marker the blip disappears, how to do it?

Link to post
local blip = createBlip(-715.8314, 2328.1269, 44.1525, 41, 2, 255, 0, 0, 255, 0, 1000)
local finishMarker = createMarker(-715.8314, 2328.1269, 125.6, "cylinder", 3.0, 255, 0, 0, 255)

addEventHandler("onMarkerHit", finishMarker,
   function(hitElement)
      if(getElementType(hitElement) == "player" and isElement(blip)) then
         destroyElement(blip)
      end
   end
)

 

Link to post

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...