AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Dynamic Data HudMessage (https://forums.alliedmods.net/showthread.php?t=299635)

siriusmd99 07-21-2017 05:35

Dynamic Data HudMessage
 
Hi. So i wanted to make a hud message that will display current weapon name. So the problem is that if player changes weapon then hud message must be changed too. In this case i made a task with interval 0.2 seconds and every time it loops all players and sets hud message with current weapon name.

But i think this is not pretty efficient because if players holds a gun much time and doesnt change it often then the loop will have no sense.

I just wonder is there any method to overlap current hud by reseting the previous one or something like this?

Or maybe i can reset channel on curweapon event and set hud message back with modified message?

JusTGo 07-21-2017 06:14

Re: Dynamic Data HudMessage
 
show your current code,
curweapon to change weapon name + hud sync (hud message hold time = 99 ) + clear hud on client death.

HamletEagle 07-21-2017 06:58

Re: Dynamic Data HudMessage
 
Quote:

Originally Posted by JusTGo (Post 2536729)
show your current code,
curweapon to change weapon name + hud sync (hud message hold time = 99 ) + clear hud on client death.

Ham_Item_Deploy, not CurWeapon.

siriusmd99 07-21-2017 10:44

Re: Dynamic Data HudMessage
 
I did that but every time i change weapon it looks like clearsync doesnt work and hud is overlapping . It's green and if i switch the weapons fast then hud message starts to become white and ugly.
It looks like previous message didn't dissapear and new one is overlaping it.
tried fadeout 0.0 - no result. It's not logic, i don't understand how the hell such thing can happen.

PHP Code:

#define HUD_TIME 6.0

public plugin_init()
{
    
set_task(HUD_TIME"HudDisplay", .flags"b")
}

public 
OnItemDeployPost(ent)
{
    new 
id get_pdata_cbase(ent414
   

    
ClearSyncHud(id,g_NewSyncObj)
   
        
g_curKills[id] = get_weapon_kills(id);
        
set_hudmessage(34139340.020.890, .holdtime =  HUD_TIME);
        
ShowSyncHudMsg(idg_NewSyncObj"Current Kills: %d"g_curKills[id]);
    
}

public 
HudDisplay()
{
    new 
iPlayers[32]
    new 
iNumid;
    
get_players(iPlayersiNum"a")
    for (new 
iiNumi++)
    {
        
id iPlayers[i];
        
        
ClearSyncHud(id,g_NewSyncObj)

        
set_hudmessage(34139340.020.8900.0, .holdtime =  HUD_TIME);
        
ShowSyncHudMsg(idg_NewSyncObj"Current Kills: %d"g_curKills[id]);
    }



JusTGo 07-21-2017 11:25

Re: Dynamic Data HudMessage
 
remove the task and ClearSync only at client death.

PHP Code:

#define HUD_TIME 6.0

public OnItemDeployPost(ent)
{
    new 
id get_pdata_cbase(ent414
   

   
        
g_curKills[id] = get_weapon_kills(id);
        
set_hudmessage(34139340.020.890, .holdtime =  HUD_TIME);
        
ShowSyncHudMsg(idg_NewSyncObj"Current Kills: %d"g_curKills[id]);
    



siriusmd99 07-21-2017 11:38

Re: Dynamic Data HudMessage
 
Quote:

Originally Posted by JusTGo (Post 2536778)
remove the task and ClearSync only at client death.

PHP Code:

#define HUD_TIME 6.0

public OnItemDeployPost(ent)
{
    new 
id get_pdata_cbase(ent414
   

   
        
g_curKills[id] = get_weapon_kills(id);
        
set_hudmessage(34139340.020.890, .holdtime =  HUD_TIME);
        
ShowSyncHudMsg(idg_NewSyncObj"Current Kills: %d"g_curKills[id]);
    



Doesn't work anyway.
+ i can't remove task because if player doesnt change weapon then hud will dissapear after 6 seconds.

I managed to make a global task and loop all players every 0.5 seconds but i think it's not efficient and even if i do this way then hud will blink akward and it's anoying.

JusTGo 07-21-2017 11:47

Re: Dynamic Data HudMessage
 
change HUD_TIME to 600.0 for example and it will not dissapear and use clearsync to remove it at client death.

siriusmd99 07-21-2017 11:54

Re: Dynamic Data HudMessage
 
Quote:

Originally Posted by JusTGo (Post 2536782)
change HUD_TIME to 600.0 for example and it will not dissapear and use clearsync to remove it at client death.

Yes, but if i change weapon i must reset hud message because points are different.
So i must reset task in ham deploy every time weapon changes.

JusTGo 07-21-2017 12:32

Re: Dynamic Data HudMessage
 
Quote:

Originally Posted by siriusmd99 (Post 2536783)
Yes, but if i change weapon i must reset hud message because points are different.
So i must reset task in ham deploy every time weapon changes.

we need full code, you may not need the task, what are points ?

siriusmd99 07-21-2017 15:02

Re: Dynamic Data HudMessage
 
I understand now. The problem is that if i use smaller task like 1.0 or 0.5 then the fade in effect (that cannot be changed) is repeating at least 1 time per second and it makes illusion that text is blinking.

But if I set a task with longer time like 30 seconds then it's ok.
But when i try to clear synchud at item deploy and start a new message with modified string then it starts to overlap and text becomes white and messy.


All times are GMT -4. The time now is 22:56.

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