Spawn Position when a player dies.
#1

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!
Reply
#2

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.
Reply
#3

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.
Reply
#4

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?
Reply
#5

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

Can anybody fix this?
Reply
#7

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?
Reply
#8

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


Forum Jump:


Users browsing this thread: 3 Guest(s)