Can this OnPlayerUpdate cause lag?
#2

You can move stuff away from the main thing if you implement an OnPlayerWeaponChange callback.

pawn Код:
public OnPlayerUpdate(playerid)
{
    if(IsPlayerNPC(playerid)) return 1;

    // ----- Stuff that needs constant checking -----
   
    // ----- OnPlayerWeaponChange -----
    static
        oldWeapon[MAX_PLAYERS char];
    new
        newWeapon = GetPlayerWeapon(playerid);
       
    if(newWeapon != oldWeapon{playerid})
    {
        OnPlayerWeaponChange(playerid, newWeapon, oldWeapon{playerid});
        oldWeapon{playerid} = newWeapon;
        return 1;
    }

    // Rest of stuff
}
pawn Код:
public OnPlayerWeaponChange(playerid, newweapon, oldweapon)
{
    // check if newweapon = 38, 39 ...
    return 1;
}
As long as you're not doing loops or extensive calculations you should be fine.
Reply


Messages In This Thread
Can this OnPlayerUpdate cause lag? - by Tamer - 03.03.2013, 15:03
Re: Can this OnPlayerUpdate cause lag? - by Vince - 03.03.2013, 15:11
Re: Can this OnPlayerUpdate cause lag? - by Jstylezzz - 03.03.2013, 15:12
Re: Can this OnPlayerUpdate cause lag? - by Tamer - 03.03.2013, 15:52

Forum Jump:


Users browsing this thread: 1 Guest(s)