Vice City Multiplayer

VC:MP 0.3 => mIRC/pawn Scripting => Topic started by: Aqeel on January 27, 2012, 04:52:35 pm

Title: Want add Timer in Commands
Post by: Aqeel 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]
Title: Re: Want add Timer in Commands
Post by: Black Eyed 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???
Title: Re: Want add Timer in Commands
Post by: omarlin97 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
Title: Re: Want add Timer in Commands
Post by: Fuzzy168 on January 28, 2012, 05:47:33 am
YOU CAN'T SET A TIMER TO A PERSON IN PAWN!!!!!!
Title: Re: Want add Timer in Commands
Post by: Black Eyed on January 28, 2012, 05:55:23 am
ROFLMAO  >:(

Code: [Select]
Yessss
Command repaired By Me

this comand have 0 errors.





Title: Re: Want add Timer in Commands
Post by: stormeus on January 28, 2012, 06:34:57 am
Okay then. Try running it, see how it doesn't work.
Title: Re: Want add Timer in Commands
Post by: Fuzzy168 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!!!
Title: Re: Want add Timer in Commands
Post by: Black Eyed on January 28, 2012, 02:44:27 pm
change time

SetTimer("TimeHealth",5000,0); // no repeat heal
Title: Re: Want add Timer in Commands
Post by: omarlin97 on January 28, 2012, 04:01:48 pm
Man Funtion repaired By Me
Title: Re: Want add Timer in Commands
Post by: stormeus on January 28, 2012, 07:32:05 pm
change time

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

Should be SetTimer( "TimeHealth", 5000, 1 );
Title: Re: Want add Timer in Commands
Post by: Fuzzy168 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 (http://vcmp.liberty-unleashed.co.uk/forum/index.php).
Title: Re: Want add Timer in Commands
Post by: RasikhQadeer 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  :-\
Title: Re: Want add Timer in Commands
Post by: Innocent Heart on January 30, 2012, 01:44:26 pm
Nice !
Title: Re: Want add Timer in Commands
Post by: Fuzzy168 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.
Title: Re: Want add Timer in Commands
Post by: Aldo on January 31, 2012, 05:48:22 am
This won't work
You cant pass variables thru SetTimer