Vice City Multiplayer

VC:MP 0.3 => mIRC/pawn Scripting => Topic started by: Fuzzy168 on August 12, 2011, 05:07:18 am

Title: Set timer help please..!!
Post by: Fuzzy168 on August 12, 2011, 05:07:18 am
How do i put a timer for a player? i can't do it using settimer..
Title: Re: Set timer help please..!!
Post by: yazeen on August 12, 2011, 04:15:21 pm
its not settimer its SetTmer

ok now its for making a function run after the given time example:

pawn]USAGE: SetTimer(funcname[],interval,repeating);[/pawn]

lets make a timer heal for example

[pawn]stock PlayerHealth()
{
SetPlayerHealth(playerid,100);
}

[/pawn]

the command:
   [pawn]else if (strcmp(cmd, "!heal", true) == 0) {
              SetTimer("PlayerHealth",5000,0); // PlayerHealth function will be submitted after 5seconds
               SendCleintMessage(playerid, GREEN,"You will be healed in 5seconds to prevent abuse..");
              }
       return 1;
    }[/pawn]

ok now lets learn the usage of each function:

SetTimer(funcname[],interval,repeating);


funcname[] : the name of the function that should be submitted
interval: how much time you wait for the function to start
repeating: how many times repeating if we put 0 just once if 1 never endz...

and the counts of the timers = 1000 = 1second 10000 = 10sec 60000 = 1min etc..

example2:

if you want the player not to die

add this function

[pawn]else if (strcmp(cmd, "!neverdiel", true) == 0) {
              SetTimer("neverdie",5000,1); // now the player will be healed every 5 seconds
               SendCleintMessage(playerid, GREEN,"You used neverdie function..");
              }
       return 1;[/pawn]

[pawn]stock neverdie()
{
SetPlayerHealth(playerid,100);
}
[/pawn]

Hope it helps
Title: Re: Set timer help please..!!
Post by: Fuzzy168 on August 12, 2011, 04:20:50 pm
Ok thanks. That's what just I need.
Title: Re: Set timer help please..!!
Post by: stormeus on August 12, 2011, 06:15:58 pm
That wouldn't work in Pawn, though.
[pawn]
SetTimer("PlayerHealth",5000,0);
[/pawn]
[pawn]
stock PlayerHealth()
{
SetPlayerHealth(playerid,100);
}
[/pawn]
Where is it getting playerid from?
Title: Re: Set timer help please..!!
Post by: Fuzzy168 on August 12, 2011, 07:06:55 pm
What is wrong with that script?
Title: Re: Set timer help please..!!
Post by: BIG[H] on August 12, 2011, 11:08:02 pm
rofl epic fail

should use first get all players and extract one from them by using array's

yazeen thats for squirrel and in squirrel timer you have to include playerid in timer function too...
Title: Re: Set timer help please..!!
Post by: yazeen on August 13, 2011, 07:57:36 am
rofl epic fail

should use first get all players and extract one from them by using array's

yazeen thats for squirrel and in squirrel timer you have to include playerid in timer function too...

lol i am scripting in pawno after 2-3 months i really forgot gPlayers[playerid], format, etc...(due to squirrel)
Title: Re: Set timer help please..!!
Post by: kitt85711 on September 01, 2011, 04:58:43 am
I need help making a timer for the commands /c cuff and /c taze I tried but i failed so bad :( I want the taze to be 5 seconds so for instance if i taze someone they cant move for 5 secs if you get cuffed i want it to auto uncuff you in 30 secs for anti abuse.plz help :(