Jump to content
  • 0
Akkarin

AtCommand plugin overwrite?

Question

Can we use this method of adding Atcommands to overwrite the default commands?

 

For example, i have a re-vamped @hide, and i'm currently using it with the bindatcmd script. Is it possible for me to do away with the npc script version and use the plugin system as the method to overwrite the original @hide?

 

I've given it a go but the mapserver just states "Server received crash signal" and disconnects. Just wondered if this is even supported before i jump into it.

 

Thanks :)

Share this post


Link to post
Share on other sites

7 answers to this question

Recommended Posts

  • 0

Thanks for the reply ossi0110 :)

 

The following is what i've thrown into nhide.c:

[cbox]

#include <stdio.h>

#include <string.h>

#include "../common/HPMi.h"

#include "../map/script.h"

#include "../map/clif.h"

#include "../map/pc.h"

#include "../map/atcommand.h"

 

HPExport struct hplugin_info pinfo = {

"nhide", // Plugin name

SERVER_TYPE_MAP,// Which server types this plugin works with?

"1.0", // Plugin version

HPM_VERSION, // HPM Version (don't change, macro is automatically updated)

};

ACMD(hide)

{

if (sd->sc.option & OPTION_INVISIBLE) {

sd->sc.option &= ~OPTION_INVISIBLE;

if (sd->disguise != -1 )

status->set_viewdata(&sd->bl, sd->disguise);

else

status->set_viewdata(&sd->bl, sd->status.class_);

clif->specialeffect(&sd->bl, 587, ALL_CLIENT); // Smoke effect

clif->specialeffect(&sd->bl, 589, ALL_CLIENT); // Smoke effect

clif->message(fd, msg_txt(10)); // Invisible: Off

 

// increment the number of pvp players on the map

map->list[sd->bl.m].users_pvp++;

 

if( map->list[sd->bl.m].flag.pvp && !map->list[sd->bl.m].flag.pvp_nocalcrank ) {

// register the player for ranking calculations

sd->pvp_timer = timer->add( timer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0 );

}

//bugreport:2266

map->foreachinmovearea(clif->insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);

} else {

sd->sc.option |= OPTION_INVISIBLE;

sd->vd.class_ = INVISIBLE_CLASS;

clif->specialeffect(&sd->bl, 587, ALL_CLIENT); // Smoke effect

clif->specialeffect(&sd->bl, 589, ALL_CLIENT); // Smoke effect

clif->message(fd, msg_txt(11)); // Invisible: On

 

// decrement the number of pvp players on the map

map->list[sd->bl.m].users_pvp--;

if( map->list[sd->bl.m].flag.pvp && !map->list[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER ) {

// unregister the player for ranking

timer->delete( sd->pvp_timer, pc->calc_pvprank_timer );

sd->pvp_timer = INVALID_TIMER;

}

}

clif->changeoption(&sd->bl);

 

return true;

}

/* Server Startup */

HPExport void plugin_init (void)

{

clif = GET_SYMBOL("clif");

script = GET_SYMBOL("script");

pc = GET_SYMBOL("pc");

atcommand = GET_SYMBOL("atcommand");

 

if( HPMi->addCommand != NULL ) {//link our '@sample' command

HPMi->addCommand("hide",ACMD_A(nhide));

}

}[/cbox]

 

Basically all i've done is copied the original @hide code and added two smoke effects. The source version i have from 4-5 years ago obviously wouldn't work with Hercules, so i've tried to just slot them into this instead. I'm trying to use it as a plugin so i can turn it off and on without having to recompile everytime i want to stop the purple smoke from showing.

 

p.s. i've -never- played with the source before, so i'm a big nab @.@

Edited by Akkarin

Share this post


Link to post
Share on other sites
  • 0

change 

 

clif->message(fd, msg_txt(10)); // Invisible: Offclif->message(fd, msg_txt(11)); // Invisible: ON

TO

clif->message(fd, atcommand->msg_table[10]); // Invisible: Offclif->message(fd, atcommand->msg_table[11]); // Invisible: On

 

 

and you didnt importet all Symbols , this is why you get  Map Server Crashes

 

Change

 

clif = GET_SYMBOL("clif");script = GET_SYMBOL("script");pc = GET_SYMBOL("pc");atcommand = GET_SYMBOL("atcommand");

 

TO

clif = GET_SYMBOL("clif");script = GET_SYMBOL("script");pc = GET_SYMBOL("pc");atcommand = GET_SYMBOL("atcommand");status = GET_SYMBOL("status");map = GET_SYMBOL("map");timer = GET_SYMBOL("timer"); 

 

last add the 2 more #includes at the header

 

#include "../map/map.h"#include "../map/status.h"
Edited by ossi0110

Share this post


Link to post
Share on other sites
  • 0

Thanks for that! I knew it'd be something i'd copied and pasted without reading through it properly to use the correct syntax/functions. I now get no errors.... however:

08:11:52[Status]: HPM: There are '4' plugins loaded, type 'plugins' to list them08:11:52[Debug]: HPM_map_atcommands: duplicate command 'hide', skipping...

I guess the plugin system can't be used to overwrite existing commands like the bindatcmd method does. Do you know if this is planned for the future or if this is intentional?

Share this post


Link to post
Share on other sites
  • 0

hmm I thought it was doing so (script command allows one to replace default with a plugins, I was under the impression atcommand was following the same logic), I'll go over it later today

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

×
×
  • Create New...

Important Information

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