Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Last Update : 06:50AM 19/11/2012
- // Credits to AnnieRuru
- // ==== TO-DO ====
- // - NPC Dialog Lists
- // - Add Block User Features ?
- // - Clean the Scripts .....
- - script IRC -1,{
- function IRC_Create;
- function IRC_Join;
- function IRC_Broadcast;
- function IRC_Add;
- function IRC_Remove;
- function IRC_List;
- OnInit:
- // Max IRC Room
- .MaxRoom = 10;
- // Max Users in IRC
- .MaxUser = 100;
- // Display Time
- .DisplayTime = 1;
- // IRC Message Colour
- .CHAT$ = "0xFFBBFF";
- .SYSTEM$ = "0x00EE55";
- // IRC Commands
- .irc_create$ = "create";
- .irc_join$ = "join";
- .irc_leave$ = "leave";
- .irc_list$ = "list";
- .irc_kick$ = "kick";
- .irc_invite$ = "invite";
- // .irc_help$ = "help";
- .irc_reject$ = "reject";
- // IRC Messages ( will add on future )
- // .message$[0] = "IRC Room reach limit.";
- // .message$[1] = "Please leave your current IRC Room.";
- // .message$[2] = "Didnt have any available IRC Room.";
- // .message$[3] = "You didnt join any IRC Room";
- // Delete Data during Test Mode
- for ( .@i = 2000000; .@i < 2000003; .@i++ )
- if ( attachrid(.@i) )
- set @IRC, 0;
- end;
- OnWhisperGlobal:
- if( @whispervar0$ == .irc_create$ ){
- if( getarraysize( .IRC_Room$ ) >= .MaxRoom ){
- dispbottom "Max IRC Room Reach.";
- }else if( @IRC ){
- dispbottom "Please leave your current IRC Room";
- }else if( getstrlen(@whispervar1$) < 4 || getstrlen(@whispervar1$) > 24 ){
- dispbottom "Usage : create#irc_name#irc_password ( if any password )";
- dispbottom "irc_name must be between 4 ~ 24";
- }else if( getstrlen( @whispervar2$ ) && getstrlen( @whispervar2$ ) < 4 ){
- dispbottom "If you gonna add Password for IRC Room, the Password must not less than 4 characters.";
- }else{
- @IRC = IRC_Create( @whispervar1$,@whispervar2$ );
- if( @IRC ){
- dispbottom "Successfully create a Room.";
- IRC_Add( ( @IRC - 1 ),strcharinfo(0) );
- // Clear variable ...
- @whispervar1$ = "";
- @whispervar2$ = "";
- }else{
- dispbottom "Failed to create a Room.";
- }
- }
- }else if( @whispervar0$ == .irc_join$ ){
- if( getarraysize( .IRC_Room$ ) <= 0 ){
- dispbottom "Didnt have any available IRC Room.";
- }else if( @IRC ){
- dispbottom "Please leave your current IRC Room";
- }else{
- @IRC = IRC_Join();
- IRC_Add( ( @IRC - 1 ),strcharinfo(0) );
- }
- }else if( @whispervar0$ == .irc_leave$ ){
- if( !@IRC ){
- dispbottom "You didnt join any IRC Room.";
- }else{
- IRC_Remove( ( @IRC - 1 ),strcharinfo(0) );
- @IRC = 0;
- dispbottom "You have left the IRC Channel";
- }
- }else if( @whispervar0$ == .irc_list$ ){
- if( !@IRC ){
- dispbottom "You didnt join any IRC Room.";
- }else{
- IRC_List( ( @IRC - 1 ) );
- }
- }else if( @whispervar0$ == .irc_kick$ ){
- if( getd( ".IRC_Room_"+( @IRC - 1 )+"$[0]" ) != strcharinfo(0) ){
- dispbottom "Only a MOD of a channel can use this to kick player in this Channel.";
- }else{
- .@OriUser$ = strcharinfo(0);
- .@ExpelName$ = @whispervar1$;
- if( attachrid( getcharid(3,.@ExpelName$) ) ){
- IRC_Remove( ( @IRC - 1 ),.@ExpelName$ );
- dispbottom "You have been kicked out from the IRC by MOD";
- @IRC = 0;
- }
- attachrid( getcharid( 3,.@OriUser$ ) );
- }
- }else if( @whispervar0$ == .irc_reject$ ){
- @AutoReject = !@AutoReject;
- dispbottom ( ( @AutoReject )?"Auto Reject":"Enable" )+" Invitation from other IRC Channel";
- }else if( @whispervar0$ == .irc_invite$ ){
- if( getd( ".IRC_Room_"+( @IRC - 1 )+"$[0]" ) != strcharinfo(0) ){
- dispbottom "Only a MOD of a channel can invite another player into this Channel.";
- }else{
- .@OriUser$ = strcharinfo(0);
- .@Channel = @IRC;
- .@Name$ = @whispervar1$;
- if( attachrid( getcharid(3,.@Name$) ) ){
- if( @AutoReject || @IRC ){
- .@i = 0;
- if( @AutoReject )
- dispbottom "Rejected IRC Invitation from "+.@OriUser$+".";
- }else{
- .@i = IRC_Add( ( .@Channel - 1 ),.@Name$ );
- if( .@i == 1 ) @IRC = .@Channel;
- }
- }
- attachrid( getcharid( 3,.@OriUser$ ) );
- if( .@i == 0 ) dispbottom "Failed to add this Player into this Channel.";
- }
- }else if( @IRC <= 0 ){
- dispbottom "You didnt join any IRC Room.";
- dispbottom "To Create a Channel : type 'create#irc_name#irc_password' ( if any )";
- dispbottom "To Join a Channel : type 'join'";
- }else{
- set .@MSG$, strcharinfo(0) +" : "+ @whispervar0$;
- IRC_Broadcast( ( @IRC - 1 ),.@MSG$,.CHAT$ );
- }
- close;
- OnPCLogoutEvent:
- if( @IRC )
- IRC_Remove( ( @IRC - 1 ),strcharinfo(0) );
- end;
- // getarg(0) = Room
- // getarg(1) = Player Name
- function IRC_Add {
- .@size = getarraysize( getd( ".IRC_Room_"+getarg(0)+"$" ) );
- for( .@i = 0; .@i < .@size; .@i++ )
- if( getd( ".IRC_Room_"+getarg(0)+"$["+.@i+"]" ) == getarg(1) )
- return 0;
- setd( ".IRC_Room_"+getarg(0)+"$["+.@size+"]" ),getarg(1);
- IRC_Broadcast( getarg(0),"( IRC ) : '"+getarg(1)+"' joined this room",.SYSTEM$ );
- return attachrid( getcharid(3,getarg(1) ) );
- }
- // getarg(0) = Room
- // getarg(1) = Player Name
- function IRC_Remove {
- .@size = getarraysize( getd( ".IRC_Room_"+getarg(0)+"$" ) );
- // Check and Remove Users
- for( .@i = 0; .@i < .@size; .@i++ )
- if( getd( ".IRC_Room_"+getarg(0)+"$["+.@i+"]" ) == getarg(1) ){
- IRC_Broadcast( getarg(0),"( IRC ) : '"+getarg(1)+"' left this room",.SYSTEM$ );
- deletearray getd( ".IRC_Room_"+getarg(0)+"$["+.@i+"]" ),1;
- }
- // Delete Room & Password from Room Lists if empty users
- if( getarraysize( getd( ".IRC_Room_"+getarg(0)+"$" ) ) <= 0 ){
- .IRC_Room$[ getarg(0) ] = "";
- .IRC_Pass$[ getarg(0) ] = "";
- }
- return attachrid( getcharid(3,getarg(1) ) );
- }
- // getarg(0) = Room
- function IRC_List {
- dispbottom "========= IRC INFORMATION ==========";
- dispbottom "IRC Name : "+.IRC_Room$[ getarg(0) ];
- dispbottom "IRC Type : "+( ( getstrlen( .IRC_Pass$[ getarg(0) ] ) )?"Secured ( '"+.IRC_Pass$[ getarg(0) ]+"' )":"Public" );
- dispbottom "========= IRC USER LIST ===========";
- .@size = getarraysize( getd( ".IRC_Room_"+getarg(0)+"$" ) );
- for( .@i = 0; .@i < .@size; .@i++ )
- dispbottom " -> "+getd( ".IRC_Room_"+getarg(0)+"$["+.@i+"]" ) + ( ( .@i == 0 )?" [ MOD ]":"" );
- dispbottom "========= IRC USER LIST ===========";
- dispbottom "Total User : "+.@size;
- return;
- }
- // getarg(0) = Room
- // getarg(1) = Message
- // getarg(2) = Color
- function IRC_Broadcast {
- freeloop(1);
- for( .@i = 0; .@i < getarraysize( getd( ".IRC_Room_"+getarg(0)+"$" ) ); .@i++ )
- if( attachrid( getcharid( 3,getd( ".IRC_Room_"+getarg(0)+"$["+.@i+"]" ) ) ) ){
- announce ( ( .DisplayTime )?"[ "+gettimestr("%H:%M",7)+" ] ":"" ) + getarg(1),bc_self,getarg(2);
- }
- freeloop(0);
- return;
- }
- // getarg(0) = Room Title
- // getarg(1) = Room Password if any
- function IRC_Create {
- for( .@i = 0; .@i < .MaxRoom; .@i++ )
- if( .IRC_Room$[.@i] == "" ){
- .IRC_Room$[.@i] = getarg(0);
- .IRC_Pass$[.@i] = getarg(1);
- return ( .@i + 1 );
- }
- return 0;
- }
- // List Channel and Select
- function IRC_Join {
- for( .@i = 0; .@i < getarraysize( .IRC_Room$ ); .@i++ )
- 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" ) +":";
- do{
- mes "^0055FF[ S ]^000000 = ^777777Secured Room^000000";
- mes "^0055FF[ P ]^000000 = ^777777Public Room^000000";
- .@Room = select( .@Menu$ );
- if( getstrlen( .IRC_Pass$[(.@Room - 1)] ) >= 4 ){
- mes "Please enter the IRC Password.";
- input .@Pass$;
- if( .@Pass$ != .IRC_Pass$[(.@Room - 1)] ){
- mes "^FF0000Invalid Password^000000";
- next;
- }
- }
- }while( getstrlen( .IRC_Pass$[(.@Room - 1)] ) >= 4 && .@Pass$ != .IRC_Pass$[(.@Room - 1)] );
- return .@Room;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment