AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Plguin Cvar From Cfg (https://forums.alliedmods.net/showthread.php?t=61557)

Frozen Usp 10-03-2007 13:42

Plguin Cvar From Cfg
 
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

:):mrgreen::):mrgreen:

Styles 10-03-2007 13:46

Re: Plguin Cvar From Cfg
 
Please explain better, I don't understand what you mean.

Frozen Usp 10-03-2007 13:51

Re: Plguin Cvar From Cfg
 
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

Styles 10-03-2007 14:08

Re: Plguin Cvar From Cfg
 
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..

Frozen Usp 10-03-2007 15:16

Re: Plguin Cvar From Cfg
 
please say exactly what to writh:D
What modules are needed??
Thanks For the help +KARMA

M249-M4A1 10-03-2007 15:35

Re: Plguin Cvar From Cfg
 
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.

Frozen Usp 10-03-2007 15:37

Re: Plguin Cvar From Cfg
 
M249 Whats Wrong dude??!?!
i'm not a good scripter as you!
i'm stile newbie

M249-M4A1 10-03-2007 15:44

Re: Plguin Cvar From Cfg
 
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"
    
    */ 


Frozen Usp 10-03-2007 15:45

Re: Plguin Cvar From Cfg
 
THANKS ALOT!!!
i would never guess that would be the code...

+ EXTREAM KARMA! :D

Frozen Usp 10-03-2007 15:47

Re: Plguin Cvar From Cfg
 
Whats The Mycvar cmd?


All times are GMT -4. The time now is 16:11.

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