Blip issue

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)

Server:

TriggerClientEvent('displayblip', id, x, y, z)

Use -1 instead of the player’s “id” to send the event to everyone and not just the player who executed the command.

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)

Aha, so I did that

AddEventHandler('displayblip', function(serverId, x, y, z)
    local ped = GetPlayerPed(GetPlayerFromServerId(serverId))
    -- my other code
end)

and

TriggerClientEvent('displayblip', id, serverId, x, y, z)

But it still causes the same problem? Sorry I’m still pretty new to lua

server.lua

--This is calling the function for the players X Y Z
TriggerClientEvent("Yourscript", source)

In your client.lua you will need to trigger the players XYZ

local plyPos = GetEntityCoords(GetPlayerPed(-1),  true)
TriggerServerEvent('activateblip', plyPos.x, plyPos.y, plyPos.z)

Now back in your server.lua you need to call the blip script.

RegisterServerEvent('activateblip')
AddEventHandler('activateblip', function(mx, my, mz)
	TriggerClientEvent('displayblip', -1, mx, my, mz)
end)

Thank you guys for the help!