Raised This Month: $7 Target: $400
 1% 

Module: Cvar Utilities (v1.6)


Post New Thread Reply   
 
Thread Tools Display Modes
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 05-23-2011 , 06:23   Re: Cvar Utilities
Reply With Quote #21

a mini question.
is it right so or can i do it better?

PHP Code:
new Catch_Enable

new Catchcvar CvarRegister"amx_catch_enable""1" )
    
CvarHookChangeCatchcvar,"Catch_Cvar" )

public 
Catch_Cvar( const handleCvar, const oldValue[], const newValue[], const cvarName[] )
{
    
catch_toggleForward( .enable newValue] == '1' );
}
public 
catch_toggleForward(const bool:enable )
{
    if(!
enable)
    {
        
client_print(0,print_chat,"Catchmod is now OFF")
        
Catch_Enable 0
    
}
    else
    {
        
client_print(0,print_chat,"Catchmod is now ON")
        
Catch_Enable 1
    
}
    
server_cmd("sv_restart 1")

PHP Code:
public Say_Command(id)
{
    if(!
Catch_Enable)
    {
        return 
PLUGIN_HANDLED
    
}
    static 
say_args[64]
    
read_args(say_argscharsmax(say_args))
    
remove_quotes(say_args)
    
    if(
say_args[0] != '/')
    {
        return 
PLUGIN_CONTINUE
    
}
    if(
equali(say_args"/install") || equali(say_args"/installdb"))
    {
        if(
get_user_flags(id) & ADMIN_KICK)
        {
            
install_db(id)
        }
        else
        {
            
ChatColor(id"%L"LANG_PLAYER,"ERROR_NOT_ALLOWDED"PLUGIN)
        }
    }
    return 
PLUGIN_CONTINUE

do i have to user get_cvar_num or is it ok so? ( both works )
__________________

Last edited by One; 05-23-2011 at 06:31.
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-23-2011 , 07:14   Re: Cvar Utilities
Reply With Quote #22

I would suggest to use a bound to make sure value is either 0 or 1. Also, since you have one cvar, making a private function is not really needed.

For example :

PHP Code:
new Catch_Enable;

public 
plugin_init()
{
    new 
handleCvarStatus CvarRegister"amx_catch_enable""1", .hasMin true, .minValue 0.0, .hasMax true, .maxValue 1.0, .forceInterval false );
    
CvarHookChangehandleCvarStatus"Catch_Cvar" );
}
public 
Catch_Cvar( const handleCvar, const oldValue[], const newValue[], const cvarName[] )
{
    
Catch_Enable = ( newValue] == '1' );
    
client_print0print_chat"Catchmod is now %s"Catch_Enable "ON" "OFF" );
    
    
server_cmd"sv_restart 1" );

__________________

Last edited by Arkshine; 05-23-2011 at 07:17.
Arkshine is offline
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 05-23-2011 , 07:54   Re: Cvar Utilities
Reply With Quote #23

thanks. works perfect and the best is that the code is now clean :d ty
__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
Tirant
Veteran Member
Join Date: Jul 2008
Location: Los Angeles, California
Old 06-24-2011 , 06:15   Re: Cvar Utilities
Reply With Quote #24

Very cool!
__________________

PM me if you're interested in buying the Credits addition for Base Builder
Battlefield Rebirth [66% done]
Call of Duty: MW2 [100% done]
Base Builder [100% done]
Tirant is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-24-2011 , 07:08   Re: Cvar Utilities
Reply With Quote #25

Thanks. You might be the third person willing to use it. Or not.
__________________
Arkshine is offline
Tirant
Veteran Member
Join Date: Jul 2008
Location: Los Angeles, California
Old 06-24-2011 , 07:15   Re: Cvar Utilities
Reply With Quote #26

Main reason why I might use it is for the clamp. But the other forwards are really cool as well.
__________________

PM me if you're interested in buying the Credits addition for Base Builder
Battlefield Rebirth [66% done]
Call of Duty: MW2 [100% done]
Base Builder [100% done]
Tirant is offline
Tirant
Veteran Member
Join Date: Jul 2008
Location: Los Angeles, California
Old 07-09-2011 , 06:21   Re: Cvar Utilities
Reply With Quote #27

You have the cvar description inputted in with registering a cvar. What exactly is it's purpose? It would be nice if somewhere there was a command for an admin to display all cvars with their descriptions. Or maybe a file to be generated for all mods using this module, or each individual plugin that lists it like...

Quote:
my_cvar "value" // [min-max] description
Not to mention, a bet a lot more people might be willing to implement this into their plugins with such a feature. I sure as hell would.
__________________

PM me if you're interested in buying the Credits addition for Base Builder
Battlefield Rebirth [66% done]
Call of Duty: MW2 [100% done]
Base Builder [100% done]
Tirant is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 07-09-2011 , 06:25   Re: Cvar Utilities
Reply With Quote #28

This should be added into amxx core...
__________________
xPaw is offline
Tirant
Veteran Member
Join Date: Jul 2008
Location: Los Angeles, California
Old 07-09-2011 , 06:30   Re: Cvar Utilities
Reply With Quote #29

It would be super cool if amxx or this would support boolean cvars with only <0/1> or <false/true> or <disabled/enabled>.
__________________

PM me if you're interested in buying the Credits addition for Base Builder
Battlefield Rebirth [66% done]
Call of Duty: MW2 [100% done]
Base Builder [100% done]
Tirant is offline
Tirant
Veteran Member
Join Date: Jul 2008
Location: Los Angeles, California
Old 07-09-2011 , 07:41   Re: Cvar Utilities
Reply With Quote #30

I've found a bug. If you have show cvar changes enabled, and you have a min/max value for a cvar set, it messages the cvar has "changed" to the value entered, when you're mod cancels it. It's a bit misleading.
__________________

PM me if you're interested in buying the Credits addition for Base Builder
Battlefield Rebirth [66% done]
Call of Duty: MW2 [100% done]
Base Builder [100% done]
Tirant is offline
Reply


Thread Tools
Display Modes

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 01:58.


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