viewing paste topic/7157 - bst.diff | Diff

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
 src/map/atcommand.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 src/map/pc.h        |  1 +
 2 files changed, 43 insertions(+)
 
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index b5e8fa7..e956dc6 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -9374,6 +9374,47 @@ static inline void atcmd_channel_help(int fd, const char *command, bool can_crea
    clif->message(fd,atcmd_output);
    return true;
 }
+
+ACMD(bst) {
+   int announcement_delay = 5;
+   if ( !message || !*message ) {
+       clif->message(fd, "Please, enter a message (usage: @bst <message>).");
+       return false;
+   }
+   else if ( sd->bst_delay + announcement_delay > (int)time(NULL) ) {
+       char atcmd_output[CHAT_SIZE_MAX];
+       safesnprintf( atcmd_output, CHAT_SIZE_MAX, "There is a %d seconds delay of using this command again.", announcement_delay );
+       clif->message( fd, atcmd_output );
+       return false;
+   }
+   else if ( ( message[0] == 'B' ||  message[0] == 'S' ||  message[0] == 'T' ) && message[1] == '>' ) {
+       struct s_mapiterator* iter = mapit->alloc( MAPIT_NORMAL, BL_PC );
+       char atcmd_output[CHAT_SIZE_MAX];
+       short msg_len = 0;
+       int announcement_color = 0xFFC0CB;
+       int colorcode = (announcement_color & 0x0000FF) << 16 | (announcement_color & 0x00FF00) | (announcement_color & 0xFF0000) >> 16;
+       TBL_PC *psd;
+       safesnprintf( atcmd_output, CHAT_SIZE_MAX, "[Market] %s : %s", sd->status.name, message );
+       msg_len = strlen(atcmd_output) +1;
+       for ( psd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); psd = (TBL_PC*)mapit->next(iter) ) {
+           WFIFOHEAD( psd->fd, msg_len + 12 );
+           WFIFOW( psd->fd, 0 ) = 0x2C1;
+           WFIFOW( psd->fd, 2 ) = msg_len + 12;
+           WFIFOL( psd->fd, 4 ) = 0;
+           WFIFOL( psd->fd, 8 ) = colorcode;
+           safestrncpy( (char*)WFIFOP( psd->fd,12 ), atcmd_output, msg_len );
+           WFIFOSET( psd->fd, msg_len + 12 );
+       }       
+       mapit->free(iter);
+       sd->bst_delay = (int)time(NULL);
+       return true;
+   }
+   else {
+       clif->message( fd, "Market Symbol is Needed when using this command ( B> S> T> )." );
+       return false;
+   }
+}
+
 /**
  * Fills the reference of available commands in atcommand DBMap
  **/
@@ -9384,6 +9425,7 @@ void atcommand_basecommands(void) {
     * Command reference list, place the base of your commands here
     **/
    AtCommandInfo atcommand_base[] = {
+       ACMD_DEF(bst),
        ACMD_DEF2("warp", mapmove),
        ACMD_DEF(where),
        ACMD_DEF(jumpto),
diff --git a/src/map/pc.h b/src/map/pc.h
index bec4522..2de6452 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -547,6 +547,7 @@ struct map_session_data {
    const char* delunit_prevfile;
    int delunit_prevline;
 
+   int bst_delay;
 };
 
 #define EQP_WEAPON EQP_HAND_R
 
Viewed 1208 times, submitted by AnnieRuru.