AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Spectator Hud help - prokreedz (https://forums.alliedmods.net/showthread.php?t=159837)

plowed 06-22-2011 08:25

Spectator Hud help - prokreedz
 
Hi, Im using prokreedz 2.27 and have problem with the spectator HUD.

First the Code

PHP Code:

public timer_task()
{
    for(new 
i=1;i<=MaxPlayers;i++)
    {
        if ( 
get_pcvar_num(kz_show_timer) == // Only do the code if the Cvar is 1..
        
{
            if (
is_user_alive(i))
            {
                if( 
is_user_connected(i) && timer_started[i])
                {
                    new 
Float:kreedztime get_gametime() - (IsPaused[i] ? get_gametime() - g_pausetime[i] : timer_time[i])

                    if( 
ShowTime[i] == )
                    {
                        new 
colors[12], r[4], g[4], b[4];
                        new 
imin floatround(kreedztime 60.0,floatround_floor)
                        new 
isec floatround(kreedztime imin 60.0,floatround_floor)
                        
get_pcvar_string(kz_hud_colorcolors11)
                        
parse(colorsr3g3b4)
                        
                        
set_hudmessage(str_to_num(r), str_to_num(g), str_to_num(b), 0.400.1000.01.00.00.0, -1)    
                        
show_hudmessage(i"Time: %02d:%02d  | CPs: %d | TPs: %d ",iminisec,checknumbers[i], gochecknumbers[i]) 
                    }
                    else
                    if( 
ShowTime[i] == )
                    {
                        
kz_showtime_roundtime(ifloatround(kreedztime))
                    }
                }
                
                if( 
get_pcvar_num(kz_godmode) == )
                    
set_user_godmode(i1)
                else
                    
set_user_godmode(i0)
            }
            else 
//Here is the Spec HUD
            
{
                new 
specmode pev(ipev_iuser1)
                if(
specmode == || specmode == 4)
                {
                    new 
target pev(ipev_iuser2)
                    if(
target != i)
                        if(
is_user_alive(target) && timer_started[target])
                        {
                            new 
name[32], colors[12], r[4], g[4], b[4];
                            
get_user_name (targetname31)

                            new 
Float:kreedztime get_gametime() - (IsPaused[target] ? get_gametime() - g_pausetime[target] : timer_time[target])
                            new 
imin floatround(kreedztime 60.0,floatround_floor)
                            new 
isec floatround(kreedztime imin 60.0,floatround_floor)

                            
get_pcvar_string(kz_hud_colorcolors11)
                            
parse(colorsr3g3b4)

                            
set_hudmessage(str_to_num(r), str_to_num(g), str_to_num(b), 0.400.1000.01.00.00.0, -1)
                            
show_hudmessage(i"Time: %02d:%02d  | CPs: %d | TPs: %d %s ",iminisecchecknumbers[target], gochecknumbers[target], IsPaused[target] ? "| *Paused*" "")     
                        }
                }
            }
        }
    }


Ive command the part where the the cvar and spechud message begin..So when the cvar is "1" the Spec HUD works.

Everytime a user is spec the hudmessage should work. But now its only work if the cvar is "1"...
The problem is I wont set the cvar to 1 because it changed it in the whole code and I only want it for this single function.
Hope you understand what I mean :shock:

DarkGL 06-22-2011 12:05

Re: Spectator Hud help - prokreedz
 
always without checking cvar
Code:

public timer_task()
{
    for(new i=1;i<=MaxPlayers;i++)
    {
            if (is_user_alive(i))
            {
                if( is_user_connected(i) && timer_started[i])
                {
                    new Float:kreedztime = get_gametime() - (IsPaused[i] ? get_gametime() - g_pausetime[i] : timer_time[i])

                    if( ShowTime[i] == 1 )
                    {
                        new colors[12], r[4], g[4], b[4];
                        new imin = floatround(kreedztime / 60.0,floatround_floor)
                        new isec = floatround(kreedztime - imin * 60.0,floatround_floor)
                        get_pcvar_string(kz_hud_color, colors, 11)
                        parse(colors, r, 3, g, 3, b, 4)
                       
                        set_hudmessage(str_to_num(r), str_to_num(g), str_to_num(b), 0.40, 0.10, 0, 0.0, 1.0, 0.0, 0.0, -1)   
                        show_hudmessage(i, "Time: %02d:%02d  | CPs: %d | TPs: %d ",imin, isec,checknumbers[i], gochecknumbers[i])
                    }
                    else
                    if( ShowTime[i] == 2 )
                    {
                        kz_showtime_roundtime(i, floatround(kreedztime))
                    }
                }
               
                if( get_pcvar_num(kz_godmode) == 1 )
                    set_user_godmode(i, 1)
                else
                    set_user_godmode(i, 0)
            }
            else //Here is the Spec HUD
            {
                new specmode = pev(i, pev_iuser1)
                if(specmode == 2 || specmode == 4)
                {
                    new target = pev(i, pev_iuser2)
                    if(target != i)
                        if(is_user_alive(target) && timer_started[target])
                        {
                            new name[32], colors[12], r[4], g[4], b[4];
                            get_user_name (target, name, 31)

                            new Float:kreedztime = get_gametime() - (IsPaused[target] ? get_gametime() - g_pausetime[target] : timer_time[target])
                            new imin = floatround(kreedztime / 60.0,floatround_floor)
                            new isec = floatround(kreedztime - imin * 60.0,floatround_floor)

                            get_pcvar_string(kz_hud_color, colors, 11)
                            parse(colors, r, 3, g, 3, b, 4)

                            set_hudmessage(str_to_num(r), str_to_num(g), str_to_num(b), 0.40, 0.10, 0, 0.0, 1.0, 0.0, 0.0, -1)
                            show_hudmessage(i, "Time: %02d:%02d  | CPs: %d | TPs: %d %s ",imin, isec, checknumbers[target], gochecknumbers[target], IsPaused[target] ? "| *Paused*" : "")   
                        }
                }
            }
    }
}


or when cvar is diffrent from 0
Code:

public timer_task()
{
    for(new i=1;i<=MaxPlayers;i++)
    {
        if ( get_pcvar_num(kz_show_timer)) // Only do the code if the Cvar is 1..
        {
            if (is_user_alive(i))
            {
                if( is_user_connected(i) && timer_started[i])
                {
                    new Float:kreedztime = get_gametime() - (IsPaused[i] ? get_gametime() - g_pausetime[i] : timer_time[i])

                    if( ShowTime[i] == 1 )
                    {
                        new colors[12], r[4], g[4], b[4];
                        new imin = floatround(kreedztime / 60.0,floatround_floor)
                        new isec = floatround(kreedztime - imin * 60.0,floatround_floor)
                        get_pcvar_string(kz_hud_color, colors, 11)
                        parse(colors, r, 3, g, 3, b, 4)
                       
                        set_hudmessage(str_to_num(r), str_to_num(g), str_to_num(b), 0.40, 0.10, 0, 0.0, 1.0, 0.0, 0.0, -1)   
                        show_hudmessage(i, "Time: %02d:%02d  | CPs: %d | TPs: %d ",imin, isec,checknumbers[i], gochecknumbers[i])
                    }
                    else
                    if( ShowTime[i] == 2 )
                    {
                        kz_showtime_roundtime(i, floatround(kreedztime))
                    }
                }
               
                if( get_pcvar_num(kz_godmode) == 1 )
                    set_user_godmode(i, 1)
                else
                    set_user_godmode(i, 0)
            }
            else //Here is the Spec HUD
            {
                new specmode = pev(i, pev_iuser1)
                if(specmode == 2 || specmode == 4)
                {
                    new target = pev(i, pev_iuser2)
                    if(target != i)
                        if(is_user_alive(target) && timer_started[target])
                        {
                            new name[32], colors[12], r[4], g[4], b[4];
                            get_user_name (target, name, 31)

                            new Float:kreedztime = get_gametime() - (IsPaused[target] ? get_gametime() - g_pausetime[target] : timer_time[target])
                            new imin = floatround(kreedztime / 60.0,floatround_floor)
                            new isec = floatround(kreedztime - imin * 60.0,floatround_floor)

                            get_pcvar_string(kz_hud_color, colors, 11)
                            parse(colors, r, 3, g, 3, b, 4)

                            set_hudmessage(str_to_num(r), str_to_num(g), str_to_num(b), 0.40, 0.10, 0, 0.0, 1.0, 0.0, 0.0, -1)
                            show_hudmessage(i, "Time: %02d:%02d  | CPs: %d | TPs: %d %s ",imin, isec, checknumbers[target], gochecknumbers[target], IsPaused[target] ? "| *Paused*" : "")   
                        }
                }
            }
        }
    }
}



All times are GMT -4. The time now is 23:34.

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