Remove player blips without disabling scripthook


#1

Is it possible to remove player blips since we use menus a lot for our roleplay and dont want to disable them for the time being, thanks.


#2

There will be a way to do this but, its going to have to be written by yourself. I’ll give you an idea of how I would go about doing this, the rest is up to you :slightly_smiling_face:

I would combine _GET_BLIP_INFO_ID_ITERATOR GET_FIRST_BLIP_INFO_ID and GET_NEXT_BLIP_INFO_ID to iterate through all the existing blips. I could then check they exist using DOES_BLIP_EXIST. I would then check that the blip is assigned to a player (see note 1) and then use REMOVE_BLIP to remove it.

Note 1: I don’t know how you would check if the blip is attached to a player exactly but, you could experiment with the natives below and see if you can figure it out

GET_BLIP_INFO_ID_ENTITY_INDEX - then maybe check if the entity is a player?

GET_BLIP_INFO_ID_TYPE - not too sure what the int is… Maybe test around and see if one of then represents a player?

GET_BLIP_SPRITE - then check if it’s a player marker, no guarantee that it is actually a player though


#3

for checking if the blip is a player would doing: work?

local blip = GetBlipFromEntity(GetPlayerPed(-1))
if DoesBlipExist(blip) then

#4

That would only get the blip for the current player (if they have one) and remove it from their map. This means that the player just wouldn’t be able to see their own blip.

I don’t know if blip ids are synchronized across all networked players so, sending the result to others may not work as expected.


#5

Ah, thanks. Im gonna go and experiment as im not the best but thanks with the assistance with the natives as i probably wouldnt have found them or used them, thanks for the help!


#6

Would it just be possible to check if that type of blip exists on the map then remove it? cause i believe blip id 1 is a player so just checking if that type of blip exists on the map remove it?


#7

No worries, I’ve just found some more natives that may be able to help you figure out if the blip is for a player.

You could get the entity by using the Entity_Index native then, use IS_ENTITY_A_PED coupled with IS_PED_A_PLAYER. It may be a bit convoluted but, it’s the only thing I can think of at the minute (someone else may have a better idea).

Edit: you may also have to use
GET_PED_FROM_ENTITY_INDEX


#8

Have you tried the GET_BLIP_INFO_ID_TYPE native for that? Like I said, I don’t know what the int is exactly but, the description says it’s the type (maybe check if it returns 1)


#9

Good call, ill check that now


#10

God knows what im doing xD

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(0)
		ped = GetPlayerPed(-1)
		test = IsEntityAPed(ped)
		if IsPedAPlayer(ped) and test == true then
			test2 = GetBlipInfoIdType(ped)
			if test2 == 1 then
				TriggerEvent("chatMessage", {255,0,0}, "This probably wont work cause my 14 yr old brain isnt intelligent enough for such a feat")
		end
	end
end)

#11

Oh god… I’ll try and whip something up for you but, not promising it will be 100% working (on mobile, not at computer).

Citizen.CreateThread(function()

    -- while true do
    local blipIterator = GetBlipInfoIdIterator()
    local blip = GetFirstBlipInfoId(blipIterator)
    
     while DoesBlipExist(blip) do
           -- check if player
          local entity = GetBlipInfoIdEntityIndex(blip)
          if entity then -- it is attached to entity?
               if IsEntityAPed(entity) and IsPedAPlayer(GetPedFromEntityIndex(entity)) then -- is a player?
                   RemoveBlip(blip)
               end
          end
          blip = GetNextBlipInfoId(blipIterator)
     end
     -- end

end)

#12

For a mobile device, this looks very good, I think it’s about 2hours of work? :open_mouth:


#13

Holy… How slowly do you write? :astonished: :wink:


#14

Now ive seen it, thats makes so much more sense to me now haha
Also on the native page the native REMOVE_BLIP Crashes so would making the size of the blip 0 or changing it into an invisible blip id work instead?


#15

Didn’t see that bit at the bottom :stuck_out_tongue:

Yea, changing the blip to make it invisible or something would probably be better then :slightly_smiling_face:


#16

Maybe something like this would work?

Citizen.CreateThread(function()

    -- while true do
    local blipIterator = GetBlipInfoIdIterator()
    local blip = GetFirstBlipInfoId(blipIterator)
    
     while DoesBlipExist(blip) do
           -- check if player
          local entity = GetBlipInfoIdEntityIndex(blip)
          if entity then -- it is attached to entity?
               if IsEntityAPed(entity) and IsPedAPlayer(GetPedFromEntityIndex(entity)) then -- is a player?
                   SetThisScriptCanRemoveBlipsCreatedByAnyScript(true)
				   SetBlipScale(Blip,0.0)
               end
          end
          blip = GetNextBlipInfoId(blipIterator)
     end
     -- end

end)

#17

Not too sure why you’re using this native since you’re not removing the blip…

Won’t work because there’s no “Blip” it’s called “blip” (Lua cares about that capital letter). Apart from that, I guess that should work. You might also want to uncomment the “while true do” and “end” lines to make sure new player blips also get removed.


#18

Sorry, still learning. Will do what you said and test. Thanks!


#19

thought you needed a Citizen.Wait(0) even if you dont want a delay?


#20

Yes, you do otherwise the client will crash… You would only need it if you uncomment the while loop