Raised This Month: $ Target: $400
 0% 

Plguin Cvar From Cfg


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Frozen Usp
Member
Join Date: Sep 2007
Location: Sweden
Old 10-03-2007 , 13:42   Plguin Cvar From Cfg
Reply With Quote #1

Hi!
How do i make a plugin take the cvars thats needed from a cfg file?
Ex. If you have a xp mod with a guy thats get 25 hp each lvl.
you only need to open the .cfg file in wordpad(ore other txt program) and change the cvar to whatever you whant


Last edited by Frozen Usp; 10-03-2007 at 13:52. Reason: Bad Explain
Frozen Usp is offline
Send a message via MSN to Frozen Usp
Styles
Veteran Member
Join Date: Jul 2004
Location: California
Old 10-03-2007 , 13:46   Re: Plguin Cvar From Cfg
Reply With Quote #2

Please explain better, I don't understand what you mean.
Styles is offline
Send a message via AIM to Styles
Frozen Usp
Member
Join Date: Sep 2007
Location: Sweden
Old 10-03-2007 , 13:51   Re: Plguin Cvar From Cfg
Reply With Quote #3

Ex. Warcraft 3 mod uses a Config file thats putt in amxmodx --> config

i whanna know how to make that.
becuse i'm working on a plguin where i whant the one tat uses the plugin can change the settings it uses from a config file

Last edited by Frozen Usp; 10-03-2007 at 13:53. Reason: Forgot a part
Frozen Usp is offline
Send a message via MSN to Frozen Usp
Styles
Veteran Member
Join Date: Jul 2004
Location: California
Old 10-03-2007 , 14:08   Re: Plguin Cvar From Cfg
Reply With Quote #4

ConfigFile[128]
get_configsdir(ConfigFile,127)
add(ConfigFile,127,"/yourInIFile.ini")

is that like what your looking for? Put that in plugin_init() execute it..
Styles is offline
Send a message via AIM to Styles
Frozen Usp
Member
Join Date: Sep 2007
Location: Sweden
Old 10-03-2007 , 15:16   Re: Plguin Cvar From Cfg
Reply With Quote #5

please say exactly what to writh
What modules are needed??
Thanks For the help +KARMA

Last edited by Frozen Usp; 10-03-2007 at 15:27.
Frozen Usp is offline
Send a message via MSN to Frozen Usp
M249-M4A1
I <3 Mac
Join Date: May 2005
Location: Not interested
Old 10-03-2007 , 15:35   Re: Plguin Cvar From Cfg
Reply With Quote #6

Please stop posting in all bold.

No modules are needed to read a file.

A very easy method is to register the cvar's in your plugin_init(), then somewhere in your code, where you want the cvar's to be read from a .cfg file, do: server_cmd("exec %s", configfile) or whatever. This avoids having to go through the mess of formatting extra stuff just to read a few cvars.
__________________
M249-M4A1 is offline
Frozen Usp
Member
Join Date: Sep 2007
Location: Sweden
Old 10-03-2007 , 15:37   Re: Plguin Cvar From Cfg
Reply With Quote #7

M249 Whats Wrong dude??!?!
i'm not a good scripter as you!
i'm stile newbie
Frozen Usp is offline
Send a message via MSN to Frozen Usp
M249-M4A1
I <3 Mac
Join Date: May 2005
Location: Not interested
Old 10-03-2007 , 15:44   Re: Plguin Cvar From Cfg
Reply With Quote #8

haha sorry, something like this:

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

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "M249-M4A1"

#define CONFIGPATH "addons/amxmodx/configs/"
#define CONFIGFILE "myconfig.cfg"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_concmd("amx_loadmahconfig""LOADITBABY"ADMIN_KICK"- execute a config file")
    
register_cvar("my_cvar""1")
    
register_cvar("my_other_cvar""abcdefghijk")
}

public 
LOADITBABY(id) {
    
server_cmd("exec %s/%s"CONFIGPATHCONFIGFILE)
    
// or, if you don't want to use defines:
    
server_cmd("exec addons/amxmodx/configs/myconfig.cfg")
    
    
// tell the client the config was executed
    
client_print(idprint_console"[AMXX] A configuration file was executed")
    
    return 
PLUGIN_HANDLED
}


/* 
    and inside of myconfig.cfg:
    
    // this is myconfig.cfg
    // sv_alltalk "0"
    // my_cvar "0"
    // my_other_cvar "abcdefg"
    
    */ 
__________________
M249-M4A1 is offline
Frozen Usp
Member
Join Date: Sep 2007
Location: Sweden
Old 10-03-2007 , 15:45   Re: Plguin Cvar From Cfg
Reply With Quote #9

THANKS ALOT!!!
i would never guess that would be the code...

+ EXTREAM KARMA!
Frozen Usp is offline
Send a message via MSN to Frozen Usp
Frozen Usp
Member
Join Date: Sep 2007
Location: Sweden
Old 10-03-2007 , 15:47   Re: Plguin Cvar From Cfg
Reply With Quote #10

Whats The Mycvar cmd?
Frozen Usp is offline
Send a message via MSN to Frozen Usp
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 16:11.


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