diff options
Diffstat (limited to 'src/map/atcommand.c')
-rw-r--r-- | src/map/atcommand.c | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index afa22b392..15f75d55a 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -85,6 +85,17 @@ static AtCommandInfo* get_atcommandinfo_byname(const char *name); // @help static const char* atcommand_checkalias(const char *aliasname); // @help static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand); // @help +// @commands (script-based) +struct Atcmd_Binding* get_atcommandbind_byname(const char* name) +{ + int i = 0; + if( *name == atcommand_symbol || *name == charcommand_symbol ) + name++; // for backwards compatibility + ARR_FIND( 0, ARRAYLENGTH(atcmd_binding), i, strcmp(atcmd_binding[i].command, name) == 0 ); + return ( i < ARRAYLENGTH(atcmd_binding) ) ? &atcmd_binding[i] : NULL; + return NULL; +} + //----------------------------------------------------------- // Return the message string of the specified number by [Yor] //----------------------------------------------------------- @@ -8987,6 +8998,9 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message TBL_PC * ssd = NULL; //sd for target AtCommandInfo * info; + // @commands (script based) + Atcmd_Binding * binding; + nullpo_retr(false, sd); //Shouldn't happen @@ -9063,7 +9077,33 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message //check to see if any params exist within this command if( sscanf(atcmd_msg, "%99s %99[^\n]", command, params) < 2 ) params[0] = '\0'; - + + // @commands (script based) + if(type == 1) { + // Check if the command initiated is a character command + if (*message == charcommand_symbol && + (ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) + { + sprintf(output, "%s failed. Player not found.", command); + clif_displaymessage(fd, output); + return true; + } + + // Get atcommand binding + binding = get_atcommandbind_byname(command); + + // Check if the binding isn't NULL and there is a NPC event, level of usage met, et cetera + if( binding != NULL && binding->npc_event[0] && + ((*atcmd_msg == atcommand_symbol && pc_get_group_level(sd) >= binding->level) || + (*atcmd_msg == charcommand_symbol && pc_get_group_level(sd) >= binding->level2))) + { + // Check if self or character invoking; if self == character invoked, then self invoke. + bool invokeFlag = ((*atcmd_msg == atcommand_symbol) ? 1 : 0); + npc_do_atcmd_event((invokeFlag ? sd : ssd), command, params, binding->npc_event); + return true; + } + } + //Grab the command information and check for the proper GM level required to use it or if the command exists info = get_atcommandinfo_byname(atcommand_checkalias(command + 1)); if (info == NULL) { |