[Help] Any help with this blip script?

Hello, I tried making a script that would show plane and helicopter blips of players that are currently flying in either aircraft. Also, on the pause menu map, the blip shows the numberplate of the vehicle the player is in. I failed miserably and my code is probably shit. Any ideas?

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(1)
		for id = 0, 64 do
			if NetworkIsPlayerActive(id) and GetPlayerPed(id) ~= GetPlayerPed(-1) then
				ped = GetPlayerPed(id)
				blip = GetBlipFromEntity(ped)
				veh = GetVehiclePedIsIn( ped, false )
				
				if IsPedInAnyPlane(ped) then
						SetBlipDisplay(blip, 2)
						SetBlipSprite( blip, 423)
						BeginTextCommandSetBlipName(blip)
						AddTextComponentSubstringPlayerName(GetVehicleNumberPlateText(veh))
						EndTextCommandSetBlipName(blip)
						Citizen.InvokeNative( 0x5FBCA48327B914DF, blip, false )
				else if IsPedInAnyHeli(ped) then
						SetBlipDisplay(blip, 2)
						SetBlipSprite( blip, 424)
						BeginTextCommandSetBlipName(blip)
						AddTextComponentSubstringPlayerName(GetVehicleNumberPlateText(veh))
						EndTextCommandSetBlipName(blip)
						Citizen.InvokeNative( 0x5FBCA48327B914DF, blip, false )
				
				end
				SetBlipRotation( blip, math.ceil( GetEntityHeading( veh ) ) )
				SetBlipScale( blip,  0.85 )
			end
		end
	end
end)

What part does not work?

Why are you doing this, just use https://runtime.fivem.net/doc/natives/#_0x5FBCA48327B914DF

It just doesn’t work, I spawn a plane and get in it but my blip doesn’t show up on the map for other players.

A broken loop won’t help, try this:

for id = 1, 64, 1 do 
...
end

I’ll try, thanks

Doesnt seem to work, no blip appears on the map when I get in a plane, probably because I get this:

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(1)
		for id = 1, 64, 1 do
			if NetworkIsPlayerActive(id) and GetPlayerPed(id) ~= GetPlayerPed(-1) then
				ped = GetPlayerPed(id)
				blip = GetBlipFromEntity(ped)
				veh = GetVehiclePedIsIn( ped, false )
				
				if IsPedInAnyPlane(ped) then
						SetBlipDisplay(blip, 2)
						SetBlipSprite( blip, 423)
						BeginTextCommandSetBlipName(blip)
						AddTextComponentSubstringPlayerName(GetVehicleNumberPlateText(veh))
						EndTextCommandSetBlipName(blip)
						ShowHeadingIndicatorOnBlip(blip, false)
				else if IsPedInAnyHeli(ped) then
						SetBlipDisplay(blip, 2)
						SetBlipSprite( blip, 424)
						BeginTextCommandSetBlipName(blip)
						AddTextComponentSubstringPlayerName(GetVehicleNumberPlateText(veh))
						EndTextCommandSetBlipName(blip)
						ShowHeadingIndicatorOnBlip(blip, false)
				end
				SetBlipRotation( blip, math.ceil( GetEntityHeading( veh ) ) ) 
				SetBlipScale( blip,  0.85 ) 
			end
		end
	end
end)

Should be elseif.

This script loads, but it just creates 1437 of the same yellow circle “Destination” blips. I need it to show blips only for players in aircraft… any ideas?

local blip
Citizen.CreateThread(function()
	while true do
		Citizen.Wait(0)
		for id = 1, 64, 1 do
			if NetworkIsPlayerActive(id) and GetPlayerPed(id) ~= GetPlayerPed(-1) then
				ped = GetPlayerPed(id)
				veh = GetVehiclePedIsIn( ped, false )
				pos = GetEntityCoords(GetPlayerPed(-1))
				blip = AddBlipForCoord(pos.x, pos.y, pos.z)
				
				if IsPedInAnyPlane(ped) then
						SetBlipSprite( blip, 423)
						SetBlipDisplay(blip, 2)
						BeginTextCommandSetBlipName("String")
						AddTextComponentSubstringPlayerName(GetVehicleNumberPlateText(veh))
						EndTextCommandSetBlipName(blip)
						ShowHeadingIndicatorOnBlip(blip, false)
				elseif IsPedInAnyHeli(ped) then
						SetBlipSprite( blip, 424)
						SetBlipDisplay(blip, 2)
						BeginTextCommandSetBlipName("String")
						AddTextComponentSubstringPlayerName(GetVehicleNumberPlateText(veh))
						EndTextCommandSetBlipName(blip)
						ShowHeadingIndicatorOnBlip(blip, false)
				end
				SetBlipRotation( blip, math.ceil( GetEntityHeading(veh))) 
				SetBlipScale(blip,  0.9) 
			end
		end
	end
end)

Hello, I need help with a script that only shows blips of players in a plane or a heli on the pause menu map. Also the name of the player shown when clicking the blip must be replaced with the licenseplate number of the aircraft. Any help is appreciated. Thanks

https://runtime.fivem.net/doc/natives/#_0x5FFF4CFC74D8FB80
https://runtime.fivem.net/doc/natives/#_0x298B91AE825E5705

https://runtime.fivem.net/doc/natives/#_0x9029B2F3DA924928
displayId 4

https://runtime.fivem.net/doc/natives/#_0xF9113A30DE5C6670
https://runtime.fivem.net/doc/natives/#_0xBC38B49BCB83BC9B
https://runtime.fivem.net/doc/natives/#_0x7CE1CCB9B293020E

thanks, gotta figure out how to piece those together

I’ll probably need some help writing the code since I’m new to lua… anything is very much appreciated.

A lot of FiveM scripting is documented on the docs for lua.

The blip variable is undefined.
Also you need to break the loop because it executes for every player that has an id that’s between 1 and 64 and it never stops try usingIf instead of for.

Check this out please?

1 Like

2 year old topic, someone ignored the bump warning