Hi modders, i need to check what a better solution to update an hud_list..
Actually i have this method:
PHP Code:
// plugin_init
register_event("ResetHUD","HudList","b");
// Other ways
public client_authorized(id) HudList();
public client_putinserver(id) HudList();
public client_infochanged(id) HudList();
public client_disconnect(id) HudList();
and this function:
PHP Code:
public HudList();
{
ReadyDisplay(999.0);
}
public ReadyDisplay(Float:fTime)
{
new szReady[1056],szNotReady[1056],szName[32];
new iPlayers[32],iNum,Players;
get_players(iPlayers,iNum,"ch");
new iReadys;
for(new i;i < iNum;i++)
{
Players = iPlayers[i];
get_user_name(Players,szName,charsmax(szName));
if(PUG_iReady[Players])
{
iReadys++;
formatex(szReady,charsmax(szReady),"%s%s^n",szReady,szName);
}
else formatex(szNotReady,charsmax(szNotReady),"%s%s^n",szNotReady,szName);
}
new iMinPlayers = get_pcvar_num(PUG_MinPlayers);
set_hudmessage(255,0,0,0.23,0.02,0,0.0,fTime,0.0,0.0,3);
show_hudmessage(0,"Not Ready (%d of %d):",PUG_GetPlayers() - iReadys,iMinPlayers);
set_hudmessage(0,255,0,0.58,0.02,0,0.0,fTime,0.0,0.0,2);
show_hudmessage(0,"Ready (%d of %d):",iReadys,iMinPlayers);
set_hudmessage(255,255,225,0.58,0.05,0,0.0,fTime,0.0,0.0,1);
show_hudmessage(0,szReady);
set_hudmessage(255,255,225,0.23,0.05,0,0.0,fTime,0.0,0.0,4);
show_hudmessage(0,szNotReady);
}
My doubt is: I need this to not use a repeated set_task, and really update list when player do some action..
It is sane and secure to replace all commands with register_forward(FM_Think,"HudList"); ?
I think have other ways to do this, when a forward called or player make some action.
Thanks.
__________________