diff options
author | Haru <haru@dotalux.com> | 2019-06-30 22:39:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-30 22:39:01 +0200 |
commit | 33b0658e174fdd50e513daa807a8824f959ded44 (patch) | |
tree | a26222da841ffba092f83f28c4add8152dac1ea1 /src/map | |
parent | bb46b50d5890c7b2e8374274cdbb85cc4cf330dd (diff) | |
parent | f909e40bbc8783139fd6ccfb6f7108206e81c601 (diff) | |
download | hercules-33b0658e174fdd50e513daa807a8824f959ded44.tar.gz hercules-33b0658e174fdd50e513daa807a8824f959ded44.tar.bz2 hercules-33b0658e174fdd50e513daa807a8824f959ded44.tar.xz hercules-33b0658e174fdd50e513daa807a8824f959ded44.zip |
Merge pull request #2476 from Emistry/atcommand_reloadnpc
Add new atcommand *reloadnpc
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/atcommand.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 97af2afff..3c454011f 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -4464,6 +4464,38 @@ ACMD(unloadnpc) return true; } +/// Unload existing NPC within the NPC file and reload it. +/// Usage: @reloadnpc npc/sample_npc.txt +ACMD(reloadnpc) +{ + if (!*message) { + clif->message(fd, msg_fd(fd, 1385)); // Usage: @unloadnpcfile <file name> + return false; + } else if (npc->unloadfile(message) == true) { + clif->message(fd, msg_fd(fd, 1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed. + + FILE *fp = fopen(message, "r"); + // check if script file exists + if (fp == NULL) { + clif->message(fd, msg_fd(fd, 261)); + return false; + } + fclose(fp); + + // add to list of script sources and run it + npc->addsrcfile(message); + npc->parsesrcfile(message, true); + npc->read_event_script(); + + clif->message(fd, msg_fd(fd, 262)); + } else { + clif->message(fd, msg_fd(fd, 1387)); // File not found. + return false; + } + + return true; +} + /*========================================== * time in txt for time command (by [Yor]) *------------------------------------------*/ @@ -10118,6 +10150,7 @@ static void atcommand_basecommands(void) ACMD_DEF(addperm), ACMD_DEF2("rmvperm", addperm), ACMD_DEF(unloadnpcfile), + ACMD_DEF(reloadnpc), ACMD_DEF(cart), ACMD_DEF(cashmount), ACMD_DEF(join), |