AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   A way to update hud_list (https://forums.alliedmods.net/showthread.php?t=225955)

^SmileY 09-11-2013 10:45

A way to update hud_list
 
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(idHudList();
public 
client_putinserver(idHudList();
public 
client_infochanged(idHudList();
public 
client_disconnect(idHudList(); 

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;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.

HamletEagle 09-11-2013 12:05

Re: A way to update hud_list
 
Please give more details. What you want to update in the list ? Players online ?

^SmileY 09-11-2013 13:32

Re: A way to update hud_list
 
Quote:

Originally Posted by HamletEagle (Post 2032760)
Please give more details. What you want to update in the list ? Players online ?

Not, it is a simple hud list to show unready and ready players, i need a method to update the list without using a repeated set_task. and an forward to do this more efficiently.

The code is ok, it is only the method to update the hudlist.

akcaliberg 09-11-2013 18:12

Re: A way to update hud_list
 
Then, update it when someone got ready.

fysiks 09-11-2013 20:24

Re: A way to update hud_list
 
Generally, you should only update only when absolutely needed. If you are updating based on connected players then you update when someone connect or disconnects. If you are updating alive status, update when someone spawns or dies. Same logic applies here.

^SmileY 09-11-2013 22:47

Re: A way to update hud_list
 
Quote:

Originally Posted by fysiks (Post 2033013)
Generally, you should only update only when absolutely needed. If you are updating based on connected players then you update when someone connect or disconnects. If you are updating alive status, update when someone spawns or dies. Same logic applies here.

Yeah it is the point, the hudlist maybe updated on certain events. If have some forward to do this more gracefully like an client send any command to server or make some action.

Thanks.

ConnorMcLeod 09-12-2013 01:02

Re: A way to update hud_list
 
Problem doing this, if this is for a public server, is that you can't control which additional plugins are installed on server, so you can't prevent plugins from overwriting your messages.
That's why it is better to loop the message with like a 1.0 interval, it won't affect server performances in any significant way and you can make sure message is displayed.

^SmileY 09-12-2013 08:45

Re: A way to update hud_list
 
Quote:

Originally Posted by ConnorMcLeod (Post 2033073)
Problem doing this, if this is for a public server, is that you can't control which additional plugins are installed on server, so you can't prevent plugins from overwriting your messages.
That's why it is better to loop the message with like a 1.0 interval, it won't affect server performances in any significant way and you can make sure message is displayed.

Thanks for the info.
But in my server i only was using one plugin to send hudmessages (Sorry, i not using any amxx default plugins.)

And in instead of using an set_task it have some other event to do this? like register_forward(FM_Think)

or FM_ClientThink?

Thanks.

akcaliberg 09-12-2013 09:18

Re: A way to update hud_list
 
Think forward is the worst way to show a hudmessage.

^SmileY 09-12-2013 09:38

Re: A way to update hud_list
 
Quote:

Originally Posted by akcaliberg (Post 2033201)
Think forward is the worst way to show a hudmessage.

Reason? Because? Do not speak any if you not have sure or an reason.

Im talking about FM_Think called by server (I guess) , not FM_ClientThink


All times are GMT -4. The time now is 18:46.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.