viewing paste topic/7023- dispbottomcolor.c | 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
//===== Hercules Plugin ======================================
//= *dispbottomcolor Script Command
//===== By: ==================================================
//= AnnieRuru
//===== Current Version: =====================================
//= 1.1
//===== Compatible With: ===================================== 
//= Hercules 2014-09-02
//===== Description: =========================================
//= just dispbottom with colors ... what else ?
//===== Topic ================================================
//= http://hercules.ws/board/topic/7023-dispbottomcolor/
//===== Additional Comments: =================================  
//= dispbottomcolor <message> , <color code>;
//============================================================
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../map/pc.h"
#include "../map/script.h"
#include "../common/HPMi.h"
#include "../common/socket.h"
#include "../common/strlib.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 = {
    "dispbottomcolor",  // 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)
};
 
BUILDIN(dispbottomcolor) {
    TBL_PC *sd = script->rid2sd(st);
    if ( sd ) {
        const char *message = script_getstr(st,2);
        unsigned short msg_len = strlen( message ) +1;
        int color = script_getnum(st,3);
        int colorcode = (color & 0x0000FF) << 16 | (color & 0x00FF00) | (color & 0xFF0000) >> 16;
        WFIFOHEAD( sd->fd, msg_len + 12 );
        WFIFOW( sd->fd, 0 ) = 0x2C1;
        WFIFOW( sd->fd, 2 ) = msg_len + 12;
        WFIFOL( sd->fd, 4 ) = 0;
        WFIFOL( sd->fd, 8 ) = colorcode;
        safestrncpy( (char*)WFIFOP( sd->fd,12 ), message, msg_len );
        WFIFOSET( sd->fd, msg_len + 12 );
    }
    return true;
}
 
HPExport void plugin_init (void) {
    script = GET_SYMBOL("script");
    session = GET_SYMBOL("session");
    strlib = GET_SYMBOL("strlib");
    sockt = GET_SYMBOL("sockt");
    addScriptCommand( "dispbottomcolor", "si", dispbottomcolor );
}
Viewed 1478 times, submitted by AnnieRuru.