Cooldown
#1

I have made my sweeper job, and I have made something like "cooldown", and I have problems.
On my last cp i have add this:
Код:
DownSweeper[playerid] = 1;
SetTimer("CoolSweeper", 3600000, false);
And I have public for "CoolSweeper":
Код:
public CoolSweeper()
{
    DownSweeper[playerid] = 0;//This is line 27049
}
And I have this error:
Код:
(27049) : error 017: undefined symbol "playerid"
What is problem.
And how can I make something like /sweepagain, than server send message to player like "You have 37 minutes left".
Reply
#2

You don't have the variable playerid when you don't are in any callback, make it:

pawn Код:
DownSweeper[MAX_PLAYERS] = 1;
SetTimer("CoolSweeper", 3600000, false);
If you want everyone to have their own cooldown, i don't realy understand your function that gets called by the timer, and what more you want to do, could you describe more? :S
Reply
#3

When you have a public with no playerid in it, the function you create inside it will not define what you wrote, in this case DownSweeper[playerid]
Use the "foreach.inc" it solves your problems..

Search it.
Reply
#4

Quote:
Originally Posted by Ranama
Посмотреть сообщение
You don't have the variable playerid when you don't are in any callback, make it:
If you want everyone to have their own cooldown, i don't realy understand your function that gets called by the timer, and what more you want to do, could you describe more? :S
When player enter last CP, server give him "cooldown"
Код:
SetTimer("CoolSweeper", 3600000, false);
And he can't sweep until Cooldown is finished(Timer), and he can sweep again.
Reply
#5

forward CoolSweeper(playerid);
public CoolSweeper(playerid)
{
DownSweeper[playerid] = 0;//This is line 27049
}
Reply
#6

You just need to use SetTimerEx
pawn Код:
//change
SetTimer("CoolSweeper", 3600000, false);
//to
SetTimerEx("CoolSweeper", 3600000,false, "i", playerid);
Then in your function
pawn Код:
public CoolSweeper(playerid)//add playerid cause the timer passes that param
{
    DownSweeper[playerid] = 0;//This is line 27049
}
Reply
#7

Quote:
Originally Posted by NeverKnow
Посмотреть сообщение
forward CoolSweeper(playerid);
public CoolSweeper(playerid)
{
DownSweeper[playerid] = 0;//This is line 27049
}
Thanks, and how to make that /sweepagain thing. When player do that command it writes how many minutes is left?
Reply
#8

You need a different approach then, as you can't retrieve the time left on a timer. You need something like gettime(). Search for a couple of examples, I can't be bothered to type one out at the moment.
Reply
#9

Delete:
pawn Код:
DownSweeper[playerid] = 1;
SetTimer("CoolSweeper", 3600000, false);
and replace it with this:
pawn Код:
DownSweeper[playerid] = GetTickCount()+3600000;
Put this in the /sweepagain command you was talking about:
pawn Код:
if(DownSweeper[playerid] > GetTickCount())
{
    new string[60], time=DownSweeper[playerid]-GetTickCount();
    time/=1000, time/=60;
    if(time > 1)
        format(string,sizeof(string),"Please wait %d minutes before using this command again!", time);
    else if(time == 1)
        format(string,sizeof(string),"Please wait 1 minute before using this command again!");
    else
        format(string,sizeof(string),"Please wait a few seconds before using this command again!");
    SendClientMessage(playerid, 0xFF0000FF, string);
    return 1;
}
Also, you no longer need:
pawn Код:
public CoolSweeper()
{
    DownSweeper[playerid] = 0;
}
If you need to check if the cooldown is over or not, use this:
pawn Код:
if(DownSweeper[playerid] > GetTickCount())
Sorry if I made things confusing, but this way you don't need to use a timer, and can also see how long of the cooldown is remaining.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)