Hello there !
So i’m adding player blips into my server the only probleme that i get is that the blips do not display when an player is in a car, it do display when player are in an police car for exemple but not normal cars.
I did try to add manually all VehClass but at the result i did get every blips look like cars even if the player is not into a car
here is my actual code ^^
Citizen.CreateThread(function()
while Enabled do
Citizen.Wait(0)
for id=1, #getPlayerIds() do
if NetworkIsPlayerActive( id ) and GetPlayerPed( id ) ~= GetPlayerPed( -1 ) then
ped = GetPlayerPed( id )
blip = GetBlipFromEntity( ped )
-- HEAD DISPLAY STUFF --
-- Create head display (this is safe to be spammed)
headId = Citizen.InvokeNative( 0xBFEFE3321A3F5015, ped, GetPlayerName( id ), false, false, "", false )
wantedLvl = GetPlayerWantedLevel( id )
-- BLIP STUFF --
if not DoesBlipExist( blip ) then -- Add blip and create head display on player
blip = AddBlipForEntity( ped )
SetBlipSprite( blip, 1 )
Citizen.InvokeNative( 0x5FBCA48327B914DF, blip, true ) -- Player Blip indicator
else -- update blip
veh = GetVehiclePedIsIn( ped, false )
blipSprite = GetBlipSprite( blip )
if not GetEntityHealth( ped ) then -- dead
if blipSprite ~= 274 then
SetBlipSprite( blip, 274 )
Citizen.InvokeNative( 0x5FBCA48327B914DF, blip, false ) -- Player Blip indicator
end
elseif veh then
vehClass = GetVehicleClass( veh )
vehModel = GetEntityModel( veh )
if vehClass == 15 then -- jet
if blipSprite ~= 422 then
SetBlipSprite( blip, 422 )
Citizen.InvokeNative( 0x5FBCA48327B914DF, blip, false ) -- Player Blip indicator
end
elseif vehClass == 8 then -- Motorcycles
if blipSprite ~= 226 then
SetBlipSprite(blip, 226)
ShowHeadingIndicatorOnBlip(blip, false) -- Player Blip indicator
end
elseif vehClass == 16 then -- plane
if vehModel == GetHashKey( "besra" ) or vehModel == GetHashKey( "hydra" )
or vehModel == GetHashKey( "lazer" ) then -- jet
if blipSprite ~= 424 then
SetBlipSprite( blip, 424 )
Citizen.InvokeNative( 0x5FBCA48327B914DF, blip, false ) -- Player Blip indicator
end
elseif blipSprite ~= 423 then
SetBlipSprite( blip, 423 )
Citizen.InvokeNative (0x5FBCA48327B914DF, blip, false ) -- Player Blip indicator
end
elseif vehClass == 14 then -- boat
if blipSprite ~= 427 then
SetBlipSprite( blip, 427 )
Citizen.InvokeNative( 0x5FBCA48327B914DF, blip, false ) -- Player Blip indicator
end
elseif vehClass == 13 then -- moto
if blipSprite ~= 226 then
SetBlipSprite( blip, 226 )
Citizen.InvokeNative( 0x5FBCA48327B914DF, blip, false ) -- Player Blip indicator
end
elseif vehModel == GetHashKey("taxi") then -- Cab/ Taxi
if blipSprite ~= 198 then
SetBlipSprite(blip, 198)
ShowHeadingIndicatorOnBlip(blip, false) -- Player Blip indicator
end
elseif vehModel == GetHashKey("fbi") or vehModel == GetHashKey("fbi2") or vehModel == GetHashKey("police2") or vehModel == GetHashKey("police3") -- Police Vehicles
or vehModel == GetHashKey("police") or vehModel == GetHashKey("sheriff2") or vehModel == GetHashKey("sheriff")
or vehModel == GetHashKey("policeold2") or vehModel == GetHashKey("policeold1") then
if blipSprite ~= 56 then
SetBlipSprite(blip, 56)
ShowHeadingIndicatorOnBlip(blip, false) -- Player Blip indicator
end
--elseif vehClass == 18 then -- véhicule de police
--if blipSprite ~= 56 then
-- SetBlipSprite( blip, 56 )
--Citizen.InvokeNative( 0x5FBCA48327B914DF, blip, false ) -- Player Blip indicator
-- end
elseif vehModel == GetHashKey( "insurgent" ) or vehModel == GetHashKey( "insurgent2" )
or vehModel == GetHashKey( "limo2" ) then -- insurgent (+ turreted limo cuz limo blip wont work)
if blipSprite ~= 426 then
SetBlipSprite( blip, 426 )
Citizen.InvokeNative( 0x5FBCA48327B914DF, blip, false ) -- Player Blip indicator
end
elseif vehModel == GetHashKey( "rhino" ) then -- tank
if blipSprite ~= 421 then
SetBlipSprite( blip, 421 )
Citizen.InvokeNative( 0x5FBCA48327B914DF, blip, false ) -- Player Blip indicator
end
elseif blipSprite ~= 1 then -- default blip
SetBlipSprite( blip, 1 )
Citizen.InvokeNative( 0x5FBCA48327B914DF, blip, true ) -- Player Blip indicator
end
-- Show number in case of passangers
passengers = GetVehicleNumberOfPassengers( veh )
if passengers then
if not IsVehicleSeatFree( veh, -1 ) then
passengers = passengers + 1
end
ShowNumberOnBlip( blip, passengers )
else
HideNumberOnBlip( blip )
end
else
-- Remove leftover number
HideNumberOnBlip( blip )
if blipSprite ~= 1 then -- default blip
SetBlipSprite( blip, 1 )
Citizen.InvokeNative( 0x5FBCA48327B914DF, blip, true ) -- Player Blip indicator
end
end
SetBlipRotation( blip, math.ceil( GetEntityHeading( veh ) ) ) -- update rotation
SetBlipNameToPlayerName( blip, id ) -- update blip name
SetBlipScale( blip, 0.99 ) -- set scale
-- set player alpha
if IsPauseMenuActive() then
SetBlipAlpha( blip, 255 )
else
x1, y1 = table.unpack( GetEntityCoords( GetPlayerPed( -1 ), true ) )
x2, y2 = table.unpack( GetEntityCoords( GetPlayerPed( id ), true ) )
distance = ( math.floor( math.abs( math.sqrt( ( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ) ) ) / -1 ) ) + 900
-- Probably a way easier way to do this but whatever im an idiot
if distance < 0 then
distance = 0
elseif distance > 255 then
distance = 255
end
SetBlipAlpha( blip, distance )
end
end
end
end
end
end)