SA-MP Forums Archive
Counting.... - 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: Counting.... (/showthread.php?tid=178522)



Counting.... - ColdXX - 22.09.2010

Hey!
I have a question right here.:P
How can i count players that enter on a checkpoint?
Like for example when a player enters a CP it sends a message
Name has entered CP (1 entered)
3 more left...


Re: Counting.... - Seven. - 22.09.2010

pawn Код:
new count[1];

//Ongamemodeinit
count[0] = 4;
count[1] = 0;
//When entering cp:
count[0]--; 3 left, 2 left..
count[1]++; // 1 entered,, 2 enterd.
Then in a string
pawn Код:
%d , %d",count[0],count[1]);
I'm sure you can implent it into your gamemode :P


Re: Counting.... - ColdXX - 22.09.2010

Yea sure thanks man


Re: Counting.... - [XST]O_x - 22.09.2010

Minor mistake:
pawn Код:
new count[2];
Your variable was out of bounds.

And it can be done simply just:

pawn Код:
new count = 0,string[32];

public OnPlayerEnterCheckpoint(playerid)
{
    new n[MAX_PLAYER_NAME]; GetPlayerName(playerid,n,sizeof(n));
    count++;
    format(string,sizeof(string),"\"%s\" has entered the %d checkpoint, %d left.",n,count,4-count);
    SendClientMessageToAll(color,string);
    return 1;
}



Re: Counting.... - ColdXX - 22.09.2010

Quote:
Originally Posted by [XST]O_x
Посмотреть сообщение
Minor mistake:
pawn Код:
new count[2];
Your variable was out of bounds.
Yea i know but i fixed that myself.
BTW how do i check if 4 players have entered the CP?


Re: Counting.... - Conroy - 22.09.2010

pawn Код:
if(count[1] == 4) {
//4 players entered CP
}