int atcommand_sub(struct script_state* st,int type) { TBL_PC dummy_sd; TBL_PC* sd; int fd; const char* cmd; cmd = script_getstr(st,2); if (st->rid) { sd = script_rid2sd(st); fd = sd->fd; } else { //Use a dummy character. sd = &dummy_sd; fd = 0; memset(&dummy_sd, 0, sizeof(TBL_PC)); if (st->oid) { struct block_list* bl = map_id2bl(st->oid); memcpy(&dummy_sd.bl, bl, sizeof(struct block_list)); if (bl->type == BL_NPC) safestrncpy(dummy_sd.status.name, ((TBL_NPC*)bl)->name, NAME_LENGTH); } } if (!is_atcommand(fd, sd, cmd, type)) { ShowWarning("script: buildin_atcommand: failed to execute command '%s'\n", cmd); script_reportsrc(st); return 1; } return SCRIPT_CMD_SUCCESS; } /*========================================== * gmcommand [MouseJstr] *------------------------------------------*/ BUILDIN_FUNC(atcommand) { return atcommand_sub(st,0); }