View Single Post
Author Message
Arje
Senior Member
Join Date: Apr 2020
Location: Córdoba, Argentina
Old 05-19-2020 , 19:46   Help Me With Hud For Spectator
Reply With Quote #1

Hello! I wanted to know if it is possible to make this Hud from C4timer only show for spects, currently shown to all players.

PHP Code:
#include amxmodx
#include csx

new msg,sec
new Float:c4cd,Float:c4max
new Float:temp,Float:r,Float:g
new bool:c4pl=false

public plugin_init()
{
    
register_plugin("C4-Bomb Countdown HUD Timer","0.4","SAMURAI; Midnight Kid")
    
msg=CreateHudSyncObj()
    
sec=get_cvar_pointer("mp_c4timer")
    
register_logevent("nr",2,"1=Round_Start")
    
register_logevent("er",2,"1=Round_End")
    
register_logevent("er",2,"1&Restart_Round_")
}

public 
nr()
{
    
c4cd=-1.0
    remove_task
(652450)
    
c4pl=false
}

public 
er()
{
    
c4cd=-1.0
    remove_task
(652450)
}

public 
bomb_planted()
{
    
c4pl=true
    c4max
=get_pcvar_float(sec)
    
c4cd=c4max
    show
()
    
set_task(1.0,"show",652450,"",0,"b")
}

public 
bomb_defused()
{
    if(
c4pl)
    {
        
remove_task(652450)
        
c4pl=false
    
}
}

public 
bomb_explode()
{
    if(
c4pl)
    {
        
remove_task(652450)
        
c4pl=false
    
}
}

public 
show()
{
    if(!
c4pl)
    {
        
remove_task(652450)
        return
    }
    if(
c4cd>=0.0)
    {
        
temp=c4cd/c4max
        
if(temp>=0.5)
        {
            
r=510*(1.0-temp)
            
g=255.0
        
}
        if(
temp<0.5)
        {
            
r=255.0
            g
=510*temp
        
}
        
    
set_hudmessage(floatround(r),floatround(g),0,-1.0,0.80,0,_,1.0,_,_,4)
    
ShowSyncHudMsg(0,msg,"Anda a Defusear la bomba!!! Faltan %d segundos antes de que explote.",floatround(c4cd))
    
c4cd-=1.0
    
}

Arje is offline