Raised This Month: $51 Target: $400
 12% 

Solved Hud update


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Point
Junior Member
Join Date: Oct 2014
Old 05-26-2019 , 20:03   Hud update
Reply With Quote #1

Hello! How can i do this? It doesn't update after the value is changed.

PHP Code:
public plugin_init()
{
        
g_iSyncHud CreateHudSyncObj();
        
set_task(0.1"Task_Display"TASK_SHOWPOINTS, .flags "b");
}

public 
Task_Display(id
{
    if(
m_iPoints[id] == 1)
    {
        
set_hudmessage(02040, -1.00.6800.00.10.010.0);
        
ShowSyncHudMsg(idg_iSyncHud "Points - (x) ()");
    } else if(
m_iPoints[id] == 2) {
        
set_hudmessage(02040, -1.00.6800.00.10.010.0);
        
ShowSyncHudMsg(idg_iSyncHud "Points - (x) (x)");
    } else {
                
set_hudmessage(02040, -1.00.6800.00.10.010.0);
        
ShowSyncHudMsg(idg_iSyncHud "Points - () ()");
       }


Last edited by Point; 06-18-2019 at 12:37.
Point is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 05-27-2019 , 07:34   Re: Hud update
Reply With Quote #2

what is your TASK_SHOWPOINTS ? i think you have a problem with indexes
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)
JocAnis is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 05-27-2019 , 09:14   Re: Hud update
Reply With Quote #3

Who is "id"? You're setting the task in plugin_init() with TASK_SHOWPOINTS as the "id", so if you're expecting it to be a player - it's not.
Also, you can use set_hudmessage just once before all the checks.
__________________

Last edited by OciXCrom; 05-27-2019 at 09:38.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 05-27-2019 , 09:33   Re: Hud update
Reply With Quote #4

No, "id" in his code will be the task Index.
__________________








CrazY. is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 05-27-2019 , 09:42   Re: Hud update
Reply With Quote #5

better put that set_task on client_putinserver + change ', TASK_SHOWPOINTS,' to ', TASK_SHOWPOINTS + id,' and then do quick math to find his index in your display function
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)

Last edited by JocAnis; 05-27-2019 at 09:42.
JocAnis is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-27-2019 , 10:14   Re: Hud update
Reply With Quote #6

Quote:
Originally Posted by JocAnis View Post
better put that set_task on client_putinserver + change ', TASK_SHOWPOINTS,' to ', TASK_SHOWPOINTS + id,' and then do quick math to find his index in your display function
No need to run 20+ tasks for a simple HUD message, 1 loop is enough.
__________________
<VeCo> is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 05-27-2019 , 11:02   Re: Hud update
Reply With Quote #7

but he is checking something related to player index: m_iPoints[id] == 1
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)
JocAnis is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 05-27-2019 , 11:50   Re: Hud update
Reply With Quote #8

That's why loop is needed. He can do both, set a single task and loop through players or set a task per player once they connect just like zombie plague hud. I don't think that one it's better than the other, so choose what's better for you.
__________________








CrazY. is offline
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 05-27-2019 , 15:14   Re: Hud update
Reply With Quote #9

PHP Code:
#include <amxmodx>

#define MAX_PLAYERS 32
#define TASK_SHOWPOINTS 12345

new m_iPoints[MAX_PLAYERS 1];

new 
g_iSyncHud;

public 
plugin_init()
{
    
g_iSyncHud CreateHudSyncObj();
    
set_task(0.1"Task_Display"TASK_SHOWPOINTS, .flags "b");
}

public 
Task_Display() {
    
    new 
Players[MAX_PLAYERS], iNumid;
    
    
get_players(PlayersiNum"chi");
    
    for(new 
0iNumi++) {
        
        
id Players[i];
        
        switch(
m_iPoints[id]) {
            
            case 
1: {
                
                
set_hudmessage(02040, -1.00.6800.00.10.010.0);
                
ShowSyncHudMsg(idg_iSyncHud "Points - (x) ()");
            }
            case 
2: {
                
                
set_hudmessage(02040, -1.00.6800.00.10.010.0);
                
ShowSyncHudMsg(idg_iSyncHud "Points - (x) (x)");
            }
            default: {
                
                
set_hudmessage(02040, -1.00.6800.00.10.010.0);
                
ShowSyncHudMsg(idg_iSyncHud "Points - () ()");
            }
        }
    }

Compiled. No errors. Untested.
redivcram is offline
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 08:29.


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