Jump to content
  • 0
Sign in to follow this  
Samuel

Plugin Battle Conf settings

Question

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.. :)

 

Thanks in advance!

Share this post


Link to post
Share on other sites

10 answers to this question

Recommended Posts

  • 0

Good Day samuel,

 

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

 

for example:

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 }

Share this post


Link to post
Share on other sites
  • 0

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!

Share this post


Link to post
Share on other sites
  • 0

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.

Share this post


Link to post
Share on other sites
  • 0

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.

Share this post


Link to post
Share on other sites
  • 0

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.  :)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.