Plugin Battle Conf settings

Samuel

New member
Messages
397
Points
0
Discord
Elijah#5798
Github
Samuel23
Emulator
Hello, I'm trying to convert the @go, @warp, @jump delay when hit via plugin and I was successful.
 
But I want to make it read the delay from a conf setting instead of hard coded in the plugin source.
 
So I looked into the sample.c and tried it so it just
 
[cbox]

HPExport void server_preinit (void) {
 /* makes map server listen to mysetting:value in any "battleconf" file (including imported or custom ones) */
 /* value is not limited to numbers, its passed to our plugins handler (parse_my_setting) as const char *,
  * and thus can be manipulated at will */
 addBattleConf("go_delay",go_delay_setting);
}

[/cbox]

[cbox]

void go_delay_setting(const char *val) {
 ShowDebug("Received 'go_delay:%s'n",val);
 /* do anything with the var e.g. config_switch(val) */
}

[/cbox]

So it successfully reads the go_delay I placed in the import/battle.conf

But now, I don't have any idea on how would I be able to use it like this in a source:

battle_config.go_delay

Hope someone could help me..
default_smile.png


Thanks in advance!

 
Good Day samuel,

You Must include int that will serve as a battle_config. For instance.

for example:

Code:
int go_delay = 1;void go_delay_setting(const char *val) {    ShowDebug("Received 'go_delay:%s'n",val);    /* do anything with the var e.g. config_switch(val) */} if(!go_delay) { // do anything here }
 
Last edited by a moderator:
Hmm, will tru this once I get home.

But just want to ask if this thing I'm doing is really possible in plugin.

Define the delay in conf file and hooks will read it.

Whenever I change the value in conf file and reload battleconf, hooks will read the new value.

Thanks!

 
Actually you don't need a conf file.. you can define it directly in your plugins. use my costume plugins for example.. I used reserved_costume_id as battle_conf and I didn't include it in conf file.

 
Alright! I'm really lookibg for examples
default_biggrin.png
Forgot that plugin
default_smile.png
Will look into it, thanks!

 
It's my pleasure. please let me know if it helps and will mark your post Solved
default_smile.png


 
Last edited by a moderator:
You can actually use battle_config.variable_name variables in plugin at your will, the only thing is that you'll need to replace battle_config. with battle->bc->, and don't forget to fetch battle symbol for plugin not to crash.

Example: battle_config.go_delay becomes battle->bc->go_delay to be used inside plugins.

 
You can actually use battle_config.variable_name variables in plugin at your will, the only thing is that you'll need to replace battle_config. with battle->bc->, and don't forget to fetch battle symbol for plugin not to crash.

Example: battle_config.go_delay becomes battle->bc->go_delay to be used inside plugins.
FYI your example requires Source modification for new configured battle_config. 
default_smile.png


 
Last edited by a moderator:
Back
Top