SA-MP Forums Archive
SetTimer's not working - 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: SetTimer's not working (/showthread.php?tid=255757)



SetTimer's not working - Biesmen - 17.05.2011

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.


Re: SetTimer's not working - Elka_Blazer - 17.05.2011

SendClientMessageToAll(-1, "ended");
-1 = ?



Re: SetTimer's not working - Biesmen - 17.05.2011

Edit Oops, wrong thread

-1 is not related to this problem.


Re: SetTimer's not working - Elka_Blazer - 17.05.2011

1 = ?
1 = to what ?!@$ ?



Re: SetTimer's not working - Biesmen - 17.05.2011

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.


Re: SetTimer's not working - Biesmen - 17.05.2011

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)


Re: SetTimer's not working - Sasino97 - 17.05.2011

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
}



Re: SetTimer's not working - Biesmen - 17.05.2011

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.


Re: SetTimer's not working - Sasino97 - 17.05.2011

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;
}



Re: SetTimer's not working - Biesmen - 17.05.2011

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.


Re: SetTimer's not working - Sasino97 - 17.05.2011

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;
}



Re: SetTimer's not working - Sasino97 - 17.05.2011

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


Re: SetTimer's not working - Biesmen - 17.05.2011

^ (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.


Re: SetTimer's not working - Sasino97 - 17.05.2011

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


Re: SetTimer's not working - Biesmen - 17.05.2011

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


Re: SetTimer's not working - playbox12 - 17.05.2011

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?


Re: SetTimer's not working - Sasino97 - 17.05.2011

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 ******??


Re: SetTimer's not working - Biesmen - 17.05.2011

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


Re: SetTimer's not working - playbox12 - 17.05.2011

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.


Re: SetTimer's not working - Biesmen - 17.05.2011

Edit: Please remove