# Connected V1.00 ? Initial release # # Connected V1.01 07-04-2015 Extended the maximum number of players from 32 to 40 # ######################################################################################################### 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 "!connected": connected ( 0,0 ); BREAK; CASE "!plstatus": set_player_status ( $KeyFlags , $argv ); BREAK; CASE "!ready": IF( UserInGroup( "admin", $userName ) == 1 ) THEN cmdLFS ( "/rcm ^2Everyone ready to start? Type: !plstatus 0" ); cmdLFS ( "/rcm_all" ); ELSE PrivMsg( "^1You are not allowed to do that"); ENDIF BREAK; ENDSWITCH EndCatchEvent Sub connected ( $KeyFlags,$id ) ### Set initial values for left/right and top/bottom coordinates ### $left_right_connected = 29; $top_bottom_connected = 50; ### End ### $mList = GetListOfPlayers("N"); $mCount = arrayCount( $mList ); $plyNum=0; /* WriteLine( "########### START DEBUG 1 ##########" ); WHILE ($plyNum < $mCount) $uName = $mList[$plyNum]; writeLine( "Uname = " . GetPlayerVar($uName,"UserName") . " Nname = " . GetPlayerVar($uName,"NickName") ); $plyNum=$plyNum+1; ENDWHILE $plyNum=0; WriteLine( "########### END DEBUG 1 ##########" ); */ ### Close previously opened buttons during automatic refresh, otherwise changed names or people who left aren't shown ### FOR ($i=0;$i<=40;$i=$i+1) closePrivButton ("player_".$i."_number&player_".$i."_nickname&player_".$i."_status"); closePrivButton ("p_exit_".$i); closePrivButton ("s_qual_".$i); ENDFOR openPrivButton( "connect_screen_bg",$left_right_connected,$top_bottom_connected,142,125,5,-1,16,""); openPrivButton( "connect_screen_title",$left_right_connected+1,$top_bottom_connected+1,140,5,5,-1,32,"^7Connected players and qualification admin-tool V1.01" ); WHILE ($plyNum < $mCount) $uName = $mList[$plyNum]; openPrivButton ("player_".$plyNum."_number",$left_right_connected+1,$top_bottom_connected+10,5,5,5,-1,32,$plyNum+1); openPrivButton ("player_".$plyNum."_nickname",$left_right_connected+7,$top_bottom_connected+10,25,5,5,-1,32,GetPlayerVar($uName,"NickName") ); IF ( GetPlayerVar( $uName,"player_status") == 0) THEN openPrivButton ("player_".$plyNum."_status",$left_right_connected+33,$top_bottom_connected+10,15,5,5,-1,32,"^2Ready"); ELSE IF ( GetPlayerVar( $uName,"player_status") == 1) THEN openPrivButton ("player_".$plyNum."_status",$left_right_connected+33,$top_bottom_connected+10,15,5,5,-1,32,"^1Not ready"); ELSE IF ( GetPlayerVar( $uName,"player_status") == 2) THEN openPrivButton ("player_".$plyNum."_status",$left_right_connected+33,$top_bottom_connected+10,15,5,5,-1,32,"^3Spectator"); ELSE openPrivButton ("player_".$plyNum."_status",$left_right_connected+33,$top_bottom_connected+10,15,5,5,-1,32,""); ENDIF ENDIF ENDIF IF ( UserIsAdmin( $userName ) == 1 ) THEN IF ( GetPlayerVar( $uName,"player_call_to_pitlane_exit") == 1 ) THEN openPrivButton ("p_exit_".$plyNum,$left_right_connected+49,$top_bottom_connected+10,10,5,5,-1,32,"^2p_exit",pit_exit); ELSE openPrivButton ("p_exit_".$plyNum,$left_right_connected+49,$top_bottom_connected+10,10,5,5,-1,32,"^7p_exit",pit_exit); ENDIF IF ( GetPlayerVar( $uName,"player_call_to_start_qualify") == 1 ) THEN openPrivButton ("s_qual_".$plyNum,$left_right_connected+60,$top_bottom_connected+10,10,5,5,-1,32,"^2s_qual",start_qual); ELSE openPrivButton ("s_qual_".$plyNum,$left_right_connected+60,$top_bottom_connected+10,10,5,5,-1,32,"^7s_qual",start_qual); ENDIF ENDIF ### Raise $top_bottom_connected with 5 before drawing next button $top_bottom_connected=$top_bottom_connected+5; ### End ### $plyNum=$plyNum+1; ### When player 20 is reached, change value of $left_right_connected to start next colum. Set $top_bottom_connected to initial value ### IF ($plyNum == 20) THEN $left_right_connected = 100; $top_bottom_connected = 50; ENDIF ### End ### ENDWHILE openPrivButton( "refresh_connected",69,164,20,5,10,30,32,"^3Refresh (%cpt%)",connected ); openPrivButton( "close_connected",90,164,20,5,10,-1,32,"^3Close",close_connected ); IF ( UserIsAdmin( $userName ) == 1 ) THEN openPrivButton( "reset_connected",111,164,20,5,10,-1,32,"^3Reset",reset_connected ); openPrivButton( "announce_race_start",69,169,62,5,10,-1,32,"^3Announce race start",announce_race_start ); ENDIF EndSub Sub close_connected ( $KeyFlags,$id ) closePrivButton ("connect_screen_bg&connect_screen_title&refresh_connected&reset_connected&close_connected&announce_race_start"); FOR ($i=0;$i<=40;$i=$i+1) closePrivButton ("player_".$i."_number&player_".$i."_nickname&player_".$i."_status"); closePrivButton ("p_exit_".$i); closePrivButton ("s_qual_".$i); ENDFOR EndSub Sub reset_connected ( $KeyFlags,$id ) $mList = GetListOfPlayers("N"); $mCount = arrayCount( $mList ); $plyNum=0; WHILE ($plyNum < $mCount) $uName = $mList[$plyNum]; SetPlayerVar( $uName,"player_status",1 ); SetPlayerVar( $uName,"player_call_to_pitlane_exit",0 ); SetPlayerVar( $uName,"player_call_to_start_qualify",0 ); $plyNum=$plyNum+1; ENDWHILE connected( 0,0 ); EndSub Sub announce_race_start ( $KeyFlags,$id ) cmdLFS ("/rcm ^2Race starts ^1NOW^2, please be sure to be on track!"); cmdLFS ( "/rcm_all" ); connected( 0,0 ); EndSub Sub set_player_status ( $KeyFlags, $argv ) $status_array[1,0] = "^2Ready"; $status_array[1,1] = "^1Not ready"; $status_array[1,2] = "^3Spectator"; IF ($argv >=0 && $argv <= 2) THEN FOR ($i=0;$i<=2;$i=$i+1) IF ( GetCurrentPlayerVar ("player_status") == $i ) THEN PrivMsg ( "^7Status was: " . $status_array[1,$i] ); SetCurrentPlayerVar( "player_status",$argv ); BREAK; ENDIF ENDFOR FOR ($i=0;$i<=2;$i=$i+1) IF ( GetCurrentPlayerVar ("player_status") == $i ) THEN PrivMsg ( "^7Status is set to: " . $status_array[1,$i] ); BREAK; ENDIF ENDFOR ELSE IF ($argv == "" ) THEN FOR ($i=0;$i<=2;$i=$i+1) IF ( GetCurrentPlayerVar ("player_status") == $i ) THEN PrivMsg ("^7Current status is: " . $status_array[1,$i] ); PrivMsg ("^7Status can be:"); PrivMsg ("^70 = ^2ready^7 , 1 = ^1not ready^7 , 2 =^3spectator"); BREAK; ENDIF ENDFOR ELSE PrivMsg ("^7Status can be:"); PrivMsg ("^70 = ^2ready^7 , 1 = ^1not ready^7 , 2 =^3spectator"); ENDIF ENDIF EndSub Sub pit_exit ( $KeyFlags, $id ) $id = Substr($id,7); $mList = GetListOfPlayers("N"); $uName = $mList[$id+0]; SetPlayerVar( $uName,"player_call_to_pitlane_exit",1 ); cmdLFS ("/msg ^3Go to pitlane exit: " . GetPlayerVar ( $uName,"NickName") ); cmdLFS ("/rcm ^2Go to pitlane exit and prepare for qualify"); cmdLFS ("/rcm_ply " . GetPlayerVar ( $uName,"NickName") ); connected( 0,0 ); EndSub Sub start_qual ( $KeyFlags, $id ) $id = Substr($id,7); $mList = GetListOfPlayers("N"); $uName = $mList[$id+0]; SetPlayerVar( $uName,"player_call_to_start_qualify",1 ); cmdLFS ("/msg ^3Start qualify: " . GetPlayerVar ( $uName,"NickName") ); cmdLFS ("/rcm ^2Start qualify"); cmdLFS ("/rcm_ply " . GetPlayerVar ( $uName,"NickName") ); connected( 0,0 ); EndSub