yuhsing

Untitled

Nov 18th, 2012
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.57 KB | None | 0 0
  1.  
  2.  
  3. // Last Update : 06:50AM 19/11/2012
  4. // Credits to AnnieRuru
  5.  
  6. // ==== TO-DO ====
  7. // - NPC Dialog Lists
  8. // - Add Block User Features ?
  9. // - Clean the Scripts .....
  10.  
  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 Message Colour
  30. .CHAT$ = "0xFFBBFF";
  31. .SYSTEM$ = "0x00EE55";
  32.  
  33. // IRC Commands
  34. .irc_create$ = "create";
  35. .irc_join$ = "join";
  36. .irc_leave$ = "leave";
  37. .irc_list$ = "list";
  38. .irc_kick$ = "kick";
  39. .irc_invite$ = "invite";
  40. // .irc_help$ = "help";
  41. .irc_reject$ = "reject";
  42.  
  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 if( getstrlen(@whispervar1$) < 4 || getstrlen(@whispervar1$) > 24 ){
  64. dispbottom "Usage : create#irc_name#irc_password ( if any password )";
  65. dispbottom "irc_name must be between 4 ~ 24";
  66. }else if( getstrlen( @whispervar2$ ) && getstrlen( @whispervar2$ ) < 4 ){
  67. dispbottom "If you gonna add Password for IRC Room, the Password must not less than 4 characters.";
  68. }else{
  69. @IRC = IRC_Create( @whispervar1$,@whispervar2$ );
  70. if( @IRC ){
  71. dispbottom "Successfully create a Room.";
  72. IRC_Add( ( @IRC - 1 ),strcharinfo(0) );
  73.  
  74. // Clear variable ...
  75. @whispervar1$ = "";
  76. @whispervar2$ = "";
  77. }else{
  78. dispbottom "Failed to create a Room.";
  79. }
  80. }
  81.  
  82. }else if( @whispervar0$ == .irc_join$ ){
  83. if( getarraysize( .IRC_Room$ ) <= 0 ){
  84. dispbottom "Didnt have any available IRC Room.";
  85. }else if( @IRC ){
  86. dispbottom "Please leave your current IRC Room";
  87. }else{
  88. @IRC = IRC_Join();
  89. IRC_Add( ( @IRC - 1 ),strcharinfo(0) );
  90. }
  91.  
  92. }else if( @whispervar0$ == .irc_leave$ ){
  93. if( !@IRC ){
  94. dispbottom "You didnt join any IRC Room.";
  95. }else{
  96. IRC_Remove( ( @IRC - 1 ),strcharinfo(0) );
  97. @IRC = 0;
  98. dispbottom "You have left the IRC Channel";
  99. }
  100.  
  101. }else if( @whispervar0$ == .irc_list$ ){
  102. if( !@IRC ){
  103. dispbottom "You didnt join any IRC Room.";
  104. }else{
  105. IRC_List( ( @IRC - 1 ) );
  106. }
  107.  
  108. }else if( @whispervar0$ == .irc_kick$ ){
  109. if( getd( ".IRC_Room_"+( @IRC - 1 )+"$[0]" ) != strcharinfo(0) ){
  110. dispbottom "Only a MOD of a channel can use this to kick player in this Channel.";
  111. }else{
  112. .@OriUser$ = strcharinfo(0);
  113. .@ExpelName$ = @whispervar1$;
  114. if( attachrid( getcharid(3,.@ExpelName$) ) ){
  115. IRC_Remove( ( @IRC - 1 ),.@ExpelName$ );
  116. dispbottom "You have been kicked out from the IRC by MOD";
  117. @IRC = 0;
  118. }
  119. attachrid( getcharid( 3,.@OriUser$ ) );
  120. }
  121.  
  122. }else if( @whispervar0$ == .irc_reject$ ){
  123. @AutoReject = !@AutoReject;
  124. dispbottom ( ( @AutoReject )?"Auto Reject":"Enable" )+" Invitation from other IRC Channel";
  125.  
  126. }else if( @whispervar0$ == .irc_invite$ ){
  127. if( getd( ".IRC_Room_"+( @IRC - 1 )+"$[0]" ) != strcharinfo(0) ){
  128. dispbottom "Only a MOD of a channel can invite another player into this Channel.";
  129. }else{
  130. .@OriUser$ = strcharinfo(0);
  131. .@Channel = @IRC;
  132. .@Name$ = @whispervar1$;
  133. if( attachrid( getcharid(3,.@Name$) ) ){
  134. if( @AutoReject || @IRC ){
  135. .@i = 0;
  136. if( @AutoReject )
  137. dispbottom "Rejected IRC Invitation from "+.@OriUser$+".";
  138. }else{
  139. .@i = IRC_Add( ( .@Channel - 1 ),.@Name$ );
  140. if( .@i == 1 ) @IRC = .@Channel;
  141. }
  142. }
  143. attachrid( getcharid( 3,.@OriUser$ ) );
  144. if( .@i == 0 ) dispbottom "Failed to add this Player into this Channel.";
  145. }
  146.  
  147. }else if( @IRC <= 0 ){
  148. dispbottom "You didnt join any IRC Room.";
  149. dispbottom "To Create a Channel : type 'create#irc_name#irc_password' ( if any )";
  150. dispbottom "To Join a Channel : type 'join'";
  151.  
  152. }else{
  153. set .@MSG$, strcharinfo(0) +" : "+ @whispervar0$;
  154. IRC_Broadcast( ( @IRC - 1 ),.@MSG$,.CHAT$ );
  155. }
  156. close;
  157.  
  158. OnPCLogoutEvent:
  159. if( @IRC )
  160. IRC_Remove( ( @IRC - 1 ),strcharinfo(0) );
  161. end;
  162.  
  163. // getarg(0) = Room
  164. // getarg(1) = Player Name
  165. function IRC_Add {
  166. .@size = getarraysize( getd( ".IRC_Room_"+getarg(0)+"$" ) );
  167. for( .@i = 0; .@i < .@size; .@i++ )
  168. if( getd( ".IRC_Room_"+getarg(0)+"$["+.@i+"]" ) == getarg(1) )
  169. return 0;
  170. setd( ".IRC_Room_"+getarg(0)+"$["+.@size+"]" ),getarg(1);
  171. IRC_Broadcast( getarg(0),"( IRC ) : '"+getarg(1)+"' joined this room",.SYSTEM$ );
  172. return attachrid( getcharid(3,getarg(1) ) );
  173. }
  174.  
  175. // getarg(0) = Room
  176. // getarg(1) = Player Name
  177. function IRC_Remove {
  178. .@size = getarraysize( getd( ".IRC_Room_"+getarg(0)+"$" ) );
  179. // Check and Remove Users
  180. for( .@i = 0; .@i < .@size; .@i++ )
  181. if( getd( ".IRC_Room_"+getarg(0)+"$["+.@i+"]" ) == getarg(1) ){
  182. IRC_Broadcast( getarg(0),"( IRC ) : '"+getarg(1)+"' left this room",.SYSTEM$ );
  183. deletearray getd( ".IRC_Room_"+getarg(0)+"$["+.@i+"]" ),1;
  184. }
  185.  
  186. // Delete Room & Password from Room Lists if empty users
  187. if( getarraysize( getd( ".IRC_Room_"+getarg(0)+"$" ) ) <= 0 ){
  188. .IRC_Room$[ getarg(0) ] = "";
  189. .IRC_Pass$[ getarg(0) ] = "";
  190. }
  191.  
  192. return attachrid( getcharid(3,getarg(1) ) );
  193. }
  194.  
  195. // getarg(0) = Room
  196. function IRC_List {
  197. dispbottom "========= IRC INFORMATION ==========";
  198. dispbottom "IRC Name : "+.IRC_Room$[ getarg(0) ];
  199. dispbottom "IRC Type : "+( ( getstrlen( .IRC_Pass$[ getarg(0) ] ) )?"Secured ( '"+.IRC_Pass$[ getarg(0) ]+"' )":"Public" );
  200. dispbottom "========= IRC USER LIST ===========";
  201. .@size = getarraysize( getd( ".IRC_Room_"+getarg(0)+"$" ) );
  202. for( .@i = 0; .@i < .@size; .@i++ )
  203. dispbottom " -> "+getd( ".IRC_Room_"+getarg(0)+"$["+.@i+"]" ) + ( ( .@i == 0 )?" [ MOD ]":"" );
  204. dispbottom "========= IRC USER LIST ===========";
  205. dispbottom "Total User : "+.@size;
  206. return;
  207. }
  208.  
  209. // getarg(0) = Room
  210. // getarg(1) = Message
  211. // getarg(2) = Color
  212. function IRC_Broadcast {
  213. freeloop(1);
  214. for( .@i = 0; .@i < getarraysize( getd( ".IRC_Room_"+getarg(0)+"$" ) ); .@i++ )
  215. if( attachrid( getcharid( 3,getd( ".IRC_Room_"+getarg(0)+"$["+.@i+"]" ) ) ) ){
  216. announce ( ( .DisplayTime )?"[ "+gettimestr("%H:%M",7)+" ] ":"" ) + getarg(1),bc_self,getarg(2);
  217. }
  218. freeloop(0);
  219. return;
  220. }
  221.  
  222. // getarg(0) = Room Title
  223. // getarg(1) = Room Password if any
  224. function IRC_Create {
  225. for( .@i = 0; .@i < .MaxRoom; .@i++ )
  226. if( .IRC_Room$[.@i] == "" ){
  227. .IRC_Room$[.@i] = getarg(0);
  228. .IRC_Pass$[.@i] = getarg(1);
  229. return ( .@i + 1 );
  230. }
  231. return 0;
  232. }
  233.  
  234. // List Channel and Select
  235. function IRC_Join {
  236. for( .@i = 0; .@i < getarraysize( .IRC_Room$ ); .@i++ )
  237. set .@Menu$,.@Menu$ + ( ( .IRC_Room$[.@i] == "" )?"":"^FF0000[ "+( ( getstrlen( .IRC_Pass$[.@i] ) >= 4 )?"S":"P" )+" ] ^0055FF"+.IRC_Room$[.@i]+" ^FF0000( "+getarraysize( getd( ".IRC_Room_"+.@i+"$") )+" / "+.MaxUser+" Users )^000000" ) +":";
  238. do{
  239. mes "^0055FF[ S ]^000000 = ^777777Secured Room^000000";
  240. mes "^0055FF[ P ]^000000 = ^777777Public Room^000000";
  241. .@Room = select( .@Menu$ );
  242. if( getstrlen( .IRC_Pass$[(.@Room - 1)] ) >= 4 ){
  243. mes "Please enter the IRC Password.";
  244. input .@Pass$;
  245. if( .@Pass$ != .IRC_Pass$[(.@Room - 1)] ){
  246. mes "^FF0000Invalid Password^000000";
  247. next;
  248. }
  249. }
  250. }while( getstrlen( .IRC_Pass$[(.@Room - 1)] ) >= 4 && .@Pass$ != .IRC_Pass$[(.@Room - 1)] );
  251. return .@Room;
  252. }
  253.  
  254. }
Advertisement
Add Comment
Please, Sign In to add comment