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 )."); + 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