[HELP] Derby Timers..
#1

I'm trying to make a derby system based on signups, this is the code of the part in which i have problem:
pawn Код:
forward EventStart();
public EventStart()
{
    time++;
    if (time == 20 && active == 0)
    {
        SendClientMessageToAll(-1, ""YELLOW"[EVENT] {5DF0BF}Derby event has started! Type "YELLOW"/derby {5DF0BF}to sign up for the event!");
        active = 1;
        time = 0;
        SetTimer("SignUpAndDerbyStart", 1000, true);
    }
    return 1;
}

forward SignUpAndDerbyStart();
public SignUpAndDerbyStart()
{
    new str[128];
    t2++;
    if (t2 == 5 && active == 1)
    {
        if (totalplayers < 2) return SendClientMessageToAll(-1, ""YELLOW"[EVENT] {5DF0BF}Derby event has been cancelled due to lack of participants!");
        format(str, sizeof(str), ""YELLOW"[EVENT] {5DF0BF}Derby signups are now closed! Derby event is loading.. "REDORANGE"(Total participants: %d)", totalplayers);
        SendClientMessageToAll(-1, str);
        for (new i = 0; i < MAX_PLAYERS; i++)
        {
            if (IsPlayerConnected(i))
            {
                if (PlayerInfo[i][DerbySignUp] == 1)
                {
                    PlayerInfo[i][DerbySignUp] = 0;
                }
            }
        }
    }
    return 1;
}
active - if derby is active or not.
The SetTimer("SignUpAndDerbyStart", 1000, true); does not load, everything works correctly but when it comes to the SignUpAndDerbyStart function, nothing happens. I'm including a timer in a timer...(I think thats the problem). Can someone please help me to figure out the problem and tell me the solution?
Reply
#2

Need urgent help please.
Reply
#3

The only problem I see is if t2 is bigger than 4 if you start SignUpAndDerbyStart than the code will never proceed, you should set it to 0 in EventStart

Than you should kill the timer if the derby starts with KillTimer

And change your naming convention, every variable looks like a local
As example change time and active to, gDerbyTime and gDerbyActive than you know it is global and belongs to the derby
Reply
#4

t2 is time2, it is just another global variable to represent time. It increments and when its value (or the seconds) becomes 5 and if the EventStart forward/timer is active, it executes the rest of the code. I don't get what you mean by KillTimer and where should I place it..
And, thanks for that global variable name tip.

By time & t2, I mean seconds.
Reply
#5

The problem I were talking about was if t2 is bigger than 4 before the timer starts / it restarts

Lets say t2 starts by 0, the first time it will work couting till 5
But on the second run it is already five and the if check will never proceed

Also you need to add KillTimer at the end otherwise the SignUpAndDerbyStart timer will never stop to increase t2 each second
pawn Код:
new gDerbyTimer;
// EventStart
    gDerbyTimer = SetTimer("SignUpAndDerbyStart", 1000, true);
// SignUpAndDerbyStart
    if (/**/)
    {
        // CODE
        KillTimer(gDerbyTimer);
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)