SA-MP Forums Archive
SetTimer problem? - 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 problem? (/showthread.php?tid=278909)

Pages: 1 2


SetTimer problem? - Tigerbeast11 - 24.08.2011

SetTimer doesn't work!

Under OnGameModeInIt()
pawn Code:
SetTimer("Timers",1000,1);
pawn Code:
forward Timers();
public Timers()
{
    printf("testing...");
    /*if(GameMinutes > 0 || GameSeconds > 0)
    {
        GameSeconds--;
        if(GameSeconds == -1)
        {
            GameMinutes--;
            GameSeconds = 59;
        }
    }
    if(GameMinutes == 0 && GameSeconds == 0)
    {
        OnGameModeExit();
    }
    new tmpstr[50]; //Accommodate for string size
    format(tmpstr,sizeof(tmpstr),"%02d:%02d",GameMinutes,GameSeconds);
    TextDrawSetString(Timer,tmpstr);*/

    return 1;
}
But the timer doesn't run. It doesn't print "testing..." every second on the server host screen. What have I done wrong?


Re: SetTimer problem? - SmileyForCheat - 24.08.2011

it's not show in samp-server.exe


Re: SetTimer problem? - iMonk3y - 24.08.2011

I don't see any problem there... post the whole OnGameModeInit, maybe then we can figure out the problem.


Re: SetTimer problem? - =WoR=G4M3Ov3r - 24.08.2011

Remove the /* and the */


Re: SetTimer problem? - Tigerbeast11 - 24.08.2011

pawn Code:
public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Call Of Duty: 5");
   
    AddPlayerClass(285, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0); //Swats
    AddPlayerClass(286, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);//FBIs
   
    AddPlayerClass(104, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);//Ballas
    AddPlayerClass(106, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);//Groves
    AddPlayerClass(109, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);//Vagos
    AddPlayerClass(124, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);//Mafia
   
    Timer = TextDrawCreate(86.000000,427.000000,"15:00");
    TextDrawAlignment(Timer,2);
    TextDrawBackgroundColor(Timer,0x000000ff);
    TextDrawFont(Timer,3);
    TextDrawLetterSize(Timer,0.499999,2.000000);
    TextDrawColor(Timer,0xffffffff);
    TextDrawSetOutline(Timer,1);
    TextDrawSetProportional(Timer,1);
    TextDrawSetShadow(Timer,1);

    SetTimer("Timers",1000,1);
    return 1;
}
It doesn't say "testing..." in samp-server.exe or something


Re: SetTimer problem? - =WoR=G4M3Ov3r - 24.08.2011

Quote:
Originally Posted by Tigerbeast11
View Post
pawn Code:
public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Call Of Duty: 5");
   
    AddPlayerClass(285, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0); //Swats
    AddPlayerClass(286, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);//FBIs
   
    AddPlayerClass(104, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);//Ballas
    AddPlayerClass(106, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);//Groves
    AddPlayerClass(109, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);//Vagos
    AddPlayerClass(124, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);//Mafia
   
    Timer = TextDrawCreate(86.000000,427.000000,"15:00");
    TextDrawAlignment(Timer,2);
    TextDrawBackgroundColor(Timer,0x000000ff);
    TextDrawFont(Timer,3);
    TextDrawLetterSize(Timer,0.499999,2.000000);
    TextDrawColor(Timer,0xffffffff);
    TextDrawSetOutline(Timer,1);
    TextDrawSetProportional(Timer,1);
    TextDrawSetShadow(Timer,1);

    SetTimer("Timers",1000,1);
    return 1;
}
It doesn't say "testing..." in samp-server.exe or something
Keep this

