Timer :P
#1

I know that's easy but I am new to pawno :P
How do I turn this:
Код:
	if (strcmp(cmd, "/cd", true) == 0)
	{
		if(PlayerInfo[playerid][pAdmin] < 3) return DenyMessage(playerid, 3);
		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp)) return SendClientMessage(playerid,COLOR_WHITE,"/countdown [seconds] [freeze 1/0]");
		cd_sec = strval(tmp);
		if(cd_sec < 0||cd_sec >1000) return SendClientMessage(playerid,COLOR_WHITE,"SERVER: Seconds between 0-1000");
		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp)) return SendClientMessage(playerid,COLOR_WHITE,"/countdown [seconds] [freeze 1/0]");
		cd_f = strval(tmp);
		if(cd_f < 0 || cd_f > 1) return SendClientMessage(playerid,COLOR_WHITE,"/countdown [seconds] [freeze 1/0]");
		if(cd_f == 1)
		for(new i=0;i<MAX_PLAYERS;i++)
		{
			if(IsPlayerConnected(i))
				TogglePlayerControllable(i, 0);
		}
		cd_timer = SetTimer("countdown",1000,3);
		return 1;
  }
To: When timer is counting down then no one can use it again while it's counting.
Help please
Reply
#2

pawn Код:
new Counting;
pawn Код:
if (strcmp(cmd, "/cd", true) == 0)
    {
        if(Counting == 1) return SendClientMessage(playerid,COLOR_WHITE,"Can't do that!");
        if(PlayerInfo[playerid][pAdmin] < 3) return DenyMessage(playerid, 3);
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) return SendClientMessage(playerid,COLOR_WHITE,"/countdown [seconds] [freeze 1/0]");
        cd_sec = strval(tmp);
        if(cd_sec < 0||cd_sec >1000) return SendClientMessage(playerid,COLOR_WHITE,"SERVER: Seconds between 0-1000");
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) return SendClientMessage(playerid,COLOR_WHITE,"/countdown [seconds] [freeze 1/0]");
        cd_f = strval(tmp);
        if(cd_f < 0 || cd_f > 1) return SendClientMessage(playerid,COLOR_WHITE,"/countdown [seconds] [freeze 1/0]");
        if(cd_f == 1)
        for(new i=0;i<MAX_PLAYERS;i++)
        {
            if(IsPlayerConnected(i))
            TogglePlayerControllable(i, 0);
        }
        cd_timer = SetTimer("countdown",1000,3);
        Counting = 1;
        return 1;
    }
Reply
#3

Quote:
Originally Posted by MadeMan
pawn Код:
new Counting;
pawn Код:
if (strcmp(cmd, "/cd", true) == 0)
    {
        if(Counting == 1) return SendClientMessage(playerid,COLOR_WHITE,"Can't do that!");
        if(PlayerInfo[playerid][pAdmin] < 3) return DenyMessage(playerid, 3);
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) return SendClientMessage(playerid,COLOR_WHITE,"/countdown [seconds] [freeze 1/0]");
        cd_sec = strval(tmp);
        if(cd_sec < 0||cd_sec >1000) return SendClientMessage(playerid,COLOR_WHITE,"SERVER: Seconds between 0-1000");
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) return SendClientMessage(playerid,COLOR_WHITE,"/countdown [seconds] [freeze 1/0]");
        cd_f = strval(tmp);
        if(cd_f < 0 || cd_f > 1) return SendClientMessage(playerid,COLOR_WHITE,"/countdown [seconds] [freeze 1/0]");
        if(cd_f == 1)
        for(new i=0;i<MAX_PLAYERS;i++)
        {
            if(IsPlayerConnected(i))
            TogglePlayerControllable(i, 0);
        }
        cd_timer = SetTimer("countdown",1000,3);
        Counting = 1;
        return 1;
    }
Thanks but I also had to add in
Код:
public countdown(playerid) , this counting = 0;
Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)