SA-MP Forums Archive
OnplayerUpdate alternative? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: OnplayerUpdate alternative? (/showthread.php?tid=175533)



OnplayerUpdate alternative? - DarrenReeder - 10.09.2010

Hello,

i read over the bad points of onplayerupdate...so i created my own function "playerUpdate()"...so if i use this function whenever you disconnect (for that player ONLY) and every 5 minutes (for whole server) will that be okay instead of using onplayerupdate?

thanks for help


Re: OnplayerUpdate alternative? - cessil - 10.09.2010

yes, that's fine the thing with OnPlayerUpdate is that it's called ~40times a second depends what you need it for every 5 minutes should be fine


Re: OnplayerUpdate alternative? - Voldemort - 10.09.2010

You should use something like this, if you don't use already ^^

pawn Код:
forward PlayerUpdate();

OnGameModeInit()
{
    SetTimer("PlayerUpdate",1000,1);
}
public PlayerUpdate()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            //Do something here
        }
    }
}



Re: OnplayerUpdate alternative? - iggy1 - 10.09.2010

I was wondering would it be better to use 'GetTickCount' in onplayerupdate to update a mode, eg,
pawn Код:
new UpdateTime;
pawn Код:
UpdateTime = GetTickCount() + 120000;//gm/fs init
pawn Код:
public OnPlayerUpdate(playerid)
{
    if(GetTickCount() > UpdateTime)
    {
        //mode update stuff here
       
        UpdateTime = GetTickCount() + 120000;
    }
    return 1;
}
Or would that be worse/less efficient than using a repeating timer?

ps, Sorry if its a bit offtopic.