Author Topic: Want add Timer in Commands  (Read 5869 times)

0 Members and 1 Guest are viewing this topic.

Offline Aqeel

  • Street Thug
  • *
  • Posts: 3
    • View Profile
Want add Timer in Commands
« on: January 27, 2012, 04:52:35 pm »
Hello all.
   i have just started a scripting
    so need somw help
        i  Want to add TIMER and FREEZE for commands !heal  and for all teleport commands like !fight etc
             i m adding a command here so u all see and change it
[pawn]
-------GOTO FIGHT AREA--------

 else if ( strcmp( cmd, "!fight", true ) == 0 )
   {
      SetPlayerPos(playerid,-974.17083,-839.76446,13.16437);
      ResetPlayerWeapons(playerid),
      SetPlayerWeapon(playerid, 20, 99999 );
      format(szMsg, 128, "%s gone to ArenaSpaz.",gPlayers[playerid]);
       SendClientMessageToAll( BLUE, szMsg );
      return 1;
   }

-------HEAL--------

{
       tmp = strtok(cmdtext, idx);
      SetPlayerHealth(playerid,100);
      SendClientMessage(playerid,0xAAAAAA,"Congrats you have 100% healed");
      return 1;
   } 
[/pawn]

Offline Black Eyed

  • Street Thug
  • *
  • Posts: 9
  • ..::Black_Eyed::..
    • View Profile
Re: Want add Timer in Commands
« Reply #1 on: January 27, 2012, 11:20:26 pm »
hmm


