new TotalEvenParticipants;
TotalEvenParticipants++;
// When someone joins
TotalEvenParticipants--;
//When someone dies
if (TotalEvenParticipants == 1)
//only one left
new JoinedEvent[MAX_PLAYERS]; // Top of script
/joinevent
JoinedEvent[playerid] = 1;
new count;
count++;
OnPlayerDeath:
if(JoinedEvent[playerid] == 1)
{
count--;
You've been killed and you're now out of the event.
if(count == 1)
{
Declare winner.
}
}
pawn Код:
|
That's not going to work because if someone quits while in the even it's not going to declare the winner. Plus you need the count variable to be on top along with the "JoinedEvent" one.
|
new bool:inEvent[MAX_PLAYERS]; //example usage of the function public OnPlayerConnect(playerid) { playerEventState(playerid, false); return 1; } public OnPlayerDeath(playerid, killerid, reason) { playerEventState(playerid, false); return 1; } //you can use this to place player in an event or take him out. stock playerEventState(player, bool: st) { inEvent[player] = st; //player is disqualified. if(!st) { if(pOfEvent() == 1) { new lastPlayerID = eventLastPlayer(), str[50]; //do what you wish with the last player, example format(str, sizeof str, "INFO: ID %d is the last alive ", lastPlayerID); SendClientMessageToAll(str, 0xFF0000AA); } } return st; } stock eventLastPlayer() { //this function is used only if we know that there is one player for(new i = 0; i < MAX_PLAYERS; ++i) if(IsPlayerConnected(i) && inEvent[i])return i; } stock pOfEvent() { new playersEvent = 0; for(new i = 0; i < MAX_PLAYERS; ++i) if(IsPlayerConnected(i) && inEvent[i])playersEvent++; return playersEvent; }