I need a timer
#1

Can somebody please have a script or can make a script for timer.

I have made a stat in /stats called : Cooldown
When i get a package or smth else it does this script :

PlayerInfo[playerid][pcooldown] = 10;

So i need timer what every 60 second does command or smth that takes off 1 point form Cooldown stats.
Sor for my bad english, i hope you understand.
Please help.
Reply
#2

i just need timer what is reloading it self at 60 seconds. please help.....
Reply
#3

Anybody ?
Reply
#4

Why bother using a timer when you can use gettime() or GetTickCount()

It's pretty simple

pawn Код:
// Define your specific cool down time
#define COOLTIME_SOMETHING 300 // 5 Minutes

// Use time of the cool down time for each player
new UseTime[MAX_PLAYERS]


// Used in any command/function to check and set a players cool down time
.......
if(gettime() - UseTime[playerid] > COOLTIME_SOMETHING)
{
    UseTime[playerid] = gettime();
    ......
}
See absolutely no need for timer.
Reply
#5

I made this :

forward Cooldowntimer(playerid, idx);
public Cooldowntimer(playerid, idx)
{
PlayerInfo[playerid][pcooldown] - 1;
return 1;
}


And to command i added this one :

SetTimer("cooldowntimer", 5000, true);


But its not working at all ;(
Reply
#6

Whay isn't this ->> PlayerInfo[playerid][pcooldown] - 1; <-- working ?
Reply
#7

BUUUMMMPPPP
Reply
#8

Quote:
Originally Posted by scout322
Посмотреть сообщение
Whay isn't this ->> PlayerInfo[playerid][pcooldown] - 1; <-- working ?
Because you're doing a calulation, but aren't saving the result anywhere. Correct is:
pawn Код:
PlayerInfo[playerid][pcooldown] = PlayerInfo[playerid][pcooldown] - 1;

// Or the shorthand version:
PlayerInfo[playerid][pcooldown] -= 1;

// Or even shorter:
PlayerInfo[playerid][pcooldown]--;
But do as Pottus said.
Reply
#9

Quote:
Originally Posted by scout322
Посмотреть сообщение
I made this :

forward Cooldowntimer(playerid, idx);
public Cooldowntimer(playerid, idx)
{
PlayerInfo[playerid][pcooldown] - 1;
return 1;
}


And to command i added this one :

SetTimer("cooldowntimer", 5000, true);


But its not working at all ;(
So, for other words, the function CoolDownTimer has 2 parameters, and you're simply trying to use that function without the parameters.
As well, you have the "idx" parameter, which isn't used in that function.
Try to use this:
pawn Код:
//// in the top of your gamemode
new Timer:CoolDown;
forward CoolDownTimer(playerid);
//// somewhere in your gamemode
public CoolDownTimer(playerid) {
     if(PlayerInfo[playerid][pcooldown] == 0) {
          KillTimer(CoolDown);
          return 1;
     }
     PlayerInfo[playerid][pcooldown]--;
     return 1;
}
//// On the command you want
CoolDown = SetTimerEx("CoolDownTimer", 5000, true, "i", playerid);
That should do the job.
Reply
#10

But how i can make that when player comes online, automaticly start the timer ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)