AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Arrange huds under each other (https://forums.alliedmods.net/showthread.php?t=278756)

Deidara 02-07-2016 13:09

Arrange huds under each other
 
Hello, I have this.
It's a hud message who appears left or right depends of the players team.
I put the up-down possition random but ocasionally they overwrite, I don't know how to explain it so I'll attach a screenshot.

The first image - 1 is what happend when two or more huds are displayed - look at the left side, up. [ http://steamcommunity.com/id/eliara/...74420292407965 ]
The second image is how I want them to be, when two or more messages are generated I want them under each other to look nice. [ http://steamcommunity.com/id/eliara/...74420292407965 ]

Screens are on steam cloud images gallery because I can't upload them, they are too large.

Code:

PHP Code:

announce(killerlevel)
{
    new 
streak get_streak()

    if (
streak&1)
    {
        new 
name[32];
        new 
PositionYforCT random_num(0.15,0.70)
        new 
PositionXforT random_num(0.15,0.70)

           
get_user_name(killername32);
          if ( 
cs_get_user_team(killer) == CS_TEAM_CT )
            {
                
set_dhudmessage(0801500.03PositionYforCT20.026.00.010.12);
                
show_dhudmessage(0stkmessages[level], name);
            }
        else
            {
                
set_dhudmessage(20592920.80PositionXforT20.026.00.010.12);
                
show_dhudmessage(0stkmessages[level], name);
            }
    }

    if (
streak&2)
    {
            
client_cmd(0"spk %s"stksounds[level]);
    }


Sorry if this topic doesn't look attractive but I'm not english and I don't know it very well.
I hope there's the right section to ask help.

Bugsy 02-07-2016 13:59

Re: Arrange huds under each other
 
You can use sync huds and clear it before you show
PHP Code:

//plugin_init()
g_HUDSyncObj CreateHudSyncObj();

//Show HUD
ClearSyncHudg_HUDSyncObj );
set_hudmessage255 255 , -1.0 0.25 , .holdtime=1.0 );
ShowSyncHudMsgg_HUDSyncObj "Test" ); 


Deidara 02-08-2016 18:31

Re: Arrange huds under each other
 
Hello.
Thanks for reply.
Is there a way to make them all show but one after each other instead of making them disappear? I want all of the to show but in order, I don't want to erase them when another is pop up.

Bugsy 02-08-2016 18:34

Re: Arrange huds under each other
 
If you want them all there but not overwriting each other, change the X/Y coordinates in set_hudmessage().

Deidara 02-08-2016 18:48

Re: Arrange huds under each other
 
How can I put the conditions to not overwrite but in the same time the up-down possition to be random? Or manually set it to be under each other?

Bugsy 02-08-2016 19:29

Re: Arrange huds under each other
 
If you want random without one overlapping another you will need to do work to make sure one is not over another, whether partially or totaly.

Instead of random, I would define an array of 5-10 origins and loop through it. Make this set ones that you know will be ok if used one after the other.

Deidara 02-08-2016 19:31

Re: Arrange huds under each other
 
Can you show me an example of this array please? I'm gonna try it.

Bugsy 02-08-2016 20:12

Re: Arrange huds under each other
 
You can make them go down in a line, a circle, random, or anything you want. You just need to fill the array with the X,Y coords.
PHP Code:

#include <amxmodx>

enum HUDPos
{
    
Float:HUD_X,
    
Float:HUD_Y
}

new const 
Float:HUDCoords[][ HUDPos ] = 
{
    { 
0.05 0.24 },
    { 
0.05 0.28 },
    { 
0.05 0.32 },
    { 
0.05 0.36 },
    { 
0.05 0.40 },                
    { 
0.05 0.44 },                
    { 
0.05 0.48 },    
    { 
0.05 0.52 }
}
    
public 
plugin_init()
{
    
register_clcmd"say test" "TestCmd" );
}

public 
TestCmdid )
{
    
set_task1.0 "ShowHUD" , .flags="b" );
}

public 
ShowHUD()
{
    static 
iHUDIndex;

    
set_hudmessage255 255 255 HUDCoordsiHUDIndex ][ HUD_X ] , HUDCoordsiHUDIndex ][ HUD_Y ] , .holdtime=1.0 );
    
show_hudmessage"Test hud #%d" iHUDIndex );
    
    if ( ++
iHUDIndex == sizeofHUDCoords ) )
        
iHUDIndex 0;



Deidara 02-08-2016 20:39

Re: Arrange huds under each other
 
Thanks for you time. That really helps me and I managed to make it work.


All times are GMT -4. The time now is 09:27.

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