PHP Code:
public Timers()
{
    
printf("testing..."); 



Re: SetTimer problem? - Tigerbeast11 - 24.08.2011

Quote:
Originally Posted by G4M3Ov3r
View Post
Keep this

PHP Code:
public Timers()
{
    
printf("testing..."); 
Sorry, what do you mean?


Re: SetTimer problem? - =WoR=G4M3Ov3r - 24.08.2011

Quote:
Originally Posted by Tigerbeast11
View Post
SetTimer doesn't work!

Under OnGameModeInIt()
pawn Code:
SetTimer("Timers",1000,1);
pawn Code:
forward Timers();
public Timers()
{
    printf("testing...");
    /*if(GameMinutes > 0 || GameSeconds > 0)
    {
        GameSeconds--;
        if(GameSeconds == -1)
        {
            GameMinutes--;
            GameSeconds = 59;
        }
    }
    if(GameMinutes == 0 && GameSeconds == 0)
    {
        OnGameModeExit();
    }
    new tmpstr[50]; //Accommodate for string size
    format(tmpstr,sizeof(tmpstr),"%02d:%02d",GameMinutes,GameSeconds);
    TextDrawSetString(Timer,tmpstr);*/

    return 1;
}
But the timer doesn't run. It doesn't print "testing..." every second on the server host screen. What have I done wrong?
You showed us what you had OnGameModeInit, Keep the printf you had under it.


Re: SetTimer problem? - Tigerbeast11 - 24.08.2011

Quote:
Originally Posted by G4M3Ov3r
View Post
You showed us what you had OnGameModeInit, Keep the printf you had under it.
I didn't have printf under OnGameModeInIt()

I had it under a callback. Here's what my script looks like:
pawn Code:
new GameMinutes = 14;
new GameSeconds = 59;
new Text:Timer;

public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Call Of Duty: 5");
   
    AddPlayerClass(285, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0); //Swats
    AddPlayerClass(286, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);//FBIs
   
    AddPlayerClass(104, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);//Ballas
    AddPlayerClass(106, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);//Groves
    AddPlayerClass(109, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);//Vagos
    AddPlayerClass(124, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);//Mafia
   
    Timer = TextDrawCreate(86.000000,427.000000,"15:00");
    TextDrawAlignment(Timer,2);
    TextDrawBackgroundColor(Timer,0x000000ff);
    TextDrawFont(Timer,3);
    TextDrawLetterSize(Timer,0.499999,2.000000);
    TextDrawColor(Timer,0xffffffff);
    TextDrawSetOutline(Timer,1);
    TextDrawSetProportional(Timer,1);
    TextDrawSetShadow(Timer,1);

    SetTimer("Timers",1000,true);
    return 1;
}

forward Timers();
public Timers()
{
    printf("testing...");
    if(GameMinutes > 0 || GameSeconds > 0)
    {
        GameSeconds--;
        if(GameSeconds == -1)
        {
            GameMinutes--;
            GameSeconds = 59;
        }
    }
    if(GameMinutes == 0 && GameSeconds == 0)
    {
        OnGameModeExit();
    }
    new tmpstr[50]; //Accommodate for string size
    format(tmpstr,sizeof(tmpstr),"%02d:%02d",GameMinutes,GameSeconds);
    TextDrawSetString(Timer,tmpstr);
    return 1;
}
The SetTimer function doesn't work though


Re: SetTimer problem? - =WoR=G4M3Ov3r - 24.08.2011

Quote:
Originally Posted by Tigerbeast11
View Post
I didn't have printf under OnGameModeInIt()

I had it under a callback. Here's what my script looks like:
pawn Code:
new GameMinutes = 14;
new GameSeconds = 59;
new Text:Timer;

public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Call Of Duty: 5");
   
    AddPlayerClass(285, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0); //Swats
    AddPlayerClass(286, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);//FBIs
   
    AddPlayerClass(104, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);//Ballas
    AddPlayerClass(106, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);//Groves
    AddPlayerClass(109, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);//Vagos
    AddPlayerClass(124, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);//Mafia
   
    Timer = TextDrawCreate(86.000000,427.000000,"15:00");
    TextDrawAlignment(Timer,2);
    TextDrawBackgroundColor(Timer,0x000000ff);
    TextDrawFont(Timer,3);
    TextDrawLetterSize(Timer,0.499999,2.000000);
    TextDrawColor(Timer,0xffffffff);
    TextDrawSetOutline(Timer,1);
    TextDrawSetProportional(Timer,1);
    TextDrawSetShadow(Timer,1);

    SetTimer("Timers",1000,true);
    return 1;
}

forward Timers();
public Timers()
{
    printf("testing...");
    if(GameMinutes > 0 || GameSeconds > 0)
    {
        GameSeconds--;
        if(GameSeconds == -1)
        {
            GameMinutes--;
            GameSeconds = 59;
        }
    }
    if(GameMinutes == 0 && GameSeconds == 0)
    {
        OnGameModeExit();
    }
    new tmpstr[50]; //Accommodate for string size
    format(tmpstr,sizeof(tmpstr),"%02d:%02d",GameMinutes,GameSeconds);
    TextDrawSetString(Timer,tmpstr);
    return 1;
}
The SetTimer function doesn't work though
Alright, put this under OnGameModeInit.

PHP Code:
printf("testing..."); 
For the SetTimer put it like this

PHP Code:
SetTimer("Timers",1000,false); // 1000 Miliseconds (1 second) 



Re: SetTimer problem? - =WoR=Varth - 24.08.2011

Put print inside your OnGameModeInit andd see whether your OnGameModeInit is called or not.


Re: SetTimer problem? - Tigerbeast11 - 24.08.2011

No, I want to test the timer. SetTimer doesn't work and I was checking to see why. My script so far should print "testing..." every second on the server.exe but it doesn't which means there is a probem with the timer.


Re: SetTimer problem? - =WoR=G4M3Ov3r - 24.08.2011

PHP Code:
public OnGameModeInit()
{
    print(
"Testing...");
    
SetTimer("message"1000false); // Set a timer of 1000 miliseconds (1 second)

Try this


Re: SetTimer problem? - Tigerbeast11 - 24.08.2011

I'm sorry, you are not understanding...

The SetTimer function doesn't initiate this call back:
pawn Code:
public Timers()
The timer doesn't trigger this function. Do you understand, or do you need me to explain a bit more?


Re: SetTimer problem? - iMonk3y - 24.08.2011

I've tested your code and everything is working fine...


Re: SetTimer problem? - Tigerbeast11 - 24.08.2011

Not for me


Re: SetTimer problem? - =WoR=G4M3Ov3r - 24.08.2011

Quote:
Originally Posted by iMonk3y
View Post
I've tested your code and everything is working fine...
So did I.


Re: SetTimer problem? - Generation-X - 24.08.2011

Post the whole script and we'll test it.

If it works, it's your problem now.


Re: SetTimer problem? - Tigerbeast11 - 24.08.2011

I send you a link in PM


Re: SetTimer problem? - =WoR=G4M3Ov3r - 24.08.2011

Quote:
Originally Posted by Tigerbeast11
View Post
I send you a link in PM
Do so.