SetTimer problem?
#1

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?
Reply
#2

it's not show in samp-server.exe
Reply
#3

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

Remove the /* and the */
Reply
#5

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
Reply
#6

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..."); 
Reply
#7

Quote:
Originally Posted by G4M3Ov3r
View Post
Keep this

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

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.
Reply
#9

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
Reply
#10

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) 
Reply
#11

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

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.
Reply
#13

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

Try this
Reply
#14

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?
Reply
#15

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

Not for me
Reply
#17

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

Post the whole script and we'll test it.

If it works, it's your problem now.
Reply
#19

I send you a link in PM
Reply
#20

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


Forum Jump:


Users browsing this thread: 2 Guest(s)