SA-MP Forums Archive
Spawn Position when a player dies. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Spawn Position when a player dies. (/showthread.php?tid=409425)



Spawn Position when a player dies. - Da_Noob - 21.01.2013

So I'm recently starting to learn scripting again, and I have a problem.
Whenever somebody dies he spawns at BlueBerry. I tried to put SetPlayerPos in OnPlayerSpawn, but now when a player logs in he spawns at the hospital (I have a register/save system). How can I fix this?

Thanks in advance!


Re: Spawn Position when a player dies. - DaRk_RaiN - 21.01.2013

I'm sure that the Hospital spawn is from AddPlayerClass.
To fix this just set the player team of use a variable such as gTeam and then when the player spawns
pawn Код:
if(GetPlayerTeam(playerid) == 1)
{
SetPlayerPos(playerid,x,y,z);
}
else if(GetPlayerTeam(playerid) == 2)
{
SetPlayerPos(playerid,x,y,z);
}
Or use it with cases.


Re: Spawn Position when a player dies. - Da_Noob - 21.01.2013

Well, I've put SetPlayerPos and then the coordinates of the hospital under OnPlayerSpawn. So now, when someone dies it teleports him to the hospital, but also when a player connects it teleports him to there, while it should teleport him to his last X, Y, Z.
When I remove the SetPlayerPos from my OnPlayerSpawn, it works fine when you log in, it'll teleport you to your last X, Y, Z. But when you die you just teleport back to Blueberry. I'm not working with teams or anything similar.


Re: Spawn Position when a player dies. - DaRk_RaiN - 21.01.2013

So what's the issue?you want players who die to get teleportd to the Hospital and those who didn't to spawn in the usual places?


Re: Spawn Position when a player dies. - Da_Noob - 21.01.2013

Yes, that's exactly what I want. But I can't make it work. Can you help me?


Re: Spawn Position when a player dies. - Da_Noob - 22.01.2013

Can anybody fix this?


Re: Spawn Position when a player dies. - Scenario - 22.01.2013

When a player dies, you would want to set a bool variable to true. So, for example: justDied[playerid] = true;

Obviously, set that under OnPlayerDeath. Under OnPlayerSpawn, check to see if justDied[playerid] is equal to true. To do that: if(justDied[playerid])

If it is, spawn them at the hospital and set the bool back to false. Otherwise, spawn them as usual (as per your accounts system).

Make sense?


Re: Spawn Position when a player dies. - Da_Noob - 22.01.2013

Yes, that makes sense. I'll try it out!