Vice City Multiplayer

VC:MP => mIRC/pawn Scripting => Topic started by: Robd on February 03, 2011, 03:40:45 PM

Title: [Pawn]Timers
Post by: Robd on February 03, 2011, 03:40:45 PM
Timer's have been giving me a lot of syntax errors, could someone please explain the criteria for a timer to work?
Title: Re: [Pawn]Timers
Post by: [GCK]KoFFe on February 03, 2011, 10:44:46 PM
 :-\ like what any idea? could u gave us any script idea

Well timer don't works on

public bla(playerid)
{
Bla bla bla
}

which include playerid or else
it should be cleared like ()

public Whatever()
{
Never Mind
}

SetTimer("Whatever",5000,false);

Whatever is Variable that Runs 

and 5000 is Time settings 5000 = 5secs
and false thing is loop the timer you can use True/False or 1/0
Title: Re: [Pawn]Timers
Post by: Robd on February 03, 2011, 10:48:59 PM
sometimes when i do a function like

stock test()
{
    SendClientMessageToAll(COLOR_GREEN,"blablabla");
    ServerInfo[0][variable] = 1;
}

SetTimer("test",10000,0");

it gives me syntax errors
Title: Re: [Pawn]Timers
Post by: aXXo on February 04, 2011, 12:24:38 AM
Quote from: Robd on February 03, 2011, 10:48:59 PM
sometimes when i do a function like

stock test()
{
    SendClientMessageToAll(COLOR_GREEN,"blablabla");
    ServerInfo[0][variable] = 1;
}

SetTimer("test",10000,0");  //<----- This line

it gives me syntax errors
Theres a syntax error in the line i specified.
It should be:
SetTimer("test",10000,false);

true means timer runs infinite times...
false means timer runs only one time.
Integers have no effect in the 3rd parameter, it runs infinite times if u put integers.....better use true/false
Title: Re: [Pawn]Timers
Post by: [GCK]KoFFe on February 04, 2011, 11:00:07 AM
use Public instead of stock


Quotestock test()
{
    SendClientMessageToAll(COLOR_GREEN,"blablabla");
    ServerInfo[0][variable] = 1;
}

SetTimer("test",10000,0");  //

To
Quote
public test()
{
    SendClientMessageToAll(COLOR_GREEN,"blablabla");
    ServerInfo[0][variable] = 1;
}

SetTimer("test",10000,0");  //
Title: Re: [Pawn]Timers
Post by: Robd on February 04, 2011, 10:32:04 PM
Thank you  :)

One more question, sometimes when using timers with variables like

public test(playerid);
{
    PlayerInfo[playerid][test] = 1;
}

I get the same errors, is there anything i can do to avoid that?
Title: Re: [Pawn]Timers
Post by: aXXo on February 05, 2011, 02:35:55 AM
You cannot pass parameters in functions when using timers.

It has to be:
public test()
{
...
return 1;
}

For using timers applicable only on certain variables you have to use SetTimerEx, which doesnt exists in VCMP.
Title: Re: [Pawn]Timers
Post by: [GCK]KoFFe on February 05, 2011, 08:56:26 AM
Quotewhich doesnt exists in VCMP.
XD ;D
Title: Re: [Pawn]Timers
Post by: Robd on February 05, 2011, 05:30:50 PM
hmmm, glad i figured out a solution for this...
if anyone's interested i have an idea that would include using ServerInfo before the timer and then reading that in the actual function for later use...
Title: Re: [Pawn]Timers
Post by: heekz.shadow on February 10, 2011, 07:52:39 AM
aXXo...you made it with playerid...Why just dont help him with playerid at timers?