Raised This Month: $ Target: $400
 0% 

A way to update hud_list


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 09-11-2013 , 10:45   A way to update hud_list
Reply With Quote #1

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.
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 09-11-2013 , 12:05   Re: A way to update hud_list
Reply With Quote #2

Please give more details. What you want to update in the list ? Players online ?
HamletEagle is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 09-11-2013 , 13:32   Re: A way to update hud_list
Reply With Quote #3

Quote:
Originally Posted by HamletEagle View Post
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.
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
akcaliberg
Senior Member
Join Date: Nov 2011
Location: Istanbul
Old 09-11-2013 , 18:12   Re: A way to update hud_list
Reply With Quote #4

Then, update it when someone got ready.
akcaliberg is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-11-2013 , 20:24   Re: A way to update hud_list
Reply With Quote #5

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.
__________________
fysiks is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 09-11-2013 , 22:47   Re: A way to update hud_list
Reply With Quote #6

Quote:
Originally Posted by fysiks View Post
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.
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-12-2013 , 01:02   Re: A way to update hud_list
Reply With Quote #7

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.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 09-12-2013 , 08:45   Re: A way to update hud_list
Reply With Quote #8

Quote:
Originally Posted by ConnorMcLeod View Post
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.
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
akcaliberg
Senior Member
Join Date: Nov 2011
Location: Istanbul
Old 09-12-2013 , 09:18   Re: A way to update hud_list
Reply With Quote #9

Think forward is the worst way to show a hudmessage.
akcaliberg is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 09-12-2013 , 09:38   Re: A way to update hud_list
Reply With Quote #10

Quote:
Originally Posted by akcaliberg View Post
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
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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