Question with OnPlayerUpdate
#1

Hello, I have 1 question. I want to use this on OnPlayerUpdate:

pawn Код:
public OnPlayerUpdate(playerid)
{
     new weaponid = GetPlayerWeapon(playerid);
     new ammo = GetPlayerAmmo(playerid);
     if(ammo !- lastammo[playerid])
     {
          OnPlayerChangeAmmo(playerid,oldammo,newammo,weaponid);
          lastammo[playerid] = ammo;
     }
     return 1;
}
Because OnPlayerUpdate gets called many times, is it possible that my callback OnPlayerChangeAmmo will be called on next player update, but wouldn't ended on the last ? Because earlier i had a bug with familiar script.
Reply
#2

I dont understand what you meant by saying: "... will be called on next player update, but wouldnt ended on the last one ..." ?

PS. Gal geriau lietuviškai pasakyk.
Reply
#3

Quote:
Originally Posted by Universal
Посмотреть сообщение
I dont understand what you meant by saying: "... will be called on next player update, but wouldnt ended on the last one ..." ?

PS. Gal geriau lietuviљkai pasakyk.
Nu per pirma update bus issauktas OnPlayerChangeAmmo ir prasidejus kitam update jis wel bus issauktas. Tai ar gali but kad dar nebus pasibaiges OnPlayerChangeAmmo visas perskaitymas sename patikrinime (nes kadangi OnPlayerUpdate yra issaukiamas labai daznai)?
Reply
#4

Quote:
Originally Posted by BuLLeT[LTU]
Посмотреть сообщение
Nu per pirma update bus issauktas OnPlayerChangeAmmo ir prasidejus kitam update jis wel bus issauktas. Tai ar gali but kad dar nebus pasibaiges OnPlayerChangeAmmo visas perskaitymas sename patikrinime (nes kadangi OnPlayerUpdate yra issaukiamas labai daznai)?
Tada gali padaryti taip pries tos funkcijos issaukima:
pawn Код:
if(GetPVarInt(playerid, "function") != 1)
{
      // issauk ta funkcija
}
O pacioje funkcijoje gali:
pawn Код:
stock Funkcija(playerid)
{
         SetPVarInt(playerid, "function", 1);
         // ta visa funkcija

         // kai funkcija baigiasi:
         SetPVarInt(playerid, "function", 0);
}
Reply
#5

O tau nera buve kad skaitytu funkcijos koda ne is eiles? pvz yra 4 eilutes ir perskaito koda: 3 2 4 1 eilutemis o ne is eiles (del lag) ?
Reply
#6

This is NOT Languages section.
Reply
#7

Quote:
Originally Posted by Jafet_Macario
Посмотреть сообщение
This is NOT Languages section.
Sorry.
Reply
#8

PAWN scripts are single-threaded.
This means that when your callback is running, the server won't fire any other callbacks. When your callback is done, it does everything again (sync, for example).
This is why if you put a large code in OnPlayerUpdate, your server will lag.
Reply
#9

Quote:
Originally Posted by BuLLeT[LTU]
Посмотреть сообщение
O tau nera buve kad skaitytu funkcijos koda ne is eiles? pvz yra 4 eilutes ir perskaito koda: 3 2 4 1 eilutemis o ne is eiles (del lag) ?
No, functions are read from the first line to last. Otherwise, it would have no sense...
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)