# Teamchat V1.00 28-08-15 Initial release # ################################################################################################################################# CatchEvent OnLapperStart() OnLapperStart_Teamchat(); EndCatchEvent CatchEvent OnConnect( $userName ) # Player event OnConnect_Teamchat(); EndCatchEvent CatchEvent OnMSO( $userName, $text ) # Player event $idxOfFirtsSpace = indexOf( $text, " "); IF( $idxOfFirtsSpace == -1 ) THEN $command = $text; $argv = ""; ELSE $command = subStr( $text,0,$idxOfFirtsSpace ); $argv = trim( subStr( $text,$idxOfFirtsSpace ) ); ENDIF /* SWITCH( $command ) CASE "!privatmsg": Private_message ( 0,0 ); BREAK; ENDSWITCH */ EndCatchEvent Sub OnLapperStart_Teamchat() ### Set GlobalVar's to be used for the message array ### GlobalVar $message_array; GlobalVar $count_message_array; EndSub Sub OnConnect_Teamchat() # Player event ### Load usernames from file tofus.txt ### UserGroupFromFile( "tofus", "./../AB-configs/tofus.txt" ); ### Check if username is found in group tofus ### IF ( UserInGroup( "tofus",GetCurrentPlayerVar( "UserName" ) ) == 1 ) THEN openPrivTextButton( "sendmessage",1,148,8,4,3,0,"Team Chat","^7Team%nl%^7Chat",120,teammessage ); openPrivButton( "open_chat_panel",1,158,8,4,3,-1,ISB_NONE,"^7Team%nl%^7Chat%nl%^7history",open_chat_panel ); ENDIF EndSub Sub teammessage ( $userName,$teammsg ) ### Count the number of messages in the message array ### $count_message_array = arrayCount( $message_array ); ### If message array is empty, set value to 1, so message is stored in the first field of the array ### ### If message array isn't empty, raise value by 1, so message is stored in the next empty field of the array ### IF ($count_message_array == 0) THEN $count_message_array=1; $message_array[1,$count_message_array] = "^7" . $teammsg; ELSE $count_message_array=$count_message_array+1; $message_array[1,$count_message_array] = "^7" . $teammsg; ENDIF EndSub Sub open_chat_panel ( $KeyFlags, $id ) closePrivButton ("open_chat_panel"); IF ( UserInGroup( "tofus",GetCurrentPlayerVar( "UserName" ) ) == 1 ) THEN $count_message_array = arrayCount( $message_array ); ### Set initial values for top/bottom coordinates , Set $counter to 1 ### $top_bottom_messages = 68; $counter=1; ### End ### ### Start displaying the latest 10 messages found in the message array ### FOR ($i=$count_message_array;$i>=1;$i=$i-1) IF ($counter <= 10) THEN openPrivButton( "chat_history_".$i,50,$top_bottom_messages,90,8,8,-1,ISB_DARK+64,"^3".$i."-".$message_array[1,$i],"" ); $top_bottom_messages=$top_bottom_messages+8; $counter=$counter+1; ENDIF openPrivButton( "close_chat_panel",50,$top_bottom_messages,90,8,8,-1,ISB_DARK,"Close",close_chat_panel ); ENDFOR ENDIF EndSub Sub close_chat_panel ( $KeyFlags, $id ) $count_message_array = arrayCount( $message_array ); FOR ($i=$count_message_array;$i>=1;$i=$i-1) closePrivButton("chat_history_".$i); ENDFOR closePrivButton ("close_chat_panel"); openPrivButton( "open_chat_panel",1,158,8,4,3,-1,ISB_NONE,"^7Team%nl%^7Chat",open_chat_panel ); EndSub