Hello, I’m having an issue with displaying a blip serverside, the blip is displayed when a command is executed, that works fine. But when a player executes the command it show the blip on him but for other players it shows the blip on them. I wan’t it to only show the blip on the player that executed the command for everyone.
Client:
RegisterNetEvent('displayblip')
AddEventHandler('displayblip', function(x, y, z)
local ped = GetPlayerPed(-1)
local x,y,z = table.unpack(GetEntityCoords(ped, false))
local blip1 = AddBlipForCoord(x, y, z)
SetBlipSprite(blip1, 1)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString('10-13')
SetBlipColour(blip1, 1)
EndTextCommandSetBlipName(blip1)
Citizen.Wait(100000)
RemoveBlip(blip1)
end)
The “id” is defined earlier to send it to all the cops online, that is working. The issue I’m running into is that when a player executes the command he sees the blip on him but all other players see the blip on themselves
Ah, that would be because of this line: local ped = GetPlayerPed(-1). Which is getting the current player’s ped (although, you should be using the PlayerPedId() native).
Anyways, you can combat this by sending the player’s server ID to the event and use the GET_PLAYER_FROM_SERVER_ID.
E.g.
AddEventHandler('displayblip', function(serverId, x, y, z)
local ped = GetPlayerPed(GetPlayerFromServerId(serverId))
-- more code
end)