Question about OnPlayerUpdate
#1

Hi, i have question about OnplayerUpdate callback

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

bump
Reply
#3

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.
Reply
#4

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 ?
Reply
#5

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.
Reply
#6

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?
Reply
#7

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

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);
  }
}
Reply
#9

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


Forum Jump:


Users browsing this thread: 2 Guest(s)