VC:MP 0.3 > mIRC/pawn Scripting

READ THIS: Note about SetTimer

(1/1)

stormeus:
Anyone who implements timers like this:
[pawn]
public OnPlayerCommandText( player, cmdtext[] )
{
   if(strcmp(cmdtext, "heal", true) == 0)
   {
      SetTimer("healplayer", 5000, 1);
      return 1;
   }
   return 0;
}
public healplayer(playerid)
{
   SetPlayerHealth( playerid, 100.0 );
   return 1;
}
[/pawn]

This will not work for anyone but player ID #0.

You cannot pass an argument to a timer in VC:MP 0.3z r2 unless you use the Squirrel server, which we do not officially support at this time. Trying to do so will cause Pawn to reset the argument to 0 every time, and will only heal players with ID #0.

Posting code like that as a solution may lead to your post being removed depending on the moderator because the code does not work, and is therefore not valid for this board.

Q: But why do people post it then?
A: Players who test this code by themselves will usually be the only people in their servers, and will end up with ID #0 as a result. It looks like it works all the time, so they use that code. However, if two players were to test the code, and ID #1 were to try to heal, only ID #0 would be affected.

Navigation

[0] Message Index

Go to full version