Author Topic: READ THIS: Note about SetTimer  (Read 5280 times)

0 Members and 1 Guest are viewing this topic.

Offline stormeus

  • VC:MP Developer
  • VC:MP Veteran
  • *
  • Posts: 1122
    • View Profile
READ THIS: Note about SetTimer
« on: January 11, 2013, 02:57:35 pm »
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.
« Last Edit: January 13, 2013, 07:41:12 pm by stormeus »
Do not PM me for support.