Skip to content

Commit be83f93

Browse files
committed
tweak(server/admin_server) increased validation of targets before spectate/teleport
1 parent effc5a1 commit be83f93

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

server/admin_server.lua

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,22 @@ Citizen.CreateThread(function()
325325
PrintDebugMessage("Player "..getName(source,true).." Requested Spectate to "..getName(playerId,true), 3)
326326
local tgtPed = GetPlayerPed(playerId)
327327
if tgtPed == 0 then
328-
-- ped does not exist (left server)
328+
-- ped does not exist left or not loaded in yet
329329
TriggerClientEvent("EasyAdmin:showNotification", source, GetLocalisedText("playernotfound"))
330330
return
331331
end
332+
333+
if playerId == source then
334+
return
335+
end
336+
332337
local tgtCoords = GetEntityCoords(tgtPed)
338+
if tgtCoords.x == 0.00 and tgtCoords.y == 0.00 then
339+
-- loaded in but still spawning
340+
TriggerClientEvent("EasyAdmin:showNotification", source, GetLocalisedText("playernotfound"))
341+
return
342+
end
343+
333344
local playerBucket = GetPlayerRoutingBucket(playerId)
334345
local sourceBucket = GetPlayerRoutingBucket(source)
335346
if sourceBucket ~= playerBucket then
@@ -490,11 +501,25 @@ Citizen.CreateThread(function()
490501
if not CachedPlayers[id].dropped and DoesPlayerHavePermission(source, "player.teleport.single") and CheckAdminCooldown(source, "teleport") then
491502
SetAdminCooldown(source, "teleport")
492503
local tgtPed = GetPlayerPed(id)
504+
if tgtPed == 0 then
505+
-- ped does not exist left or not loaded in yet
506+
TriggerClientEvent("EasyAdmin:showNotification", source, GetLocalisedText("playernotfound"))
507+
return
508+
end
509+
if id == source then
510+
return
511+
end
493512
local tgtCoords = GetEntityCoords(tgtPed)
513+
if tgtCoords.x == 0.00 and tgtCoords.y == 0.00 then
514+
-- loaded in but still spawning
515+
TriggerClientEvent("EasyAdmin:showNotification", source, GetLocalisedText("playernotfound"))
516+
return
517+
end
494518
local preferredWebhook = detailNotification ~= "false" and detailNotification or moderationNotification
495519
SendWebhookMessage(preferredWebhook,string.format(GetLocalisedText("teleportedtoplayer"), getName(source, false, true), getName(id, true, true)), "teleport", 16777214)
496520
TriggerClientEvent('EasyAdmin:TeleportRequest', source, id,tgtCoords)
497521
else
522+
TriggerClientEvent("EasyAdmin:showNotification", source, GetLocalisedText("playernotfound"))
498523
PrintDebugMessage('EASYADMIN FAILED TO TELEPORT'..source..' TO ID: '..id, 2)
499524
end
500525
end)

0 commit comments

Comments
 (0)