SetTimer's not working
#1

Well, I'm having a weird problem.
My SetTimer isn't working at all. I've never had a problem with this before. I've been using Timers for a long time.

Here's the codes I am using to set timers:

pawn Код:
//OnGameModeInit
TheGame();
//
public TheGame()
{
    print("Going to EndGame"); // Yes it will print
    SetTimer("EndGame", 15000, false); // <- Doesn't work
    return 1;
}
//
public EndGame()
{
    SendClientMessageToAll(-1, "ended");
    SetTimer("ShowScores", 5000, false); // Nope.
    SetTimer("EndGame", 85000, false); // Nope.
    return 1;
}

public ShowScores(playerid)
{
    SetTimerEx("EndScores", 30000, false, "i", playerid); // Nope.
    SetTimerEx("SkipAbility", 15000, false, "i", playerid); // Nope.
    return 1;
}

public SkipAbility(playerid)
{
    SkipAbb[playerid] = 1;
    TextDrawShowForPlayer(playerid, PressKey);
    Seconds = 50;
    TheTimer = SetTimer("Countdown", 1000, true); // Nope.
    return 1;
}

public CountDown()
{
    print("The timer()");
    new string[15];
    if(Seconds == 0 && Minutes == 0)
    {
        KillTimer(TheTimer);
        TextDrawSetString(TimeDraw[1], "N/A");
        return 1;
    }
    Seconds--;
    return 1;
}
I don't get it why they're not working.
Reply
#2

SendClientMessageToAll(-1, "ended");
-1 = ?
Reply
#3

Edit Oops, wrong thread

-1 is not related to this problem.
Reply
#4

1 = ?
1 = to what ?!@$ ?
Reply
#5

Haha, wrong thread. Read my edit:
Your question is not related to my problem. -1 is just the "Color", in this case it's white. It has a lot more behind it, but search for it.
Reply
#6

Your question is not related to my problem. -1 is just the "Color", in this case it's white. It has a lot more behind it, but search for it.

Edit: I also tried to add the timers in a Filterscript and include, they both failed.

Edit2: Shit, I thought I edited my previous post. (Please remove my previous post, not this one)
Reply
#7

Error Number 1:

This is why there is the "forward" function...

pawn Код:
forward PublicName(arguments);
Error number 2:

SetTimer("ShowScores", time, 0); //Who's the playerid?
The compiler doesn't know who is him!! You should show the score to all players, so use for (i ...) etc

ShowScores(playerid) // -.-

pawn Код:
for(new i = 0; i<MAX_PLAYERS;i++)
{
  SetTimerEx("ShowScore", time, repeating, "i", i); //The same concept to all timers with arguments
}
Reply
#8

Quote:
Originally Posted by [GF]Sasino97
Посмотреть сообщение
This is why there is the "forward" function...


pawn Код:
forward PublicName(arguments);
Dude, as you can see those are "Publics". You can't use them if they are not forwarded.
Ofcourse they are forwarded.
Reply
#9

Quote:
Originally Posted by Biesmen
Посмотреть сообщение
Well, I'm having a weird problem.
My SetTimer isn't working at all. I've never had a problem with this before. I've been using Timers for a long time.

Here's the codes I am using to set timers:

pawn Код:
//OnGameModeInit
TheGame();
//
public TheGame()
{
    print("Going to EndGame"); // Yes it will print
    SetTimer("EndGame", 15000, false); // <- Doesn't work
    return 1;
}
//
public EndGame()
{
    SendClientMessageToAll(-1, "ended");
    SetTimer("ShowScores", 5000, false); // Nope.
    SetTimer("EndGame", 85000, false); // Nope.
    return 1;
}

public ShowScores(playerid)
{
    SetTimerEx("EndScores", 30000, false, "i", playerid); // Nope.
    SetTimerEx("SkipAbility", 15000, false, "i", playerid); // Nope.
    return 1;
}

public SkipAbility(playerid)
{
    SkipAbb[playerid] = 1;
    TextDrawShowForPlayer(playerid, PressKey);
    Seconds = 50;
    TheTimer = SetTimer("Countdown", 1000, true); // Nope.
    return 1;
}

