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

[L4D2]About the func_button_timed entity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mrs cheng
Member
Join Date: Mar 2017
Old 11-26-2018 , 02:05   [L4D2]About the func_button_timed entity
Reply With Quote #1

Keyvalues

Use String <string>
The text/string that appears on the progress bar while the player is holding down use.

Use Sub-String <string>
A sub-string that appears below the Use String.

Why are they invalid to use the above two key names? (use_string and use_sub_string)
The ProgressBarText/SubText does not appear when I press the button.

Could someone help me?
Thanks.
Mrs cheng is offline
Mr. Zero
Veteran Member
Join Date: Jun 2009
Location: Denmark
Old 11-30-2018 , 01:37   Re: [L4D2]About the func_button_timed entity
Reply With Quote #2

You have to apply a model. You can afterwards hide the model if you don't need it with the effects bitflag for NODRAW.
This also fixes the glow netprops so glows can be applied to the button if needed.

Beaware that applying model to the button can mess up the use range, depending on how large your use model is.
Furthermore make sure your UseStrings aren't empty, otherwise the game will use the last UseString the client saw (such as, healing teammate when the player is using your button).

PHP Code:
// func_buttons, even without model, still collide and can provide height
// advantage. By offseting, no height advantage is given.
#define FUNC_BUTTON_Z_OFFSET -2.0

...

    
// Validate use strings.
    
if (strlen(UseString) > 0)
    {
        
Format(TempStringsizeof(TempString), "%s"UseString);
        
StripQuotes(TempString);
        
TrimString(TempString);
        if (
strlen(TempString) > 0)
        {
            
DispatchKeyValue(Entity"use_string"TempString);
        }
        else
        {
            
// Empty string to overwrite last useaction string
            
DispatchKeyValue(Entity"use_string"" ");
        }
    }
    else
    {
        
// Empty string to overwrite last useaction string
        
DispatchKeyValue(Entity"use_string"" ");
    }

    if (
strlen(UseSubString) > 0)
    {
        
Format(TempStringsizeof(TempString), "%s"UseSubString);
        
StripQuotes(TempString);
        
TrimString(TempString);
        if (
strlen(TempString) > 0)
        {
            
DispatchKeyValue(Entity"use_sub_string"TempString);
        }
        else
        {
            
// Empty string to overwrite last useaction string
            
DispatchKeyValue(Entity"use_sub_string"" ");
        }
    }
    else
    {
        
// Empty string to overwrite last useaction string
        
DispatchKeyValue(Entity"use_sub_string"" ");
    }

    
// Apply model and no draw model flag.
    // This fixes missing glow and use strings.
    
SetEntityModel(EntityBUTTON_MODEL);
    
int Effects GetEntProp(EntityProp_Send"m_fEffects");
    
Effects |= 32;
    
SetEntProp(EntityProp_Send"m_fEffects"Effects);

    
// Apply bounds for correct use range.
    
float MinBounds[3] = {
        
BUTTON_MODEL_MINBOUNDS_X,
        
BUTTON_MODEL_MINBOUNDS_Y,
        
BUTTON_MODEL_MINBOUNDS_Z};
    
MinBounds[2] += FUNC_BUTTON_Z_OFFSET;
    
float MaxBounds[3] = {
        
BUTTON_MODEL_MAXBOUNDS_X,
        
BUTTON_MODEL_MAXBOUNDS_Y,
        
BUTTON_MODEL_MAXBOUNDS_Z};
    
MaxBounds[2] -= FUNC_BUTTON_Z_OFFSET;

    
SetEntPropVector(EntityProp_Send"m_vecMins"MinBounds);
    
SetEntPropVector(EntityProp_Send"m_vecMaxs"MaxBounds); 

Last edited by Mr. Zero; 11-30-2018 at 01:39.
Mr. Zero is offline
Mrs cheng
Member
Join Date: Mar 2017
Old 11-30-2018 , 12:21   Re: [L4D2]About the func_button_timed entity
Reply With Quote #3

Quote:
Originally Posted by Mr. Zero View Post
You have to apply a model. You can afterwards hide the model if you don't need it with the effects bitflag for NODRAW.
This also fixes the glow netprops so glows can be applied to the button if needed.

Beaware that applying model to the button can mess up the use range, depending on how large your use model is.
Furthermore make sure your UseStrings aren't empty, otherwise the game will use the last UseString the client saw (such as, healing teammate when the player is using your button).

PHP Code:
// func_buttons, even without model, still collide and can provide height
// advantage. By offseting, no height advantage is given.
#define FUNC_BUTTON_Z_OFFSET -2.0

...

    
// Validate use strings.
    
if (strlen(UseString) > 0)
    {
        
Format(TempStringsizeof(TempString), "%s"UseString);
        
StripQuotes(TempString);
        
TrimString(TempString);
        if (
strlen(TempString) > 0)
        {
            
DispatchKeyValue(Entity"use_string"TempString);
        }
        else
        {
            
// Empty string to overwrite last useaction string
            
DispatchKeyValue(Entity"use_string"" ");
        }
    }
    else
    {
        
// Empty string to overwrite last useaction string
        
DispatchKeyValue(Entity"use_string"" ");
    }

    if (
strlen(UseSubString) > 0)
    {
        
Format(TempStringsizeof(TempString), "%s"UseSubString);
        
StripQuotes(TempString);
        
TrimString(TempString);
        if (
strlen(TempString) > 0)
        {
            
DispatchKeyValue(Entity"use_sub_string"TempString);
        }
        else
        {
            
// Empty string to overwrite last useaction string
            
DispatchKeyValue(Entity"use_sub_string"" ");
        }
    }
    else
    {
        
// Empty string to overwrite last useaction string
        
DispatchKeyValue(Entity"use_sub_string"" ");
    }

    
// Apply model and no draw model flag.
    // This fixes missing glow and use strings.
    
SetEntityModel(EntityBUTTON_MODEL);
    
int Effects GetEntProp(EntityProp_Send"m_fEffects");
    
Effects |= 32;
    
SetEntProp(EntityProp_Send"m_fEffects"Effects);

    
// Apply bounds for correct use range.
    
float MinBounds[3] = {
        
BUTTON_MODEL_MINBOUNDS_X,
        
BUTTON_MODEL_MINBOUNDS_Y,
        
BUTTON_MODEL_MINBOUNDS_Z};
    
MinBounds[2] += FUNC_BUTTON_Z_OFFSET;
    
float MaxBounds[3] = {
        
BUTTON_MODEL_MAXBOUNDS_X,
        
BUTTON_MODEL_MAXBOUNDS_Y,
        
BUTTON_MODEL_MAXBOUNDS_Z};
    
MaxBounds[2] -= FUNC_BUTTON_Z_OFFSET;

    
SetEntPropVector(EntityProp_Send"m_vecMins"MinBounds);
    
SetEntPropVector(EntityProp_Send"m_vecMaxs"MaxBounds); 
Thank you very much. but when I set the model I get an error message in the server console,
just warning me that I am trying to set a non brush model to the entity.Is there a way to avoid it?
Mrs cheng is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 12-04-2018 , 18:04   Re: [L4D2]About the func_button_timed entity
Reply With Quote #4

Maybe set another "brush" model. Or find a ready one on some map and read what model name it uses, like enum all entities and check by class.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas 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 12:16.


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