Countdown problem
#1

Well I got countdown problem. when person do /wcd it should count down but it stuck at 42. So here are scripts

Код:
new WCDVar = 4;
new WCDTimer;

CMD:wcd(playerid,params[])
{
	if(PlayerInfo[playerid][W] >= 1)
	{
	    for(new i = 0; i < MAX_PLAYERS; i++)
        if(PlayerInfo[i][W] >= 1) {
	    WCDTimer = SetTimer("WCD", 1000, true);
	    } return CMDMessageToW(playerid,"WCountDown");
	}
	return 1;
}

forward WCD();
public WCD()
{
     WCDVar--;
     new str[128];
     if(WCDVar == 0)
     {
            KillTimer(WCDTimer);
            WCDVar = 4;
     }
     else
     {
     
           format(str, sizeof(str), "%d", WCDTimer);
           GameTextForAll(str, 1000, 6);
     }
     return 1;
}
Thank you for help
Reply
#2

Do you want it to count for that player only or all players on the server?
Reply
#3

Quote:
Originally Posted by Arbico
Посмотреть сообщение
Do you want it to count for that player only or all players on the server?
To all players with W rank. But it isnt problem. Just need solution how to make it counts down. Not to be stuck at 42.
Reply
#4

Bump
Reply
#5

Cmon guys
Reply
#6

Код:
  format(str, sizeof(str), "%d", WCDTimer);
You're showing WCDTimer for the cooldown instead of WCDVar. This is most likely your problem but there are more than one errors in your code. For example:

You're using GameTextForAll but in the command you check for specific players. Your codes redundant and half of it is irrelevant.

Make WCDTimer a player variable.
PHP код:
new WCDTimer[MAX_PLAYERS]; 
Instead of SetTimer, we'll use SetTimerEx to define the players.
PHP код:
CMD:wcd(playeridparams[])
{
      if (!
PlayerInfo[playerid][W])
         return 
SendClientMessage(playerid, -1"You don't have permission to use this.");
      for (new 
0MAX_PLAYERSi++){
          if (
PlayerInfo[i][W]){
               
WCDTimer[i] = SetTimerEx("WCD"1000,  true"i"i);
          }
      }
      
CMDMessageToW(playerid"WCountDown");
      return 
1;

Change your public function:
PHP код:
public WCD(playerid)
{
     
WCDVar--; 
     new 
str[60]; 
     if(
WCDVar == 0)
     {
          
KillTimer(WCDTimer[playerid]);
          
WCDVar 4;
     }
     else
     {
         
format (strsizeof(str), "%d"WCDVar);
         
GameTextForPlayer(playeridstr30006);
     }
     return 
1;

Reply
#7

Quote:
Originally Posted by Arthur Kane
Посмотреть сообщение
Код:
  format(str, sizeof(str), "%d", WCDTimer);
You're showing WCDTimer for the cooldown instead of WCDVar. This is most likely your problem but there are more than one errors in your code. For example:

You're using GameTextForAll but in the command you check for specific players. Your codes redundant and half of it is irrelevant.

Make WCDTimer a player variable.
PHP код:
new WCDTimer[MAX_PLAYERS]; 
Instead of SetTimer, we'll use SetTimerEx to define the players.
PHP код:
CMD:wcd(playeridparams[])
{
      if (!
PlayerInfo[playerid][W])
         return 
SendClientMessage(playerid, -1"You don't have permission to use this.");
      for (new 
0MAX_PLAYERSi++){
          if (
PlayerInfo[i][W]){
               
WCDTimer[i] = SetTimerEx("WCD"1000,  true"i"i);
          }
      }
      
CMDMessageToW(playerid"WCountDown");
      return 
1;

Change your public function:
PHP код:
public WCD(playerid)
{
     
WCDVar--; 
     new 
str[60]; 
     if(
WCDVar == 0)
     {
          
KillTimer(WCDTimer[playerid]);
          
WCDVar 4;
     }
     else
     {
         
format (strsizeof(str), "%d"WCDVar);
         
GameTextForPlayer(playeridstr30006);
     }
     return 
1;

Will try it tonight, hope it will work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)