How to check if player is last in a mission?
#1

How can i check if a player is last alive in the mission and reward him 5000k.
Reply
#2

count how many players are in the mission and if it equals 1 then give him 5000k
Reply
#3

Quote:
Originally Posted by cessil
Посмотреть сообщение
count how many players are in the mission and if it equals 1 then give him 5000k
How? Can someone do it?
Reply
#4

On Top :
pawn Код:
New PlayerTotalVar;
new PlayerVar[MAX_PLAYERS];
OnPlayerSpawn Callback :
pawn Код:
public OnPlayerConnect(playerid)
{
  PlayerTotalVar++;
  PlayerVar[playerid] = 1;
  return 1;
}
OnPlayerDisconnect Callback :
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
  PlayerTotalVar--;
  return 1;
}
Then SetTimer("TimerName", 1000, true);
Put that on the Callback OnPlayerSpawn

then :

pawn Код:
forward TimeName(playerid);
public TimeName(playerid)
{
  if(PlayerTotalVar == 1 && PlayerVar[playerid] == 1)
  {
    GivePlayerMoney....
  }
  return 1;
}
Somewhere when someone loses just do :
PlayerVar[playerid] = 0;
PlayerTotalVar--;
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)