RegisterCommand("getloc", function(source, args, rawCommand)
playerid = tonumber(args[1]) -- define playerid as the first argument
local ped = GetPlayerPed(playerid) -- get the ped of the playerid
local pos = GetEntityCoords(ped, true) -- get the coords of the ped
Citizen.CreateThread(function()
SetNewWaypoint(pos.x, pos.y) -- set the waypoint to the x and y position of the ped
TriggerEvent('chatMessage', '', {255, 255, 255}, 'Waypoint has been set to player ID ' .. playerid)
end)
end, false) -- set this to false to allow anyone
Note that this will only set the waypoint statically, and it will not follow the player. (and it may not work cause I can’t check lol)
how would i sent the waypoint to only one player?
when I have a client script, that runs trough a console command, it gives the waypoint to all players.
RegisterCommand("getloc", function(source, args, rawCommand)
local player = GetPlayerFromServerId(args[1])
local ped = GetPlayerPed(player)
local pos = GetEntityCoords(ped, true)
SetNewWaypoint(pos.x, pos.y)
TriggerEvent('chatMessage', '', {255, 255, 255}, 'Waypoint has been set to player ID ' .. args[1])
end)
Have you tested it on another player I have dropped it into client side, set the waypoint for a second and the way point is on me not the player whos Id I have specified.
Use this inside registercommand, this must show a blip player in map:
playerCoords = GetEntityCoords(GetPlayerPed(args[1]), true)
coordsX= playerCoords.x
coordsY= playerCoords.y
coordsZ= playerCoords.z
markBlip=AddBlipForCoord(coordsX,coordsY,coordsZ)
--add type of marker that you want
markerType=128
while true do
Citizen.Wait(0)
SetBlipSprite(markBlip, markBlipType)
end
Bit late to the party, but I’ve tried this, doesnt seem to work. It will always set a marker to the own player. Iam also not sure if I got the correct ID’s. Reading them from Vmenu, and will be in the order people joined. so /getloc 1 (anything lower than 10 tested with 2 players in the server) will set a waypoint to the own pet