I’ve been unable to find out how to do this. Would appreciate some support.
Do you want to do this when they’re respawning after they died or if they restart the whole game?
When they’re respawning after they died. This is for a Freeroam server I’m making.
If you’re using esx_ambulancejob, I’m pretty sure you can do that through that script by saving the last death position in an object.
Wouldn’t that make them respawn EXACTLY where they died? Like a revive script? That’s not what I’m looking for. I want them to respawn NEAR their death location. I’m pretty sure RSM servers have that.
Yea, you’d need to spawn them within a radius of that specific point you’re carrying with you in the object
Isn’t there any resource or script that allows me to do that or do I have to program it myself? I just got started with making a server in FiveM and all this resource development stuff seems really complicated.
Code it yourself… What your asking for is really simple, Just store their death coords in a object(table) and when it revives them ->
local radius = 100
local newCoords = {
x = math.random(oldcoords.x - radius, oldcoords.x + radius),
y = math.random(oldcoords.y - radius, oldcoords.y + radius),
z = oldCoords.z -- This one doesn't matter because your going to recalculate it below
}
_, newCoords.z = GetGroundZFor_3dCoord(newCoords.x, newCoords.y, newCoords.z)
SetEntityCoords(GetPlayerPed(-1), newCoords.x, newCoords.y, newCoords.z)
where to write this please specify
local radius = 100
local newCoords = {
x = math.random(oldcoords.x - radius, oldcoords.x + radius),
y = math.random(oldcoords.y - radius, oldcoords.y + radius),
z = oldCoords.z – This one doesn’t matter because your going to recalculate it below
}
_, newCoords.z = GetGroundZFor_3dCoord(newCoords.x, newCoords.y, newCoords.z)
SetEntityCoords(GetPlayerPed(-1), newCoords.x, newCoords.y, newCoords.z)
Hello I was looking for some simple resource like that, but couldn’t find anything ready and after many tries and reading posts I have managed to make myself one. So am sharing it here for anyone interested.
Installation is pretty much straightforward, make a folder with the name respawn-near
and put those two files in your server-data/resources
folder and then add this line start respawn-near
to your server.cfg
file.
I have tested the resource and it seems to be working just fine, it will respawn you near your death place when you suicide or you are killed.
Hope that helps someone else.
Hello! i just tried your script, i installed just as you said there, but it keep respawning at the default server location, do you have an idea about how to fix it please?
Thanks you
make sure you have this resource enabled in your server I think its disabled by default and its provided by fivem itself so just enable it in your server.cfg
i try this right now thanks you very much
well yes it’s working pretty good, thanks you so much!
But i have a little question, i would like the player respawn at the exact position where he died so i changed this:
local radius = 300
to this:
local radius = 0
and this:
newCoords.z = -300.0
to this:
newCoords.z = -1.0
im spawning at correct X and Y but i spawn high in the airs (but won’t die because of your timer)
is it possible to respawn closer from the ground?
change only this variable to a lower amount, Z-axis should be calculated automatically if it doesn’t then it would be newCoords.z = -300.0
, but that is a kinda random height
ok so the problem is i get the timer where i am invincible, when i fall i don’t take damages, but other players keep dying on the server
is it normal, or can i do anything for it? maybe make it a server instead of a client script?
no normal behavior is to spawn you near your death, sometimes (rarely) when it can’t find Z axis (ground) it will put you on air in free fall and after some time you will be spawned again at least that’s how it was with me, this is how it normally works,
what you described sounds like some weird behavior and maybe something else is conflicting with that resource
and yes you can always do something it is code, maybe try some things and edit it and see if you find a solution then share it with everyone, good luck
ok i’ll make some tests, in my case it always respawn high in the air, and on the fall i don’t die.
i’ll check if i can fix something! Thanks again
what do you mean high like very high or like 5-6 meters high if its 5-6 meters high in air that would be because of this 25 number here, make it lower and it should spawn you a bit closer to ground, this is the case when it found ground
i’ll try on my local since im still curious, but yeah high like 6/8 meters something like that
But i finally found how to be invincible with ragdol enabled so problem for my server is stopped anyway