spawning on hospital when died
#1

I want it so that when a player dies, he ends up on the hospital..

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
  SetPlayerPos(playerid, 1607.4170, 1819.0120, 359.4669);
  return 1;
}
This is what I have so far, the problem is that when I die, I spawn far up in the air, and land the point where he is supposed to spawn(not falling ofc)
Reply
#2

OnPlayerDeath is called when player dies, so of course that doesn't work.
You should use the OnPlayerSpawn callback, but create a player-variable and set it to true when player spawns for the first time. Then use the if-statement to check if that variable is setted to true - which means that player isn't spawning for the first time.
Reply
#3

Quote:
Originally Posted by Don Correlli
OnPlayerDeath is called when player dies, so of course that doesn't work.
You should use the OnPlayerSpawn callback, but create a player-variable and set it to true when player spawns for the first time. Then use the if-statement to check if that variable is setted to true - which means that player isn't spawning for the first time.
I appreciate your answer.Though I am quite new at scripting, so what you said there can't really help me.
Reply
#4

Very simple way:
pawn Код:
new pDead[MAX_PLAYERS];
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
  pDead[playerid] = 1;
  return 1;
}
pawn Код:
public OnPlayerSpawn(playerid)
{
  if(pDead[playerid] == 1)
 {
    SetPlayerPos(playerid, 1607.4170, 1819.0120, 359.4669);
    pDead[playerid] = 0;
  }
  return 1;
}
Reply
#5

Itz because you set your Z coordinates high high up "SetPlayerPos(playerid, 1607.4170, 1819.0120, 359.4669);" It's Y,X,Z so the Z coordinate should be from 1-50. Tell me in what hospital do you want to respawn
Reply
#6

Quote:
Originally Posted by Majataka
Itz because you set your Z coordinates high high up "SetPlayerPos(playerid, 1607.4170, 1819.0120, 359.4669);" It's Y,X,Z so the Z coordinate should be from 1-50. Tell me in what hospital do you want to respawn
What if the hospital is on the high side of the map? But yeah you need the right co-ordinates.
Reply
#7

Lv Hospital
Reply
#8

Quote:
Originally Posted by Majataka
Itz because you set your Z coordinates high high up "SetPlayerPos(playerid, 1607.4170, 1819.0120, 359.4669);" It's Y,X,Z so the Z coordinate should be from 1-50. Tell me in what hospital do you want to respawn
He wrote SetPlayerPos in the callback OnPlayerDeath, he will goto the pause and then respawn at the default spawn point, he won't be able to spawn at the hospital if he puts SetPlayerPos on OnPlayerDeath.
Reply
#9

Quote:
Originally Posted by Majataka
Itz because you set your Z coordinates high high up "SetPlayerPos(playerid, 1607.4170, 1819.0120, 359.4669);" It's Y,X,Z so the Z coordinate should be from 1-50. Tell me in what hospital do you want to respawn
actually its X,Y,Z not Y,X,Z
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)