Count problem.
#1

Hello, the count function checks if players are near the guy who started the count if they are near the count starts, problem is if a guys is near me and i start to count it counts like this, 5 , 3, 1, GO. I tried alone and it worked good.

pawn Код:
public Count(playerid){
    if(!IsCountActive){
        KillTimer(CountTimer);
    }else{
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        foreach(Player, i){
            if(IsPlayerInRangeOfPoint(i, 30, x, y, z)){
                new string[4];
                format(string,sizeof(string),"%i",CountAmmount);
                GameTextForPlayer(i,string,1000,3);
                CountAmmount--;
                if(CountAmmount == -1) {
                    IsCountActive = 0, GameTextForPlayer(i,"~g~~h~Go!",1000,3);
                }
            }
        }
    }
    return 1;
}


CMD:count(playerid,params[]){
    static amount;
    if(sscanf(params,"i",amount)) return SendClientMessage(playerid, 0xDDDDDDFF, "[{37B7D7}USAGE{DDDDDD}]: /count [amount]");
    if(IsCountActive == 1) return SendClientMessage(playerid, 0xDDDDDDFF, "[{FF0000}ERROR{DDDDDD}]: The countdown is already activated!");
    if(amount > 10 || amount <= 0) return SendClientMessage(playerid, 0xDDDDDDFF, "[{FF0000}ERROR{DDDDDD}]: The amount can't be greater than 10.");
    CountTimer = SetTimerEx("Count", 1000, true, "i", playerid);
    CountAmmount = amount;
    IsCountActive = 1;
    return 1;
}
Reply
#2

Bump.
Reply
#3

place the count-- above the loop
Reply
#4

pawn Код:
public Count(playerid){
    if(!IsCountActive){
        KillTimer(CountTimer);
    }else{
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        CountAmmount--;//place it here so it won't loop the count values
        foreach(Player, i){
            if(IsPlayerInRangeOfPoint(i, 30, x, y, z)){
                new string[4];
                format(string,sizeof(string),"%i",CountAmmount);
                GameTextForPlayer(i,string,1000,3);                
                if(CountAmmount == -1) {
                    IsCountActive = 0, GameTextForPlayer(i,"~g~~h~Go!",1000,3);
                }
            }
        }
    }
    return 1;
}
Reply
#5

fixed already, anyway thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)