viewing paste topic/4700- ally.c | C

Posted on the | Last edited on
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
//===== Hercules Plugin ======================================
//= Ally - Atcommand
//===== By: ==================================================
//= Original by Zephir from brAthena
//= Convert by AnnieRuru
//===== Current Version: =====================================
//= 1.0
//===== Compatible With: ===================================== 
//= Hercules 2014-03-03
//===== Description: =========================================
//= able to send a message to guild alliance
//===== Topic ================================================
//= http://hercules.ws/board/topic/4700-
//===== Additional Comments: =================================  
//= nothing special about this mod ... but might be famous ?
//============================================================
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../common/HPMi.h"
#include "../common/strlib.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 = {
    "ally",         // Plugin name
    SERVER_TYPE_MAP,// Which server types this plugin works with?
    "1.0",          // Plugin version
    HPM_VERSION,    // HPM Version (don't change, macro is automatically updated)
};
 
ACMD(ally) {
    if ( !message || !*message )
        return false;
    else if ( sd->status.guild_id == 0 ) {
        clif->message( fd, "You don't have a guild." );
        return false;
    }
    else if ( sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] || sd->sc.data[SC_NOCHAT] )
        return true;
    else if ( battle->bc->min_chat_delay ) {
        if ( DIFF_TICK( sd->cantalk_tick, timer->gettick() ) > 0 )
            return true;
        sd->cantalk_tick = timer->gettick() + battle->bc->min_chat_delay;
    }
    else {
        struct guild* g = guild->search( sd->status.guild_id );
        int i;
        char atcmd_output[CHAT_SIZE_MAX];
    //  safesnprintf( atcmd_output, CHAT_SIZE_MAX, "[Alliance] %s : %s", sd->status.name, message );
        safesnprintf( atcmd_output, CHAT_SIZE_MAX, "[%s] %s : %s", g->name, sd->status.name, message );
        guild->recv_message( sd->status.guild_id, sd->status.account_id, atcmd_output, strlen(atcmd_output) );
        for ( i = 0; i < guild->get_alliance_count( g, 0 ); i++ )
            guild->recv_message( g->alliance[i].guild_id, sd->status.account_id, atcmd_output, strlen(atcmd_output) );
        logs->chat( LOG_CHAT_GUILD, sd->status.guild_id, sd->status.char_id, sd->status.account_id, mapindex_id2name( sd->mapindex ), sd->bl.x, sd->bl.y, NULL, message);
    }
    return true;
}
 
HPExport void plugin_init (void) {
    atcommand = GET_SYMBOL("atcommand");
    clif = GET_SYMBOL("clif");
    battle = GET_SYMBOL("battle");
    mapindex = GET_SYMBOL("mapindex");
    timer = GET_SYMBOL("timer");
    guild = GET_SYMBOL("guild");
    logs = GET_SYMBOL("logs");
    strlib = GET_SYMBOL("strlib");
 
    addAtcommand("ally",ally);
}
Viewed 1815 times, submitted by AnnieRuru.