public CountDown()
{
    print("The timer()");
    new string[15];
    if(Seconds == 0 && Minutes == 0)
    {
        KillTimer(TheTimer);
        TextDrawSetString(TimeDraw[1], "N/A");
        return 1;
    }
    Seconds--;
    return 1;
}
I don't get it why they're not working.
EDIT: TRY THIS

pawn Код:
//OnGameModeInit
TheGame();
//
public TheGame()
{
    print("Going to EndGame"); // Yes it will print
    SetTimer("EndGame", 15000, false); // <- Doesn't work
    return 1;
}
//
public EndGame()
{
    SendClientMessageToAll(-1, "ended");
        for(new i=0;i<MAX_PLAYERS;i++)
        {
        SetTimerEx("ShowScores", 5000, false, "i", i); // Nope.
        SetTimerEx("EndGame", 85000, false, "i", i); // Nope.
        }
    return 1;
}

public ShowScores(playerid)
{
    SetTimerEx("EndScores", 30000, false, "i", playerid); // Nope.
    SetTimerEx("SkipAbility", 15000, false, "i", playerid); // Nope.
    return 1;
}

public SkipAbility(playerid)
{
    SkipAbb[playerid] = 1;
    TextDrawShowForPlayer(playerid, PressKey);
    Seconds = 50;
    TheTimer = SetTimer("Countdown", 1000, true); // Nope.
    return 1;
}

public CountDown()
{
    print("The timer()");
    new string[15];
    if(Seconds == 0 && Minutes == 0)
    {
        KillTimer(TheTimer);
        TextDrawSetString(TimeDraw[1], "N/A");
        return 1;
    }
    Seconds--;
    return 1;
}
Reply
#10

Do you mean using the functions without "SetTimer"? I did that and then it works fine, but I need a timer ofcourse.

I also tried to reinstall SAMP Server.

@Sasino
Thanks for trying, but no. A loop is not the problem.
Reply
#11

Try to use the Sleep(ms)/Wait(ms) function:
This function will work as a timer, but when it's executed all functions in the server get paused.
pawn Код:
stock Sleep(ms)
{
  new t = tickcount();
  while(t-tickcount() < ms) { }
  return 1;
}
Reply
#12

0.o are you sure? I use it for very little times (Like 500 ms)
Reply
#13

^ (Pointed at ******)

So, does anyone else have any other idea how I can fix this problem. I cannot continue my GM if this won't get fixed. Weird bug, seriously. I think this is a SA:MP bug.
Reply
#14

Did you try the first solution I posted ? ? ? (for i loop) I think that's the real solution
Reply
#15

No, it doesn't even reach the loop. The SetTimer won't call any "custom callback" at all.
Reply
#16

Quote:
Originally Posted by [GF]Sasino97
Посмотреть сообщение
Did you try the first solution I posted ? ? ? (for i loop) I think that's the real solution
Even if the variable playerid was not filled with something, it will still process. Even if you were right, it won't to fix the problem of timers not working.

Ehrm, have you tried using the timers in a blanco gamemode, just something like LVDM, no plugins, no filterscripts?
Reply
#17

Quote:
Originally Posted by Biesmen
Посмотреть сообщение
No, it doesn't even reach the loop. The SetTimer won't call any "custom callback" at all.
No, It won't, but the (playerid) argument in that callback will be filled with 0, so it'll work with player ID 0...

Right ******??
Reply
#18

Quote:
Originally Posted by ******
Посмотреть сообщение
And have you tried doing what I suggested in my first post?
I asked if you mean, using those functions without a timer. I did that and then they work perfectly, but ofcourse I need a timer. If you mean something else, then what? :P
Reply
#19

Quote:
Originally Posted by [GF]Sasino97
Посмотреть сообщение
No, It won't, but the (playerid) argument in that callback will be filled with 0, so it'll work with player ID 0...

Right ******??
Thats exactly what I meant, he said he debugged it, hence it doesen't matter if the ID is 0 or not, it will still show it in the server window.
Reply
#20

Edit: Please remove
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)