viewing paste Unknown #18713 | 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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
// Oxxy (C) 2015, HPM plugin.
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#include "../common/HPMi.h"
#include "../common/malloc.h"
#include "../common/mmo.h"
#include "../common/socket.h"
#include "../common/strlib.h"
#include "../map/clif.h"
#include "../map/script.h"
#include "../map/pc.h"
 
#include "../common/HPMDataCheck.h" /* should always be the last file included! (if you don't make it last, it'll intentionally break compile time) */
 
HPExport struct hplugin_info pinfo = {
    "Chat Color",    // Plugin name
    SERVER_TYPE_MAP,// Which server types this plugin works with?
    "0.1",       // Plugin version
    HPM_VERSION, // HPM Version (don't change, macro is automatically updated)
};
 
/*ACMD(color) {
    if(!message || !*message) {
        clif->message(fd, "Usage: @color <color>");
        clif->message(fd, "<color> must be in hex format. Starting with 0x");
        clif->message(fd, "Example: @color 0x00FF00");
        if(pc_readglobalreg_str(sd,script->add_str("CHAT_COLOR$")) = "") {
            clif->message(fd, "Defaulting your color to green.");
            pc_setglobalreg_str(sd, script->add_str("CHAT_COLOR$"), "0x000000");
            return 1;
        }
        return -1;
    } else {
        pc_setglobalreg_str(sd, script->add_str("CHAT_COLOR$"), message);
        clif->message(fd, "Color has been set.");
    }
 
    return 1;
}*/
 
ACMD(setcolor) {
    unsigned char k;
    unsigned short msg_len = 1;
    char mout[40];
 
    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");
        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;
    }
 
    sd->fontcolor = pc_readglobalreg_str(*sd, script->add_str("CHAT_COLOR$"));
    msg_len += sprintf(mout, "Color changed to '%s'", script->add_str(CHAT_COLOR$));
 
    WFIFOHEAD(*fd,msg_len + 12);
    WFIFOW(*fd,0) = 0x2C1;
    WFIFOW(*fd,2) = msg_len + 12;
    WFIFOL(*fd,4) = 0;
    WFIFOL(*fd,8) = channel->config->colors[k];
    safestrncpy((char*)WFIFOP(fd,12), mout, msg_len);
    WFIFOSET(*fd, msg_len + 12);
    return true;
}
 
HPExport void plugin_init (void) {
    char *server_type;
    char *server_name;
 
    /* core vars */
    iMalloc = GET_SYMBOL("iMalloc");
    script = GET_SYMBOL("script");
    clif = GET_SYMBOL("clif");
    pc = GET_SYMBOL("pc");
 
    addAtcommand("setcolor", color);
    //addScriptCommand("color","is",color)
}
 
HPExport void server_online (void) {
    ShowInfo ("'%s' Plugin by Oxxy. Version '%s'\n",pinfo.name,pinfo.version);
}
Viewed 764 times, submitted by Guest.