SA-MP Forums Archive
Question about timer! - 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: Question about timer! (/showthread.php?tid=300903)



Question about timer! - ikbenremco - 02.12.2011

Look i want add a vip command that they can use /varmor every 30 mins but i dont know how to work with timers can someone help me ?



Quote:

CMD:varmor(playerid,params[]) {
if(Player[playerid][VipRank] >= 2) {
SetPlayerArmour(playerid, 100);
}
}




Re: Question about timer! - Neo Karls - 02.12.2011

pawn Код:
CMD:varmor(playerid, params[])
{
    new string[128], armor;
    if(sscanf(params, "d", armor))
    {
        SendClientMessageEx(playerid, COLOR_GRAD2, "USAGE: /varmor [health]");
        return 1;
    }
    if(Player[playerid][VipRank] >= 2)
    {
        SetPlayerArmour(playerid, armor);
        format(string, sizeof(string), "You have set your armor to %d.", armor);
        SendClientMessageEx(playerid, COLOR_WHITE, string);
    }
    return 1;
}



Re: Question about timer! - ikbenremco - 02.12.2011

Where's the timer?

I want it to work every 30 mins if you type command if you type command in that time You have to wait "" mins more to use this command


Re: Question about timer! - Neo Karls - 02.12.2011

If so, you have to use
pawn Код:
new viparmortimer
pawn Код:
new string[128];
    if(Player[playerid][VipRank] >= 2)
    {
        format(string, sizeof(string), "You must wait 30 minutes to use this command. ");
        SendClientMessageEx(playerid, COLOR_GREY, string);
        return 1;
    }
at first then
make a condition within the above script like

pawn Код:
if(Player[playerid][VipRank] >= 2)
    {
        viparmortimer[playerid] = 108000;
    }



Re: Question about timer! - ikbenremco - 02.12.2011

Can you maby put the last code in my code it wont work .. there is nothing what let the timer going down, None thing to start timer?


Re: Question about timer! - Neo Karls - 02.12.2011

hold on


Put
pawn Код:
new viparmortimer = 108000;
instead of

pawn Код:
new viparmortimer ;



Re: Question about timer! - ikbenremco - 02.12.2011

And again errors and nothing that trigger the timer..


Respuesta: Question about timer! - iKeN - 02.12.2011

pawn Код:
new bool:ArmourUsed[MAX_PLAYERS]; // Create bool..

// OnPlayerConnect
// ArmourUsed[playerid] = false;

CMD:varmor(playerid,params[])
{
   if(ArmourUsed[playerid] == false)
   {
      if(Player[playerid][VipRank] >= 2)
      {
         SetPlayerArmour(playerid, 100.0);
         ArmourUsed[playerid] = true;
         SetTimerEx("WaitTime", 60000*30, false, "i", playerid);
      }
   }
   else return SendClientMessage(playerid, -1, " Wait 30 min ");// you text
   return 1;
}

forward WaitTime(playerid);
public WaitTime(playerid)
{
    ArmourUsed[playerid] = false;
    return 1;
}