yuhsing

Untitled

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