viewing paste Unknown #13475 | Text

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
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);
}
 
Viewed 703 times, submitted by Guest.