Author Topic: Set timer help please..!!  (Read 3262 times)

0 Members and 1 Guest are viewing this topic.

Offline Fuzzy168

  • VC:MP Veteran
  • *****
  • Posts: 729
  • Programming since 2011
    • View Profile
Set timer help please..!!
« on: August 12, 2011, 05:07:18 am »
How do i put a timer for a player? i can't do it using settimer..
I'm beginning to feel like a Lag God, Lag God

yazeen

  • Guest
Re: Set timer help please..!!
« Reply #1 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

Offline Fuzzy168

  • VC:MP Veteran
  • *****
  • Posts: 729
  • Programming since 2011
    • View Profile
Re: Set timer help please..!!
« Reply #2 on: August 12, 2011, 04:20:50 pm »
Ok thanks. That's what just I need.
I'm beginning to feel like a Lag God, Lag God

Offline stormeus

  • VC:MP Developer
  • VC:MP Veteran
  • *
  • Posts: 1122
    • View Profile
Re: Set timer help please..!!
« Reply #3 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?
Do not PM me for support.




Offline Fuzzy168

  • VC:MP Veteran
  • *****
  • Posts: 729
  • Programming since 2011
    • View Profile
Re: Set timer help please..!!
« Reply #4 on: August 12, 2011, 07:06:55 pm »
What is wrong with that script?
I'm beginning to feel like a Lag God, Lag God

Offline BIG[H]

  • Made Man
  • ***
  • Posts: 159
  • Sight of light
    • View Profile
Re: Set timer help please..!!
« Reply #5 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...
Outdoor city server Administrator, FS server owner!

yazeen

  • Guest
Re: Set timer help please..!!
« Reply #6 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)

Offline kitt85711

  • Wiseguy
  • **
  • Posts: 72
    • View Profile
Re: Set timer help please..!!
« Reply #7 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 :(