How can I place random spawn locations within a player’s kill radius? it’s the gun game
Standalone usage:
Citizen.CreateThread(function()
local radius = 60 -- distance from old location
while true do
if IsPlayerDead(PlayerId()) then
local x,y,z = table.unpack(GetEntityCoords(PlayerPedId(),false))
posX = x + math.random(-radius, radius)
posY = y + math.random(-radius, radius)
posZ = z + 999.0
_,posZ = GetGroundZFor_3dCoord(posX+.0,posY+.0,z,1)
Wait(3000) -- seconds to wait for player to Respawn
--REVIVE SCRIPT HERE
--example
--TriggerEvent("esx_ambulancejob:revive")
--or
DoScreenFadeOut(800)
while not IsScreenFadedOut() do
Citizen.Wait(50)
end
NetworkResurrectLocalPlayer(posX, posY, posZ, 100, true, false)
SetPlayerInvincible(PlayerPedId(), false)
ClearPedBloodDamage(PlayerPedId())
Wait(100)
SetEntityCoords(PlayerPedId(),posX,posY,posZ)
DoScreenFadeIn(800)
end
Wait(1000)
end
end)
1 Like