viewing paste Unknown #6099 | Text

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
+int atcommand_broadcastchat(const int fd, struct map_session_data* sd, const char* command, const char* message)
+{
+   char msg[CHAT_SIZE_MAX];
+   short type;
+   nullpo_retr(-1, sd);
+
+   if(strcmp(command+1,"market") == 0)
+       type = 1;
+   else if(strcmp(command+1,"recruit") == 0)
+       type = 2;
+   else if(strcmp(command+1,"reloadchannelcolor") == 0)
+       type = 3;
+   else
+       return -1;
+   
+   if(!message || !*message || sscanf(message, "%255s",msg) < 1)
+   {
+       sprintf(atcmd_output,"To enable/disable, use: @%s <on/off>",command+1);
+       clif_displaymessage(sd->fd,atcmd_output);
+       sprintf(atcmd_output,"To send the message, use: @%s <message>",command+1);
+       clif_displaymessage(sd->fd,atcmd_output);
+       return -1;
+   }
+
+   if(type == 3)
+   {
+       clif_load_marketrecruit_color();
+       clif_displaymessage(fd, "Database color of Market and Recruit channel had been reloaded");
+       return 0;
+   }
+   
+   if(strcmp(msg,"on") == 0)
+   {
+       switch(type)
+       {
+           case 1:
+               sd->state.market_chnl = 1;
+               break;
+           case 2:
+               sd->state.recruit_chnl = 1;
+               break;
+       }
+       sprintf(atcmd_output,"%s is %s now.",command+1,"ON");
+       clif_displaymessage(sd->fd,atcmd_output);
+       return 0;
+   }
+   else if(strcmp(msg,"off") == 0)
+   {
+       switch(type)
+       {
+           case 1:
+               sd->state.market_chnl = 0;
+               break;
+           case 2:
+               sd->state.recruit_chnl = 0;
+               break;
+       }
+       sprintf(atcmd_output,"%s is %s now.",command+1,"OFF");
+       clif_displaymessage(sd->fd,atcmd_output);
+       return 0;
+   }
+   else
+   {
+       double diff_tick = DIFF_TICK(sd->broadcastchat_tick,gettick());
+       if( (type == 1 && !sd->state.market_chnl) || (type == 2 && !sd->state.recruit_chnl) )
+       {   
+           sprintf(atcmd_output,"You must enable '%s' first by using, @%s <on/off>",command+1,command+1);
+           clif_displaymessage(sd->fd,atcmd_output);
+           return -1;
+       }
+       if(diff_tick > 0)
+       {
+           sprintf(atcmd_output,"You must wait %0.1f second(s) to use this command.",diff_tick/1000.);
+           clif_displaymessage(sd->fd,atcmd_output);
+           return -1;
+       }
+       snprintf(atcmd_output, CHAT_SIZE_MAX - 5, "[ %s ] %s : %s",(type == 1)?"Market":"Recruit",sd->status.name, msg);
+       clif_marketrecruit_msg(sd,atcmd_output,type);
+       sd->broadcastchat_tick = gettick()+battle_config.broadcastchat_interval;
+   }
+
+   return 0;
+}
Viewed 720 times, submitted by Guest.