SA-MP Forums Archive
Count problem. - 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)
+--- Thread: Count problem. (/showthread.php?tid=331836)



Count problem. - Bogdan1992 - 06.04.2012

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



Re: Count problem. - Bogdan1992 - 07.04.2012

Bump.


Re: Count problem. - Harish - 07.04.2012

place the count-- above the loop


Re: Count problem. - Harish - 07.04.2012

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



Re: Count problem. - Bogdan1992 - 07.04.2012

fixed already, anyway thanks.