Code: [Select]
  }
    else if ( strcmp( cmd, "!Heal", true ) == 0 )
{
        new Float:Health; GetPlayerHealth( playerid, Health );
if ( Health >= 100 ) SendClientMessage( playerid, RED, "Error: You have 100" );
else {
SetTimer("TimeHealth",5000,0);
         SendClientMessage(playerid,ORANGE,"Wait 5 Secs..");

}
return 1;





//  Test
public TimeHealth(playerid)
{
SetPlayerHealth(playerid,100);
SendClientMessage(playerid,ORANGE,"You Have Healed ");
}




Work???
« Last Edit: January 28, 2012, 02:44:49 pm by Black Eyed »

Offline omarlin97

  • Street Thug
  • *
  • Posts: 41
  • Scripter The Server Pawno
    • View Profile
    • Dominican Server Latino
Re: Want add Timer in Commands
« Reply #2 on: January 27, 2012, 11:49:27 pm »
Code: [Select]
    else if ( strcmp( cmd, "!Heal", true ) == 0 )
{
        new Float:Health; GetPlayerHealth( playerid, Health );
if ( Health >= 100 ) SendClientMessage( playerid, RED, "Error: You have 100" );
else {
SetTimer("TimeHealth",5000,1);
         SendClientMessage(playerid,ORANGE,"Wait 5 Secs..");

}
return 1;
              }





//  Test
public TimeHealth(playerid)
{
SetPlayerHealth(playerid,100);
SendClientMessage(playerid,ORANGE,"You Have Healed ");
}




Yessss
Command repaired By Me
« Last Edit: January 27, 2012, 11:56:19 pm by omarlin97 »
Owner end creator the Server TDM

Dominican Server Latino
web site: http://dominicanserver.net16.net/

Offline Fuzzy168

  • VC:MP Veteran
  • *****
  • Posts: 729
  • Programming since 2011
    • View Profile
Re: Want add Timer in Commands
« Reply #3 on: January 28, 2012, 05:47:33 am »
YOU CAN'T SET A TIMER TO A PERSON IN PAWN!!!!!!
« Last Edit: January 28, 2012, 05:51:21 am by Fuzzy168 »
I'm beginning to feel like a Lag God, Lag God

Offline Black Eyed

  • Street Thug
  • *
  • Posts: 9
  • ..::Black_Eyed::..
    • View Profile
Re: Want add Timer in Commands
« Reply #4 on: January 28, 2012, 05:55:23 am »
ROFLMAO  >:(

Code: [Select]
Yessss
Command repaired By Me

this comand have 0 errors.






Offline stormeus

  • VC:MP Developer
  • VC:MP Veteran
  • *
  • Posts: 1122
    • View Profile
Re: Want add Timer in Commands
« Reply #5 on: January 28, 2012, 06:34:57 am »
Okay then. Try running it, see how it doesn't work.
Do not PM me for support.




Offline Fuzzy168

  • VC:MP Veteran
  • *****
  • Posts: 729
  • Programming since 2011
    • View Profile
Re: Want add Timer in Commands
« Reply #6 on: January 28, 2012, 06:35:32 am »
ROFLMAO  >:(

Code: [Select]
Yessss
Command repaired By Me

this comand have 0 errors.

It's not about whether there is any errors in the script. But whether the script will work in-game. In this case, IT WON'T WORK!!!
I'm beginning to feel like a Lag God, Lag God

Offline Black Eyed

  • Street Thug
  • *
  • Posts: 9
  • ..::Black_Eyed::..
    • View Profile
Re: Want add Timer in Commands
« Reply #7 on: January 28, 2012, 02:44:27 pm »
change time

SetTimer("TimeHealth",5000,0); // no repeat heal

Offline omarlin97

  • Street Thug
  • *
  • Posts: 41
  • Scripter The Server Pawno
    • View Profile
    • Dominican Server Latino
Re: Want add Timer in Commands
« Reply #8 on: January 28, 2012, 04:01:48 pm »
Man Funtion repaired By Me
Owner end creator the Server TDM

Dominican Server Latino
web site: http://dominicanserver.net16.net/

Offline stormeus

  • VC:MP Developer
  • VC:MP Veteran
  • *
  • Posts: 1122
    • View Profile
Re: Want add Timer in Commands
« Reply #9 on: January 28, 2012, 07:32:05 pm »
change time

SetTimer("TimeHealth",5000,0); // no repeat heal

Should be SetTimer( "TimeHealth", 5000, 1 );
Do not PM me for support.




Offline Fuzzy168

  • VC:MP Veteran
  • *****
  • Posts: 729
  • Programming since 2011
    • View Profile
Re: Want add Timer in Commands
« Reply #10 on: January 29, 2012, 07:51:22 am »
change time

SetTimer("TimeHealth",5000,0); // no repeat heal
Setting it to '0' will only make it INFINITY!!.. But I still think you shouldn't add a timer. If you still insist, try Squirrel.
I'm beginning to feel like a Lag God, Lag God

Offline RasikhQadeer

  • Street Thug
  • *
  • Posts: 49
  • Hero_Great! The Great Scripter!
    • View Profile
Re: Want add Timer in Commands
« Reply #11 on: January 30, 2012, 01:41:17 pm »
Well i have made a timer hea cmd but it wored for me fine with the timer also when i tried testing uit on 2 players the 1st one did heal then i did but i got my heal on my 3 secs whie the other got on his secs then it worked for me  :-\

Offline Innocent Heart

  • Wiseguy
  • **
  • Posts: 51
  • Crime Investigation Department Owner
    • View Profile
    • Crime Investigaton Department
Re: Want add Timer in Commands
« Reply #12 on: January 30, 2012, 01:44:26 pm »
Nice !
Conatact Information :
Facebook:-www.facebook.com/dashingjaff
Youtube:-www.youtube.com/NooranScripter

====>My Server Info  < ========
ServerName :- CID-Server
Server Clan :- [D.R] Dakriders
Server Forum :- www.CidServer.tk
Clan Forum :-www.Drgang.tk
=====> DarkRiders Group <=====

Pm Me If U want To be Pro In Scripting !
Those Who Banned my Ip and My Freind's Ip They Are Big Fuckers...!

Offline Fuzzy168

  • VC:MP Veteran
  • *****
  • Posts: 729
  • Programming since 2011
    • View Profile
Re: Want add Timer in Commands
« Reply #13 on: January 31, 2012, 05:33:46 am »
Well i have made a timer hea cmd but it wored for me fine with the timer also when i tried testing uit on 2 players the 1st one did heal then i did but i got my heal on my 3 secs whie the other got on his secs then it worked for me  :-\
The SetTimer function doesn't have an arg.. as an argument. So this means that the timer will run the function but it will ignore all arguments included in the function.

For example, the function is HealPlayer( plr ). The timer will ignore the plr and run everything else.

What I'm trying to say is, your timer won't work because you can't set it to a specific person.



And about your 3 seconds advantage. During the 5 seconds when a the timer is running the script, when another player types /c heal, the player will be automaticly be included in the timer. Thus having an advantage. Lets say 1 player typed /c heal. Then another person typed /c heal when the timer left 1/2 seconds left. That's an unfair advantage.
I'm beginning to feel like a Lag God, Lag God

Offline Aldo

  • Wiseguy
  • **
  • Posts: 52
    • View Profile
Re: Want add Timer in Commands
« Reply #14 on: January 31, 2012, 05:48:22 am »
This won't work
You cant pass variables thru SetTimer