SA-MP Forums Archive
Question about OnPlayerUpdate - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Question about OnPlayerUpdate (/showthread.php?tid=324440)



Question about OnPlayerUpdate - titanak - 09.03.2012

Hi, i have question about OnplayerUpdate callback

does OnPlayerUpdate strain a that player id or a server only or a both of them?


Re: Question about OnPlayerUpdate - titanak - 09.03.2012

bump


Re: Question about OnPlayerUpdate - AndreT - 09.03.2012

What do you mean "strain"? If I think I understand you correctly, you're thinking of the callback having an impact on the server performance.

The callback is fired quite often for each player. I don't have exact statistics to back it up, but the more things that a player does, the more often this callback gets called. If you have 100 players online, you must keep in mind the code is ran approximately 2000 times a second or even more. This is why very extensive code and heavy calculations should not be ran here.

It can be helpful for a number of things: detect health changes, detect weapon changes and so on.


Re: Question about OnPlayerUpdate - titanak - 10.03.2012

but something like this:

pawn Код:
#define MAX_TEST 4000

for(new s; s < MAX_TEST; s ++)
{
          // codee...
}
this will make very much lagg when is online like 20 players ?


Re: Question about OnPlayerUpdate - new121 - 15.03.2012

pawn Код:
public OnGameModeInit()
{
    SetTimer("TEST", 10000, true);// setting a timer that repeats every 10 seconds.
}

forward TEST();
public TEST()
{
      for(new s; s < MAX_TEST; s ++)
     {
          // codee...
     }
      return 1;
}
You may need to adjust the timers time depending on what you are trying to do but this will cause less "strain" aka lag.


Re: Question about OnPlayerUpdate - HeLiOn_PrImE - 26.03.2012

sorry for bumping this, but I would like to use this callback to check if players are armed (no weapons server). Is this recommended or not? And if it is, how can I check them for weapons?


Re: Question about OnPlayerUpdate - HuSs3n - 26.03.2012

if you wanna make no weapons server simply dont use giveplayerweaponz ....


Re : Question about OnPlayerUpdate - Vukilore - 26.03.2012

pawn Код:
public OnPlayerUpdate(playerid)
{
   if(GetPlayerWeapon(playerid) >= 1) // check if the player has one weapon (0 = no weapon)
  {
     SendClientMessage(playerid, -1,"Weapon Not Allowed On This Server");
     ResetPlayerWeapons(playerid);
  }
}



Re: Question about OnPlayerUpdate - HeLiOn_PrImE - 26.03.2012

Thank you.HuSs3n, I won't give weapons for sure, but some crapy people invented hacks for sa-mp.