Guest User

Destrojer

a guest
Nov 2nd, 2009
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 18.69 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #if defined MAX_PLAYERS
  4.     #undef MAX_PLAYERS
  5. #endif
  6.  
  7. #define MAX_PLAYERS             (200)       // Slot's
  8. #define MAX_MESSAGE             (20)        // Max. save message
  9. #define MAX_MESSAGE_STRING      (74)        /* max message len + 24 nick
  10.                                                 (50 + 24 )*/
  11.  
  12. #define IRC_LIST                (0)         // List's ID 1
  13. #define IRC_CHANNEL_NAME        (1)         // List's ID 2
  14. #define IRC_CHANNEL_PASS        (2)         // List's ID 3
  15. #define IRC_CHANNEL_DEL         (3)         // List's ID 4
  16. #define IRC_CHANNEL_JOIN        (4)         // List's ID 5
  17. #define IRC_CHANNEL_PASS2       (5)         // List's ID 6
  18. #define IRC_MESSAGE             (6)         // List's ID 7
  19. #define IRC_MESSAGE_SEND        (7)         // List's ID 8
  20. #define IRC_CHANNEL_DELETE      (8)         // List's ID 9
  21. #define IRC_CHANNEL_MSGBOX      (9)         // List's ID 10
  22. #define IRC_MESSAGE_MSGBOX      (10)        // List's ID 11
  23.  
  24. #define MAX_CHANNELS            (21)        // Max channels
  25. #define MAX_CHANNELS_NAME       (10)        // Max channel's name len
  26. #define MAX_CHANNELS_PASS       (10)        // Max channel's pass len
  27.  
  28. #define COLOR_GREEN             (0x00CC00FF)
  29. #define COLOR_RED               (0xCC0000FF)
  30. #define COLOR_YELLOW            (0xC5FF3EFF)
  31. #define COLOR_ORANGE            (0xFF9600FF)
  32.  
  33. #define Print(%1) { \
  34.  print(\
  35.  "\nIRC's Channel system by Conan/\x44\x65\x73\x74\x72\x6f\x6a\x65\x72\n");}
  36.  
  37. enum pInfo
  38. {
  39.     ircChannel,
  40.     ircJoin,
  41.     createChannel,
  42.     bool:windowOpen
  43.  
  44. }
  45.  
  46. enum channels
  47. {
  48.     names[MAX_CHANNELS_NAME],
  49.     pass[MAX_CHANNELS_PASS],
  50.     message,
  51.     bool:active,
  52.     bool:havePassword
  53. }
  54.  
  55. new
  56.     playerInfo[MAX_PLAYERS][pInfo],
  57.     ircChannels[MAX_CHANNELS][channels],
  58.     chatHistory[MAX_CHANNELS][MAX_MESSAGE][MAX_MESSAGE_STRING];
  59.  
  60. stock PlayerName(playerid)
  61. {
  62.     new name[24];
  63.    
  64.     GetPlayerName(playerid, name, sizeof(name));
  65.    
  66.     return name;
  67. }
  68.  
  69. public OnFilterScriptInit()
  70. {
  71.     Print("IRC's Channel system by Conan/Destrojer")
  72.    
  73.     return 1;
  74. }
  75.  
  76. public OnFilterScriptExit()
  77. {
  78.     print("Filter Script unloaded");
  79.     return 1;
  80. }
  81.  
  82. public OnPlayerDisconnect(playerid, reason)
  83. {
  84.     if(playerInfo[playerid][createChannel] != 0)
  85.     {
  86.         ircChannels[playerInfo[playerid][createChannel]][active] = false;
  87.         strdel(ircChannels[playerInfo[playerid][createChannel]][names], 0, 10);
  88.         strdel(ircChannels[playerInfo[playerid][createChannel]][pass], 0, 10);
  89.  
  90.         for(new i = 1; i < MAX_MESSAGE; i++)
  91.             strdel(chatHistory[playerInfo[playerid][createChannel]][i], 0,
  92.              MAX_MESSAGE_STRING);
  93.  
  94.         for(new i, gmax = GetMaxPlayers(); i < gmax; i++)
  95.         {
  96.             if(!IsPlayerConnected(i))
  97.                 continue;
  98.             if(playerInfo[i][ircChannel] == playerInfo[playerid][ircChannel])
  99.             {
  100.                 ShowPlayerDialog(playerid, IRC_CHANNEL_MSGBOX,
  101.                  DIALOG_STYLE_MSGBOX,
  102.                  "Disconnected",
  103.                  "Channel was deleted!",
  104.                  "OK",
  105.                  "Close");
  106.                    
  107.                 playerInfo[i][ircChannel] = 0;
  108.             }
  109.         }
  110.         playerInfo[playerid][createChannel] = 0;
  111.     }
  112.    
  113.     playerInfo[playerid][ircChannel] = 0;
  114.    
  115.     return 1;
  116. }
  117.  
  118. public OnPlayerCommandText(playerid, cmdtext[])
  119. {
  120.     if (strcmp(cmdtext[1], "ircoptions", true) == 0)
  121.     {
  122.         #define TITLE                       "Select option"
  123.         #define OPTIONS                     "Create channel\nDelete/Leave\nJoin"
  124.        
  125.         ShowPlayerDialog(playerid, IRC_LIST, DIALOG_STYLE_LIST, TITLE, OPTIONS,
  126.          "Next",
  127.          "Close");
  128.        
  129.         return 1;
  130.     }
  131.    
  132.     if (strcmp(cmdtext[1], "irc", true) == 0)
  133.     {
  134.         new strTitle[45], strChat[2500];
  135.        
  136.         if(playerInfo[playerid][ircChannel] == 0)
  137.             return SendClientMessage(playerid, COLOR_RED,
  138.              "You are not in any irc channel!");
  139.        
  140.         format(strTitle, sizeof(strTitle),
  141.          "Channel #%s",
  142.          ircChannels[playerInfo[playerid][ircChannel]][names]);
  143.  
  144.         for(new i = 1; i < MAX_MESSAGE; i++)
  145.         {
  146.             if(!strlen(chatHistory[playerInfo[playerid][ircChannel]][i]))
  147.                 continue;
  148.             strcat(strChat, chatHistory[playerInfo[playerid][ircChannel]][i],
  149.              sizeof(strChat));
  150.         }
  151.        
  152.         if(!strlen(strChat))
  153.         {
  154.             ShowPlayerDialog(playerid, IRC_MESSAGE, DIALOG_STYLE_LIST, strTitle,
  155.              "No message",
  156.              "Write",
  157.              "Hide");
  158.                
  159.             return 1;
  160.         }
  161.        
  162.         ShowPlayerDialog(playerid, IRC_MESSAGE, DIALOG_STYLE_LIST, strTitle,
  163.          strChat,
  164.          "Write",
  165.          "Hide");
  166.  
  167.         return 1;
  168.     }
  169.    
  170.     return 0;
  171. }
  172.  
  173. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  174. {
  175.     if(dialogid == IRC_MESSAGE_MSGBOX)
  176.     {
  177.         new strTitle[45], strChat[2500];
  178.        
  179.         format(strTitle, sizeof(strTitle), "Channel #%s",
  180.          ircChannels[playerInfo[playerid][ircChannel]][names]);
  181.  
  182.         for(new i = 1; i < MAX_MESSAGE; i++)
  183.         {
  184.             if(!strlen(chatHistory[playerInfo[playerid][ircChannel]][i]))
  185.                 continue;
  186.             strcat(strChat, chatHistory[playerInfo[playerid][ircChannel]][i],
  187.              sizeof(strChat));
  188.         }
  189.  
  190.         playerInfo[playerid][windowOpen] = true;
  191.  
  192.         if(!strlen(strChat))
  193.         {
  194.             ShowPlayerDialog(playerid, IRC_MESSAGE, DIALOG_STYLE_LIST, strTitle,
  195.              "No message",
  196.              "Write",
  197.              "Hide");
  198.                
  199.             return 1;
  200.         }
  201.  
  202.         ShowPlayerDialog(playerid, IRC_MESSAGE, DIALOG_STYLE_LIST, strTitle,
  203.          strChat,
  204.          "Write",
  205.          "Hide");
  206.  
  207.         return 1;
  208.     }
  209.    
  210.     if(response == 1)
  211.     {
  212.         if(dialogid == IRC_LIST)
  213.         {
  214.             switch(listitem)
  215.             {
  216.                 case 0:
  217.                 {
  218.                     if(playerInfo[playerid][createChannel] != 0)
  219.                         return SendClientMessage(playerid, COLOR_RED,
  220.                          "You have one channel. You can not have more!");
  221.                     for(new i = 1; i < MAX_CHANNELS; i++)
  222.                     {
  223.                         if(ircChannels[i][active] == false)
  224.                         {
  225.                             ShowPlayerDialog(playerid, IRC_CHANNEL_NAME,
  226.                              DIALOG_STYLE_INPUT,
  227.                              "Name",
  228.                              "",
  229.                              "Ok",
  230.                              "Cancel");
  231.                                
  232.                             playerInfo[playerid][createChannel] = i;
  233.                             return 1;
  234.                         }
  235.                     }
  236.                 }
  237.                 case 1:
  238.                 {
  239.                     new strChannels[220];
  240.                     for(new i = 1; i < MAX_CHANNELS; i++)
  241.                     {
  242.                         new str[20];
  243.                         format(str, sizeof(str), "\n#%s",
  244.                          ircChannels[i][names]);
  245.                                
  246.                         strcat(strChannels, str, sizeof(strChannels));
  247.                     }
  248.                    
  249.                     if(!strlen(ircChannels[1][names]))
  250.                     {
  251.                         ShowPlayerDialog(playerid, IRC_CHANNEL_MSGBOX,
  252.                          DIALOG_STYLE_MSGBOX,
  253.                          "Select channel",
  254.                          "No channels",
  255.                          "Ok",
  256.                          "Close");
  257.                          
  258.                         return 1;
  259.                     }
  260.                    
  261.                     ShowPlayerDialog(playerid, IRC_CHANNEL_DEL,
  262.                      DIALOG_STYLE_LIST,
  263.                      "Select channel",
  264.                      strChannels,
  265.                      "Delete",
  266.                      "Close");
  267.  
  268.                     return 1;
  269.                 }
  270.                 case 2:
  271.                 {
  272.                     new strChannels[220];
  273.                     for(new i = 1; i < MAX_CHANNELS; i++)
  274.                     {
  275.                         new str[20];
  276.                         format(str, sizeof(str), "\n#%s",
  277.                          ircChannels[i][names]);
  278.  
  279.                         strcat(strChannels, str, sizeof(strChannels));
  280.                     }
  281.                    
  282.                     if(!strlen(ircChannels[1][names]))
  283.                     {
  284.                         ShowPlayerDialog(playerid, IRC_CHANNEL_MSGBOX,
  285.                          DIALOG_STYLE_MSGBOX,
  286.                          "Select channel",
  287.                          "No channels",
  288.                          "Ok",
  289.                          "Close");
  290.                            
  291.                         return 1;
  292.                     }
  293.                    
  294.                     ShowPlayerDialog(playerid, IRC_CHANNEL_JOIN,
  295.                      DIALOG_STYLE_LIST,
  296.                      "Select channel",
  297.                      strChannels,
  298.                      "Join",
  299.                      "Close");
  300.  
  301.                     return 1;
  302.                 }
  303.             }
  304.            
  305.             return 1;
  306.         }
  307.        
  308.         if(dialogid == IRC_CHANNEL_NAME)
  309.         {
  310.             if(strlen(inputtext) >= MAX_CHANNELS_NAME || strlen(inputtext) <= 1)
  311.             {
  312.                 ShowPlayerDialog(playerid, IRC_CHANNEL_NAME, DIALOG_STYLE_INPUT,
  313.                  "Name",
  314.                  "",
  315.                  "Ok",
  316.                  "Cancel");
  317.                    
  318.                 SendClientMessage(playerid, COLOR_RED,
  319.                  "Wrong name!");
  320.  
  321.                 return 1;
  322.             }
  323.            
  324.             format(ircChannels[playerInfo[playerid][createChannel]][names],
  325.              MAX_CHANNELS_NAME,
  326.              "%s",
  327.              inputtext);
  328.            
  329.             ircChannels[playerInfo[playerid][createChannel]][active] = true;
  330.             ShowPlayerDialog(playerid, IRC_CHANNEL_PASS, DIALOG_STYLE_INPUT,
  331.              "Password",
  332.              "",
  333.              "Ok",
  334.              "NO PASS");
  335.  
  336.             return 1;
  337.         }
  338.        
  339.         if(dialogid == IRC_CHANNEL_PASS)
  340.         {
  341.             new strInfo[45];
  342.             if(strlen(inputtext) >= MAX_CHANNELS_PASS || strlen(inputtext) <= 1)
  343.             {
  344.                 ShowPlayerDialog(playerid, IRC_CHANNEL_PASS, DIALOG_STYLE_INPUT,
  345.                  "Password",
  346.                  "",
  347.                  "Ok",
  348.                  "NO PASS");
  349.                    
  350.                 SendClientMessage(playerid, COLOR_RED,
  351.                  "Wrong password");
  352.  
  353.                 return 1;
  354.             }
  355.             format(ircChannels[playerInfo[playerid][createChannel]][pass],
  356.              MAX_CHANNELS_PASS,
  357.              "%s",
  358.              inputtext);
  359.                
  360.             format(strInfo, sizeof(strInfo), "Name: %s Password: %s",
  361.              ircChannels[playerInfo[playerid][createChannel]][names],
  362.              ircChannels[playerInfo[playerid][createChannel]][pass]);
  363.                
  364.             SendClientMessage(playerid, COLOR_GREEN, strInfo);
  365.            
  366.             SendClientMessage(playerid, COLOR_YELLOW,
  367.              "Use /irc to open dialog window");
  368.            
  369.             playerInfo[playerid][ircChannel] = playerInfo[playerid][createChannel];
  370.  
  371.             return 1;
  372.         }
  373.        
  374.         if(dialogid == IRC_CHANNEL_DEL)
  375.         {
  376.             if(ircChannels[(listitem + 1)][active] == false)
  377.             {
  378.                 SendClientMessage(playerid, COLOR_RED,
  379.                  "Sorry the channel does no exist!");
  380.  
  381.                 return 1;
  382.             }
  383.             if(strlen(ircChannels[playerInfo[playerid][createChannel]][pass]))
  384.             {
  385.                 ShowPlayerDialog(playerid, IRC_CHANNEL_DELETE,
  386.                  DIALOG_STYLE_INPUT,
  387.                  "Password",
  388.                  "",
  389.                  "Ok",
  390.                  "Cancel");
  391.                
  392.                 return 1;
  393.             }
  394.            
  395.             if(!strlen(ircChannels[playerInfo[playerid][createChannel]][pass])
  396.              && playerInfo[playerid][createChannel] != 0)
  397.             {
  398.                 ircChannels[playerInfo[playerid][createChannel]][active] = false;
  399.                 strdel(ircChannels[playerInfo[playerid][createChannel]][names],
  400.                  0,
  401.                  10);
  402.                    
  403.                 strdel(ircChannels[playerInfo[playerid][createChannel]][pass],
  404.                  0,
  405.                  10);
  406.  
  407.                 for(new i = 1; i < MAX_MESSAGE; i++)
  408.                     strdel(chatHistory[playerInfo[playerid][createChannel]][i],
  409.                      0,
  410.                      MAX_MESSAGE_STRING);
  411.  
  412.                 for(new i, gmax = GetMaxPlayers(); i < gmax; i++)
  413.                 {
  414.                     if(!IsPlayerConnected(i))
  415.                         continue;
  416.                     if(playerInfo[i][ircChannel] == playerInfo[playerid][ircChannel])
  417.                     {
  418.                         ShowPlayerDialog(playerid, IRC_CHANNEL_MSGBOX,
  419.                          DIALOG_STYLE_MSGBOX,
  420.                          "Disconnected",
  421.                          "Channel was deleted!",
  422.                          "OK",
  423.                          "Close");
  424.  
  425.                         playerInfo[i][ircChannel] = 0;
  426.                     }
  427.                 }
  428.                 ircChannels[playerInfo[playerid][createChannel]][active] = false;
  429.                 strdel(ircChannels[playerInfo[playerid][createChannel]][names],
  430.                  0,
  431.                  10);
  432.                    
  433.                 strdel(ircChannels[playerInfo[playerid][createChannel]][pass],
  434.                     0,
  435.                     10);
  436.                    
  437.                 playerInfo[playerid][createChannel] = 0;
  438.                 SendClientMessage(playerid, COLOR_GREEN,
  439.                  "You deleted your IRC channel");
  440.                
  441.                 return 1;
  442.             }
  443.            
  444.             ShowPlayerDialog(playerid, IRC_CHANNEL_MSGBOX, DIALOG_STYLE_MSGBOX,
  445.              "Information",
  446.              "You are left channel",
  447.              "Ok",
  448.              "Close");
  449.                
  450.             playerInfo[playerid][ircChannel] = 0;
  451.            
  452.             return 1;
  453.         }
  454.        
  455.         if(dialogid == IRC_CHANNEL_DELETE)
  456.         {
  457.             if(strcmp(ircChannels[playerInfo[playerid][createChannel]][pass],
  458.              inputtext, false) == 0 && strlen(inputtext))
  459.             {
  460.                 ircChannels[playerInfo[playerid][createChannel]][active] = false;
  461.                 strdel(ircChannels[playerInfo[playerid][createChannel]][names],
  462.                  0,
  463.                  10);
  464.                    
  465.                 strdel(ircChannels[playerInfo[playerid][createChannel]][pass],
  466.                  0,
  467.                  10);
  468.                
  469.                 for(new i = 1; i < MAX_MESSAGE; i++)
  470.                     strdel(chatHistory[playerInfo[playerid][createChannel]][i],
  471.                      0,
  472.                      MAX_MESSAGE_STRING);
  473.                    
  474.                 for(new i, gmax = GetMaxPlayers(); i < gmax; i++)
  475.                 {
  476.                     if(!IsPlayerConnected(i))
  477.                         continue;
  478.                     if(playerInfo[i][ircChannel] == playerInfo[playerid][ircChannel])
  479.                     {
  480.                         ShowPlayerDialog(playerid, IRC_CHANNEL_MSGBOX,
  481.                          DIALOG_STYLE_MSGBOX,
  482.                          "Disconnected",
  483.                          "Channel was deleted!",
  484.                          "OK",
  485.                          "Close");
  486.                            
  487.                         playerInfo[i][ircChannel] = 0;
  488.                     }
  489.                 }
  490.                
  491.                 playerInfo[playerid][createChannel] = 0;
  492.                
  493.                 SendClientMessage(playerid, COLOR_GREEN,
  494.                  "You deleted your IRC channel");
  495.                
  496.                 return 1;
  497.             }
  498.  
  499.             SendClientMessage(playerid, COLOR_RED, "Wrong password!");
  500.            
  501.             return 1;
  502.            
  503.         }
  504.        
  505.         if(dialogid == IRC_CHANNEL_JOIN)
  506.         {
  507.             if(ircChannels[(listitem + 1)][active] == false)
  508.             {
  509.                 ShowPlayerDialog(playerid, IRC_CHANNEL_MSGBOX,
  510.                  DIALOG_STYLE_MSGBOX,
  511.                  "ERROR",
  512.                  "Channel does not exist!",
  513.                  "Ok",
  514.                  "Close");
  515.  
  516.                 return 1;
  517.             }
  518.            
  519.             if(!strlen(ircChannels[(listitem + 1)][pass]))
  520.             {
  521.                 new strInfo[100];
  522.                
  523.                 playerInfo[playerid][ircChannel] = (listitem + 1);
  524.                
  525.                 format(strInfo, sizeof(strInfo), "You joined to %s channel",
  526.                  ircChannels[playerInfo[playerid][ircChannel]][names]);
  527.                    
  528.                 SendClientMessage(playerid, COLOR_GREEN, strInfo);
  529.                 format(strInfo, sizeof(strInfo), "%s joined to us",
  530.                  PlayerName(playerid));
  531.                
  532.                 SendClientMessage(playerid, COLOR_YELLOW,
  533.                  "Use /irc to open dialog window");
  534.                
  535.                 for(new i, gmax = GetMaxPlayers(); i < gmax; i++)
  536.                 {
  537.                     if(!IsPlayerConnected(i))
  538.                         continue;
  539.                     if(playerInfo[i][ircChannel] == playerInfo[playerid][ircChannel])
  540.                         SendClientMessage(i, COLOR_ORANGE, strInfo);
  541.                 }
  542.                
  543.                 return 1;
  544.                
  545.             }
  546.             if(strlen(ircChannels[(listitem + 1)][pass]))
  547.             {
  548.                 ShowPlayerDialog(playerid, IRC_CHANNEL_PASS2, DIALOG_STYLE_INPUT,
  549.                  "Password",
  550.                  "",
  551.                  "Join",
  552.                  "Cancel");
  553.                    
  554.                 playerInfo[playerid][ircJoin] = (listitem + 1);
  555.                
  556.                 return 1;
  557.             }
  558.            
  559.         }
  560.        
  561.         if(dialogid == IRC_CHANNEL_PASS2)
  562.         {
  563.             if(strcmp(ircChannels[playerInfo[playerid][ircJoin]][pass],
  564.              inputtext, false) == 0 && strlen(inputtext))
  565.             {
  566.                 playerInfo[playerid][ircChannel] = playerInfo[playerid][ircJoin];
  567.                
  568.                 new strInfo[100];
  569.  
  570.                 format(strInfo, sizeof(strInfo), "You joined to %s channel",
  571.                  ircChannels[playerInfo[playerid][ircChannel]][names]);
  572.                    
  573.                 SendClientMessage(playerid, COLOR_GREEN, strInfo);
  574.                
  575.                 format(strInfo, sizeof(strInfo), "%s joined to us",
  576.                  PlayerName(playerid));
  577.                    
  578.                 SendClientMessage(playerid, COLOR_YELLOW,
  579.                  "Use /irc to open dialog window");
  580.                    
  581.                 playerInfo[playerid][ircJoin] = 0;
  582.  
  583.                 for(new i, gmax = GetMaxPlayers(); i < gmax; i++)
  584.                 {
  585.                     if(!IsPlayerConnected(i))
  586.                         continue;
  587.                     if(playerInfo[i][ircChannel] == playerInfo[playerid][ircChannel])
  588.                         SendClientMessage(i, COLOR_ORANGE, strInfo);
  589.                 }
  590.                
  591.                 return 1;
  592.             }
  593.         }
  594.        
  595.         if(dialogid == IRC_MESSAGE)
  596.         {
  597.             ShowPlayerDialog(playerid, IRC_MESSAGE_SEND, DIALOG_STYLE_INPUT,
  598.              "Message",
  599.              "",
  600.              "Send",
  601.              "Back");
  602.  
  603.             playerInfo[playerid][windowOpen] = false;
  604.  
  605.             return 1;
  606.         }
  607.        
  608.         if(dialogid == IRC_MESSAGE_SEND)
  609.         {
  610.             if(strlen(inputtext) >= 40)
  611.             {
  612.                 ShowPlayerDialog(playerid, IRC_MESSAGE_MSGBOX,
  613.                  DIALOG_STYLE_MSGBOX,
  614.                  "Error!",
  615.                  "Message is to long!",
  616.                  "Ok",
  617.                  "Close");
  618.                
  619.                 return 1;
  620.             }
  621.            
  622.             if(ircChannels[playerInfo[playerid][ircChannel]][message] == 19)
  623.              ircChannels[playerInfo[playerid][ircChannel]][message] = 0;
  624.                
  625.             format(chatHistory[playerInfo[playerid][ircChannel]][0],
  626.              MAX_MESSAGE_STRING,
  627.              "%s: %s\n",
  628.              PlayerName(playerid), inputtext);
  629.  
  630.             for(new i = 19; i >= 1; i--)
  631.             {
  632.                 format(chatHistory[playerInfo[playerid][ircChannel]][i],
  633.                  MAX_MESSAGE_STRING,
  634.                  "%s",
  635.                  chatHistory[playerInfo[playerid][ircChannel]][i - 1]);
  636.             }
  637.  
  638.             playerInfo[playerid][windowOpen] = true;
  639.            
  640.             new strTitle[45], strChat[2500];
  641.  
  642.             for(new i = 1; i < MAX_MESSAGE; i++)
  643.             {
  644.                 if(!strlen(chatHistory[playerInfo[playerid][ircChannel]][i]))
  645.                     continue;
  646.                 strcat(strChat, chatHistory[playerInfo[playerid][ircChannel]][i],
  647.                     sizeof(strChat));
  648.             }
  649.                
  650.             format(strTitle, sizeof(strTitle), "Channel #%s",
  651.              ircChannels[playerInfo[playerid][ircChannel]][names]);
  652.  
  653.  
  654.             for(new i, gmax = GetMaxPlayers(); i < gmax; i++)
  655.             {
  656.                 if(!IsPlayerConnected(i))
  657.                     continue;
  658.                 if(playerInfo[i][ircChannel] == playerInfo[playerid][ircChannel])
  659.                 {
  660.                     if(i != playerid)
  661.                         GameTextForPlayer(i,
  662.                          "~g~New message on ~r~IRC channel",
  663.                          1000,
  664.                          5);
  665.                    
  666.                     if(playerInfo[i][windowOpen] == true)
  667.                      ShowPlayerDialog(i, IRC_MESSAGE, DIALOG_STYLE_LIST,
  668.                      strTitle,
  669.                      strChat,
  670.                      "Write",
  671.                      "Hide");
  672.                 }
  673.             }
  674.         }
  675.     }
  676.    
  677.     if(response == 0)
  678.     {
  679.    
  680.         if(dialogid == IRC_CHANNEL_NAME)
  681.         {
  682.             playerInfo[playerid][createChannel] = 0;
  683.            
  684.             return 1;
  685.         }
  686.        
  687.         if(dialogid == IRC_CHANNEL_PASS)
  688.         {
  689.             new strInfo[45];
  690.             format(strInfo, sizeof(strInfo), "Name: %s without password",
  691.              ircChannels[playerInfo[playerid][createChannel]][names],
  692.              ircChannels[playerInfo[playerid][createChannel]][pass]);
  693.                
  694.             SendClientMessage(playerid, COLOR_GREEN, strInfo);
  695.            
  696.             SendClientMessage(playerid, COLOR_YELLOW,
  697.              "Use /irc to open dialog window");
  698.            
  699.             playerInfo[playerid][ircChannel] = playerInfo[playerid][createChannel];
  700.            
  701.             return 1;
  702.         }
  703.         if(dialogid == IRC_MESSAGE_SEND)
  704.         {
  705.             new strTitle[45], strChat[2500];
  706.  
  707.             format(strTitle, sizeof(strTitle), "Channel #%s",
  708.              ircChannels[playerInfo[playerid][ircChannel]][names]);
  709.  
  710.             playerInfo[playerid][windowOpen] = true;
  711.  
  712.             for(new i = 1; i < MAX_MESSAGE; i++)
  713.             {
  714.                 if(!strlen(chatHistory[playerInfo[playerid][ircChannel]][i]))
  715.                     continue;
  716.                    
  717.                 strcat(strChat, chatHistory[playerInfo[playerid][ircChannel]][i],
  718.                  sizeof(strChat));
  719.             }
  720.            
  721.             if(!strlen(strChat))
  722.             {
  723.                 ShowPlayerDialog(playerid, IRC_CHANNEL_JOIN, DIALOG_STYLE_LIST,
  724.                  strTitle,
  725.                  "No Message",
  726.                  "Write",
  727.                  "Hide");
  728.                    
  729.                 return 1;
  730.             }
  731.            
  732.             ShowPlayerDialog(playerid, IRC_MESSAGE, DIALOG_STYLE_LIST, strTitle,
  733.              strChat,
  734.              "Wtite",
  735.              "Hide");
  736.         }
  737.         if(dialogid == IRC_MESSAGE)
  738.             playerInfo[playerid][windowOpen] = false;
  739.     }
  740.  
  741.     return 1;
  742. }
Advertisement
Add Comment
Please, Sign In to add comment