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



Timer :P - lionlev - 27.03.2010

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


Re: Timer :P - MadeMan - 28.03.2010

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



Re: Timer :P - lionlev - 28.03.2010

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