02.03.2017, 12:56
Save the position of the player when they die, load it when they respawn, something like this:
While it may not be the most optimized code, it should work.
Here's a tutorial about PVars (what we used in the code up here) https://sampforum.blast.hk/showthread.php?tid=163175
Here's a wiki page with nice documentation for starters https://sampwiki.blast.hk/wiki/Control_Structures
Код:
public OnPlayerDeath(playerid) { new Float:pos[3]; GetPlayerPos(playerid,pos[0],pos[1],pos[2]); SetPVarFloat(playerid,"PosX",pos[0]); SetPVarFloat(playerid,"PosY",pos[1]); SetPVarFloat(playerid,"PosZ",pos[2]); SetPVarInt(playerid,"IsResPawn",1); return 1; } public OnPlayerSpawn(playerid) { if(GetPVarInt(playerid,"IsResPawn") == 1) { SetPlayerPos(playerid,GetPVarFloat(playerid,"PosX"),GetPVarFloat(playerid,"PosY"),GetPVarFloat(playerid,"PosZ"); DeletePVar(playerid,"IsResPawn"); } return 1; }
Here's a tutorial about PVars (what we used in the code up here) https://sampforum.blast.hk/showthread.php?tid=163175
Here's a wiki page with nice documentation for starters https://sampwiki.blast.hk/wiki/Control_Structures