Counting....
#1

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...
Reply
#2

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
Reply
#3

Yea sure thanks man
Reply
#4

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;
}
Reply
#5

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?
Reply
#6

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


Forum Jump:


Users browsing this thread: 2 Guest(s)