viewing paste Unknown #18714 | C#

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
ACMD(setcolor) {
    unsigned short msg_len = 1;
    char mout[40];
    unsigned char cc = script->add_str("CHAT_COLOR$");
 
    if( !message || !*message ) {
        clif->message(fd, "Usage: @setcolor <color>");
        clif->message(fd, "<color> must be in hex format. Starting with 0x");
        clif->message(fd, "Example: @color 0x00FF00");
        return 0;
        //if(pc_readglobalreg_str(sd,script->add_str("CHAT_COLOR$")) = "") {
        //  clif->message(fd, "Defaulting your color to green.");
        //  sd->fontcolor = 0;
        //  return 1;
        //}
    }
 
    if( message[0] == '0' ) {
        sd->fontcolor = 0;
        return true;
    }
 
    pc_setglobalreg_str(sd, cc, message);
    sd->fontcolor = pc_readglobalreg_str(sd, cc);
    //sd->fontcolor = pc_readglobalreg_str(sd, cc);
    msg_len += sprintf(mout, "Color changed to '%s'", cc);
 
    WFIFOHEAD(fd,msg_len + 12);
    WFIFOW(fd,0) = 0x2C1;
    WFIFOW(fd,2) = msg_len + 12;
    WFIFOL(fd,4) = 0;
    WFIFOL(fd,8) = sd->fontcolor;
    safestrncpy((char*)WFIFOP(fd,12), mout, msg_len);
    WFIFOSET(fd, msg_len + 12);
    return true;
}
Viewed 642 times, submitted by Guest.