Raised This Month: $ Target: $400
 0% 

how to add new cvar(with variables) in CFG??


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bugg
Senior Member
Join Date: Jan 2012
Old 12-22-2012 , 12:08   how to add new cvar(with variables) in CFG??
Reply With Quote #1

Example:
PHP Code:
public plugin_init()
{
newcvar register_cvar("newcvar""1");
    
register_clcmd("say /health""something")
new 
configsDir[64]
    
get_configsdir(configsDir63)
    
server_cmd("exec %s/amx_lol.cfg"configsDir
}


public 
something(id)
{
switch( 
get_pcvar_num(elegirserver) )
    {
        case 
1:
        {
            
set_user_health(id,get_user_health(id)+15)  
        }
        case 
2:
        {
            
set_user_health(id,get_user_health(id)+50)  
        }
        case 
3:
        {
            
set_user_health(id,get_user_health(id)+70)  
        }
        case 
4:
        {
            
set_user_health(id,get_user_health(id)+100)  
        }

well, now in lol.cfg write that:

newcvar 3

----------


what´s wrong? coz always.. give it 15 hp only..

lol.cfg not found... dont read it :S

help plz?
Bugg is offline
simanovich
AlliedModders Donor
Join Date: Jun 2012
Location: Israel
Old 12-22-2012 , 13:19   Re: how to add new cvar(with variables) in CFG??
Reply With Quote #2

Call it amx_lol.cfg and not lol.cfg
__________________
simanovich is offline
Bugg
Senior Member
Join Date: Jan 2012
Old 12-22-2012 , 13:33   Re: how to add new cvar(with variables) in CFG??
Reply With Quote #3

Quote:
Originally Posted by simanovich View Post
Call it amx_lol.cfg and not lol.cfg
what?? xDD

is call amx_lol man!..
Bugg is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-22-2012 , 14:29   Re: how to add new cvar(with variables) in CFG??
Reply With Quote #4

Try executing the cfg file in plugin_cfg().
__________________
fysiks is offline
Bugg
Senior Member
Join Date: Jan 2012
Old 12-22-2012 , 15:23   Re: how to add new cvar(with variables) in CFG??
Reply With Quote #5

cfg works 100%.

Coz i have others cvars, and works fine.

The problem is in the code to set HP. bad codding i think.. for that reason need help.
Bugg is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-22-2012 , 15:34   Re: how to add new cvar(with variables) in CFG??
Reply With Quote #6

Quote:
Originally Posted by Bugg View Post
cfg works 100%.

Coz i have others cvars, and works fine.

The problem is in the code to set HP. bad codding i think.. for that reason need help.
Did you try what I said?
__________________
fysiks is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 12-22-2012 , 20:12   Re: how to add new cvar(with variables) in CFG??
Reply With Quote #7

Where do you define the variable "elegirserver"?
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
DjOptimuS
Senior Member
Join Date: Jan 2009
Old 12-22-2012 , 21:07   Re: how to add new cvar(with variables) in CFG??
Reply With Quote #8

What do you want to do exactly?
DjOptimuS is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-23-2012 , 20:28   Re: how to add new cvar(with variables) in CFG??
Reply With Quote #9

Quote:
Originally Posted by YamiKaitou View Post
Where do you define the variable "elegirserver"?
Oh wow, I totally over looked that.
__________________
fysiks is offline
xDrugz
Senior Member
Join Date: Jul 2011
Location: return 4;
Old 12-24-2012 , 11:47   Re: how to add new cvar(with variables) in CFG??
Reply With Quote #10

code:

Code:
#include < amxmodx >
#include < amxmisc >
#include < fun >

new g_pCvar;

public plugin_init() 
{ 
	g_pCvar = register_cvar( "amx_healthtoadd", "50" );
	
	new ConfigsDir[ 64 ];
	get_configsdir( ConfigsDir, charsmax( ConfigsDir ) );
	server_cmd("exec %s/health.cfg", ConfigsDir );
	
	register_clcmd( "say /health", "something" );
} 

public something( id ) 
{ 
	new health = get_pcvar_num( g_pCvar );
	
	set_user_health( id, get_user_health( id ) + health );
}
health.cfg:
Code:
amx_healthtoadd "100"
make sure you placed health.cfg file in your configs dir.
__________________
xDrugz 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 20:39.


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