yuhsing

Untitled

Nov 17th, 2012
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.71 KB | None | 0 0
  1. // Last Update : 12:00PM 18/11/2012
  2.  
  3. // Credits to AnnieRuru
  4.  
  5. // ==== TO-DO ====
  6. // - Fix Kick / Remove Users
  7. // - Add Block Users
  8. // - NPC Dialog Lists
  9. // - Add Password Features ?
  10. // - Reject Invitation ?
  11.  
  12. - script IRC -1,{
  13. function IRC_Create;
  14. function IRC_Join;
  15. function IRC_Broadcast;
  16. function IRC_Add;
  17. function IRC_Remove;
  18. function IRC_List;
  19.  
  20.  
  21. OnInit:
  22. // Max IRC Room
  23. .MaxRoom = 10;
  24. // Max Users in IRC
  25. .MaxUser = 100;
  26. // Display Time
  27. .DisplayTime = 1;
  28.  
  29. // IRC Chat Colour
  30. .WARNING$ = "0xFF0000";
  31. .CHAT$ = "0xFFBBFF";
  32. .SYSTEM$ = "0x00EE55";
  33.  
  34. // IRC Commands
  35. .irc_create$ = "create";
  36. .irc_join$ = "join";
  37. .irc_leave$ = "leave";
  38. .irc_list$ = "list";
  39. .irc_kick$ = "kick";
  40. .irc_invite$ = "invite";
  41.  
  42. // IRC Messages ( will add on future )
  43. // .message$[0] = "IRC Room reach limit.";
  44. // .message$[1] = "Please leave your current IRC Room.";
  45. // .message$[2] = "Didnt have any available IRC Room.";
  46. // .message$[3] = "You didnt join any IRC Room";
  47.  
  48. // Delete Data during Test Mode
  49. for ( .@i = 2000000; .@i < 2000003; .@i++ )
  50. if ( attachrid(.@i) )
  51. set @IRC, 0;
  52. end;
  53.  
  54.  
  55. OnWhisperGlobal:
  56. if( @whispervar0$ == .irc_create$ ){
  57. if( getarraysize( .IRC_Room$ ) >= .MaxRoom ){
  58. dispbottom "Max IRC Room Reach.";
  59. }else if( @IRC ){
  60. dispbottom "Please leave your current IRC Room";
  61. }else{
  62. for( .@i = 0; .@i < .MaxRoom; .@i++ )
  63. if( .IRC_Room$[.@i] == "" ){
  64. .IRC_Room$[.@i] = IRC_Create();
  65. @IRC = ( .@i + 1 );
  66. IRC_Add( ( @IRC - 1 ),strcharinfo(0) );
  67. end;
  68. }
  69. }
  70.  
  71. }else if( @whispervar0$ == .irc_join$ ){
  72. if( getarraysize( .IRC_Room$ ) <= 0 ){
  73. dispbottom "Didnt have any available IRC Room.";
  74. }else if( @IRC ){
  75. dispbottom "Please leave your current IRC Room";
  76. }else{
  77. @IRC = IRC_Join();
  78. IRC_Add( ( @IRC - 1 ),strcharinfo(0) );
  79. }
  80.  
  81. }else if( @whispervar0$ == .irc_leave$ ){
  82. if( !@IRC ){
  83. dispbottom "You didnt join any IRC Room.";
  84. }else{
  85. IRC_Remove( ( @IRC - 1 ),strcharinfo(0) );
  86. @IRC = 0;
  87. }
  88.  
  89. }else if( @whispervar0$ == .irc_list$ ){
  90. if( !@IRC ){
  91. dispbottom "You didnt join any IRC Room.";
  92. }else{
  93. IRC_List( ( @IRC - 1 ) );
  94. }
  95.  
  96. }else if( @whispervar0$ == .irc_kick$ ){
  97. if( getd( ".IRC_Room_"+( @IRC - 1 )+"$[0]" ) != strcharinfo(0) ){
  98. dispbottom "Only a MOD of a channel can use this to kick player in this Channel.";
  99. }else{
  100. .@OriAID = getcharid(3);
  101. .@ExpelName$ = @whispervar1$;
  102. if( attachrid( getcharid(3,.@ExpelName$) ) ){
  103. dispbottom "Your @IRC = "+@IRC;
  104. IRC_Remove( ( @IRC - 1 ),.@ExpelName$ );
  105. @IRC = 0;
  106. }
  107. attachrid( .@OriAID );
  108. }
  109.  
  110. }else if( @whispervar0$ == .irc_invite$ ){
  111. if( getd( ".IRC_Room_"+( @IRC - 1 )+"$[0]" ) != strcharinfo(0) ){
  112. dispbottom "Only a MOD of a channel can invite another player into this Channel.";
  113. }else{
  114. .@OriAID = getcharid(3);
  115. .@Channel = @IRC;
  116. .@Name$ = @whispervar1$;
  117. if( attachrid( getcharid(3,.@Name$) ) ){
  118. .@i = IRC_Add( ( .@Channel - 1 ),.@Name$ );
  119. if( .@i == 1 ) @IRC = .@Channel;
  120. }
  121. attachrid( .@OriAID );
  122. if( .@i == 0 ) dispbottom "Failed to add this Player into this Channel.";
  123. }
  124.  
  125. }else if( @IRC <= 0 ){
  126. dispbottom "You didnt join any IRC Room.";
  127.  
  128. }else{
  129. set .@MSG$, strcharinfo(0) +" : "+ @whispervar0$;
  130. IRC_Broadcast( ( @IRC - 1 ),.@MSG$,.CHAT$ );
  131. }
  132. close;
  133.  
  134. // getarg(0) = Room
  135. // getarg(1) = Player Name
  136. function IRC_Add {
  137. .@size = getarraysize( getd( ".IRC_Room_"+getarg(0)+"$" ) );
  138. for( .@i = 0; .@i < .@size; .@i++ )
  139. if( getd( ".IRC_Room_"+getarg(0)+"$["+.@i+"]" ) == getarg(1) )
  140. return 0;
  141. setd( ".IRC_Room_"+getarg(0)+"$["+.@size+"]" ),getarg(1);
  142. IRC_Broadcast( getarg(0),"( IRC ) : '"+getarg(1)+"' joined this room",.SYSTEM$ );
  143. return 1;
  144. }
  145.  
  146. // getarg(0) = Room
  147. // getarg(1) = Player Name
  148. function IRC_Remove {
  149. IRC_Broadcast( getarg(0),"( IRC ) : '"+getarg(1)+"' left this room",.SYSTEM$ );
  150. .@size = getarraysize( getd( ".IRC_Room_"+getarg(0)+"$" ) );
  151.  
  152. // Doesnt work well yet....
  153. for( .@i = 0; .@i < .@size; .@i++ ){
  154. // dispbottom " ===> [ "+.@i+" ] "+getd( ".IRC_Room_"+getarg(0)+"$["+.@i+"]" );
  155. if( getd( ".IRC_Room_"+getarg(0)+"$["+.@i+"]" ) == getarg(1) )
  156. deletearray getd( ".IRC_Room_"+getarg(0)+"$["+.@i+"]" ),1;
  157. }
  158.  
  159. // Delete Room from Room Lists if empty users
  160. if( getarraysize( getd( ".IRC_Room_"+getarg(0)+"$" ) ) <= 0 )
  161. .IRC_Room$[ getarg(0) ] = "";
  162. return;
  163. }
  164.  
  165. // getarg(0) = Room
  166. function IRC_List {
  167. dispbottom "==== USER LIST ( IRC : "+.IRC_Room$[ getarg(0) ]+" ) ====";
  168. .@size = getarraysize( getd( ".IRC_Room_"+getarg(0)+"$" ) );
  169. for( .@i = 0; .@i < .@size; .@i++ )
  170. dispbottom " -> "+getd( ".IRC_Room_"+getarg(0)+"$["+.@i+"]" ) + ( ( .@i == 0 )?" [ MOD ]":"" );
  171. dispbottom "==== USER LIST ( Total : "+.@size+" Users ) ====";
  172. return;
  173. }
  174.  
  175. // getarg(0) = Room
  176. // getarg(1) = Message
  177. // getarg(2) = Color
  178. function IRC_Broadcast {
  179. freeloop(1);
  180. for( .@i = 0; .@i < getarraysize( getd( ".IRC_Room_"+getarg(0)+"$" ) ); .@i++ )
  181. if( attachrid( getcharid( 3,getd( ".IRC_Room_"+getarg(0)+"$["+.@i+"]" ) ) ) ){
  182. announce ( ( .DisplayTime )?"[ "+gettime(3)+":"+gettime(2)+" ] ":"" ) + getarg(1),bc_self,getarg(2);
  183. }
  184. freeloop(0);
  185. return;
  186. }
  187.  
  188. // Input a Name during creating Channel
  189. function IRC_Create {
  190. mes "Please enter a Name for this IRC Channel";
  191. do{
  192. input .@IRC_Name$;
  193. mes "IRC Name : ^0055FF"+.@IRC_Name$+"^000000";
  194. next;
  195. }while( select("Confirm:Change") == 2 );
  196. close2;
  197. return .@IRC_Name$;
  198. end;
  199. }
  200.  
  201. // List Channel and Select
  202. function IRC_Join {
  203. for( .@i = 0; .@i < getarraysize( .IRC_Room$ ); .@i++ )
  204. set .@Menu$,.@Menu$ + ( ( .IRC_Room$[.@i] == "" )?"":"^0055FF"+.IRC_Room$[.@i]+" ^FF0000( "+getarraysize( getd( ".IRC_Room_"+.@i+"$") )+" / "+.MaxUser+" Users )^000000" ) +":";
  205. return select( .@Menu$ );
  206. }
  207.  
  208. }
Advertisement
Add Comment
Please, Sign In to add comment