How remove a blip in my script?

Hello, i try do remove some blips if the player haven’t the correct job in my client script but i not find how ;(

My client script :

RegisterNetEvent('jobssystem:updateJob')
AddEventHandler('jobssystem:updateJob', function(nameJob)
local id = PlayerId()
local playerName = GetPlayerName(id)
  SendNUIMessage({
  updateJob = true,
  job = nameJob,
  player = playerName
  })
    if nameJob == 'Chomeur' then
      for _, item in pairs(Chomeur) do
        item.blip = AddBlipForCoord(item.x, item.y, item.z)
        SetBlipSprite(item.blip, item.id)
        SetBlipAsShortRange(item.blip, true)
        BeginTextCommandSetBlipName("STRING")
        AddTextComponentString(item.name)
        EndTextCommandSetBlipName(item.blip)
      end
    else
      RemoveBlip(Chomeur)
    end
end)

What’s stored in your Chomeur table?

This might be the solution if I understand your code correctly:

RegisterNetEvent('jobssystem:updateJob')
AddEventHandler('jobssystem:updateJob', function(nameJob)
local id = PlayerId()
local playerName = GetPlayerName(id)
  SendNUIMessage({
  updateJob = true,
  job = nameJob,
  player = playerName
  })
    if nameJob == 'Chomeur' then
      for _, item in pairs(Chomeur) do
        item.blip = AddBlipForCoord(item.x, item.y, item.z)
        SetBlipSprite(item.blip, item.id)
        SetBlipAsShortRange(item.blip, true)
        BeginTextCommandSetBlipName("STRING")
        AddTextComponentString(item.name)
        EndTextCommandSetBlipName(item.blip)
      end
    else
	  for _, item in pairs(Chomeur) do
		if DoesBlipExist(item.blip) then
			SetBlipAsMissionCreatorBlip(item.blip,false)
			RemoveBlip(item.blip)
			item.blip = nil
		end
	  end
    end
end)
1 Like

It’s working ! One question, where did you find DoesBlipExist() ? and all of this functions ?

http://www.dev-c.com/nativedb/
https://runtime.fivem.net/doc/reference.html
https://wiki.fivem.net/wiki/Main_Page
Or in client folder yourfivemfolder/citizen/scripting/lua

Okey thank’s you very much !