SA-MP Forums Archive
How to check if player is last in a mission? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to check if player is last in a mission? (/showthread.php?tid=188066)



How to check if player is last in a mission? - ZamaXor - 06.11.2010

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


Re: How to check if player is last in a mission? - cessil - 06.11.2010

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


Re: How to check if player is last in a mission? - ZamaXor - 06.11.2010

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?


Re: How to check if player is last in a mission? - ViruZZzZ_ChiLLL - 06.11.2010

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--;