yuhsing

Untitled

Nov 18th, 2012
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.85 KB | None | 0 0
  1.  
  2.  
  3.  
  4. // Last Update : 8:50PM 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. // - Clean the Scripts .....
  14.  
  15.  
  16. - script IRC -1,{
  17. function IRC_Create;
  18. function IRC_Join;
  19. function IRC_Broadcast;
  20. function IRC_Add;
  21. function IRC_Remove;
  22. function IRC_List;
  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. dispbottom "You have left the IRC Channel";
  90. }
  91.  
  92. }else if( @whispervar0$ == .irc_list$ ){
  93. if( !@IRC ){
  94. dispbottom "You didnt join any IRC Room.";
  95. }else{
  96. IRC_List( ( @IRC - 1 ) );
  97. }
  98.  
  99. }else if( @whispervar0$ == .irc_kick$ ){
  100. if( getd( ".IRC_Room_"+( @IRC - 1 )+"$[0]" ) != strcharinfo(0) ){
  101. dispbottom "Only a MOD of a channel can use this to kick player in this Channel.";
  102. }else{
  103. .@OriAID = getcharid(3);
  104. .@ExpelName$ = @whispervar1$;
  105. if( attachrid( getcharid(3,.@ExpelName$) ) ){
  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. OnPCLogoutEvent:
  141. if( @IRC )
  142. IRC_Remove( ( @IRC - 1 ),strcharinfo(0) );
  143. end;
  144.  
  145. // getarg(0) = Room
  146. // getarg(1) = Player Name
  147. function IRC_Add {
  148. .@size = getarraysize( getd( ".IRC_Room_"+getarg(0)+"$" ) );
  149. for( .@i = 0; .@i < .@size; .@i++ )
  150. if( getd( ".IRC_Room_"+getarg(0)+"$["+.@i+"]" ) == getarg(1) )
  151. return 0;
  152. setd( ".IRC_Room_"+getarg(0)+"$["+.@size+"]" ),getarg(1);
  153. IRC_Broadcast( getarg(0),"( IRC ) : '"+getarg(1)+"' joined this room",.SYSTEM$ );
  154. return attachrid( getcharid(3,getarg(1) ) );
  155. }
  156.  
  157. // getarg(0) = Room
  158. // getarg(1) = Player Name
  159. function IRC_Remove {
  160. .@size = getarraysize( getd( ".IRC_Room_"+getarg(0)+"$" ) );
  161. // Check and Remove Users
  162. for( .@i = 0; .@i < .@size; .@i++ )
  163. if( getd( ".IRC_Room_"+getarg(0)+"$["+.@i+"]" ) == getarg(1) ){
  164. IRC_Broadcast( getarg(0),"( IRC ) : '"+getarg(1)+"' left this room",.SYSTEM$ );
  165. deletearray getd( ".IRC_Room_"+getarg(0)+"$["+.@i+"]" ),1;
  166. }
  167.  
  168. // Delete Room from Room Lists if empty users
  169. if( getarraysize( getd( ".IRC_Room_"+getarg(0)+"$" ) ) <= 0 )
  170. .IRC_Room$[ getarg(0) ] = "";
  171.  
  172. return attachrid( getcharid(3,getarg(1) ) );
  173. }
  174.  
  175. // getarg(0) = Room
  176. function IRC_List {
  177. dispbottom "==== USER LIST ( IRC : "+.IRC_Room$[ getarg(0) ]+" ) ====";
  178. .@size = getarraysize( getd( ".IRC_Room_"+getarg(0)+"$" ) );
  179. for( .@i = 0; .@i < .@size; .@i++ )
  180. dispbottom " -> "+getd( ".IRC_Room_"+getarg(0)+"$["+.@i+"]" ) + ( ( .@i == 0 )?" [ MOD ]":"" );
  181. dispbottom "==== USER LIST ( Total : "+.@size+" Users ) ====";
  182. return;
  183. }
  184.  
  185. // getarg(0) = Room
  186. // getarg(1) = Message
  187. // getarg(2) = Color
  188. function IRC_Broadcast {
  189. freeloop(1);
  190. for( .@i = 0; .@i < getarraysize( getd( ".IRC_Room_"+getarg(0)+"$" ) ); .@i++ )
  191. if( attachrid( getcharid( 3,getd( ".IRC_Room_"+getarg(0)+"$["+.@i+"]" ) ) ) ){
  192. announce ( ( .DisplayTime )?"[ "+gettime(3)+":"+gettime(2)+" ] ":"" ) + getarg(1),bc_self,getarg(2);
  193. }
  194. freeloop(0);
  195. return;
  196. }
  197.  
  198. // Input a Name during creating Channel
  199. function IRC_Create {
  200. mes "Please enter a Name for this IRC Channel";
  201. do{
  202. input .@IRC_Name$;
  203. mes "IRC Name : ^0055FF"+.@IRC_Name$+"^000000";
  204. next;
  205. }while( select("Confirm:Change") == 2 );
  206. close2;
  207. return .@IRC_Name$;
  208. end;
  209. }
  210.  
  211. // List Channel and Select
  212. function IRC_Join {
  213. for( .@i = 0; .@i < getarraysize( .IRC_Room$ ); .@i++ )
  214. set .@Menu$,.@Menu$ + ( ( .IRC_Room$[.@i] == "" )?"":"^0055FF"+.IRC_Room$[.@i]+" ^FF0000( "+getarraysize( getd( ".IRC_Room_"+.@i+"$") )+" / "+.MaxUser+" Users )^000000" ) +":";
  215. return select( .@Menu$ );
  216. }
  217.  
  218. }
Advertisement
Add Comment
Please, Sign In to add comment