# Top Table per car V1.01 11-03-15 -Initial release # ######################################################################################################################### CatchEvent OnLapperStart() OnLapperStart_TopTable(); 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 "!toptable": Toptable( $KeyFlags ); BREAK; ENDSWITCH EndCatchEvent Sub OnLapperStart_TopTable() ### Declare arrays with carnames ### GlobalVar $car_names; $car_names[1,1] = "UF1"; $car_names[1,2] = "XFG"; $car_names[1,3] = "XRG"; $car_names[1,4] = "LX4"; $car_names[1,5] = "LX6"; $car_names[1,6] = "RB4"; $car_names[1,7] = "FXO"; $car_names[1,8] = "XRT"; $car_names[1,9] = "RAC"; $car_names[1,10] = "FZ5"; $car_names[1,11] = "UFR"; $car_names[1,12] = "XFR"; $car_names[1,13] = "FXR"; $car_names[1,14] = "XRR"; $car_names[1,15] = "FZR"; $car_names[1,16] = "MRT"; $car_names[1,17] = "FBM"; $car_names[1,18] = "FOX"; $car_names[1,19] = "FO8"; $car_names[1,20] = "BF1"; ### END ### EndSub Sub Toptable ( $KeyFlags ) ### Store value used for !top, before running script with every possible car ### $store_def_TopCar = getConfigVar( DefaultTopCar ); #WriteLine( "DefCarStart = " . $store_def_TopCar ); #DEBUG ### End ### ### Set initial values for left/right and top/bottom coordinates ### $left_right_toptable = 1; $top_bottom_toptable = 30; ### End ### $count_car = 0; ### Loop through every car in array $car_names and set DefaultTopCar to the currently listed car FOR( $i = 1; $i <= 20; $i = $i + 1) setConfigVar( DefaultTopCar, $car_names[1,$i] ); ### Get the current Top list for select car. Loop through that list once, to get the best time for that car and display car/nickname/timet on screen ### $list = GetListTop( getConfigVar( DefaultTopCar ), 0, 0 ); FOR( $j = 0; $j < 1; $j = $j + 1) IF ( $list[$j,"UserName"] != "") THEN $count_car = $count_car + 1; ENDIF ENDFOR ### End ### ENDFOR $bg_length = $count_car * 5 + 27; ### Open screen with background and title buttons ### openPrivButton( "toptable_gui_bg",$left_right_toptable,$top_bottom_toptable,142,$bg_length,5,-1,16,""); openPrivButton( "toptable_maintitle",$left_right_toptable+1,$top_bottom_toptable+1,140,5,5,-1,32,"^7TopTable per car V1.01" ); openPrivButton( "toptable_tracktitle",$left_right_toptable+1,$top_bottom_toptable+6,70,5,5,-1,32,"^7Track: " ); openPrivButton( "toptable_track",$left_right_toptable+71,$top_bottom_toptable+6,70,5,5,-1,32,"^7" . GetLapperVar ( "ShortTrackName" ) ); openPrivButton( "toptable_title_car",$left_right_toptable+1,$top_bottom_toptable+11,45,5,5,-1,32,"^7Car:" ); openPrivButton( "toptable_title_nickname",$left_right_toptable+46,$top_bottom_toptable+11,50,5,5,-1,32,"^7Nickname:" ); openPrivButton( "toptable_title_time",$left_right_toptable+96,$top_bottom_toptable+11,45,5,5,-1,32,"^7Time:" ); ### End ### ### Set new value for top/bottom coordinates ### $top_bottom_toptable = 46; ### End ### ### Loop through every car in array $car_names and set DefaultTopCar to the currently listed car FOR( $i = 1; $i <= 20; $i = $i + 1) setConfigVar( DefaultTopCar, $car_names[1,$i] ); # WriteLine( "DefCar = " . $car_names[1,$i] ); #DEBUG ### Get the current Top list for select car. Loop through that list once, to get the best time for that car and display car/nickname/timet on screen ### $list = GetListTop( getConfigVar( DefaultTopCar ), 0, 0 ); FOR( $j = 0; $j < 1; $j = $j + 1) IF ( $list[$j,"UserName"] != "") THEN #WriteLine( "######################" ); #DEBUG #WriteLine( "Car = " . $list[$j,"CName"] ); #DEBUG #WriteLine( "Nickname = " . $list[$j,"NickName"] ); #DEBUG IF ($list[$j,"PbLapTime"] > 3599000) THEN $colpb = ((3600000 - $list[$j,"PbLapTime"]) / 10) . "/" . GetConfigVar( "LapTimeUsedForPb" ) + langEngine( "%{built_lapsdone}%" ); ELSE $colpb = NumToMSH( $list[$j,"PbLapTime"] ); ENDIF #WriteLine( "PB = " . $colpb ); #DEBUG #WriteLine( "######################" ); #DEBUG openPrivButton( "toptable_title_car_".$i,$left_right_toptable+1,$top_bottom_toptable,45,5,5,-1,32,"^7" . $list[$j,"CName"] ); openPrivButton( "toptable_title_nickname_".$i,$left_right_toptable+46,$top_bottom_toptable,50,5,5,-1,32,"^7" . $list[$j,"NickName"] ); openPrivButton( "toptable_title_time_".$i,$left_right_toptable+96,$top_bottom_toptable,45,5,5,-1,32,"^7" . $colpb ); $top_bottom_toptable = $top_bottom_toptable + 5; ENDIF ENDFOR ### End ### ENDFOR ### End ### ### Set new value for top/bottom coordinates. Display button to close the screen ### $top_bottom_toptable = 30 + $bg_length - 6; openPrivButton( "toptable_gui_close",$left_right_toptable+1,$top_bottom_toptable,140,5,5,-1,32,"^3Close", toptable_gui_close ); ### End ### ### Restore value used for DefaultTopCar ### setConfigVar( DefaultTopCar, $store_def_TopCar ); ### End ### #WriteLine( "DefCarEnd = " . $store_def_TopCar ); #DEBUG #WriteLine( "######################" ); #DEBUG #WriteLine( "Number of cars = " . $car_count ); #DEBUG #WriteLine( "######################" ); #DEBUG EndSub Sub toptable_gui_close( $KeyFlags,$id ) closePrivButton ("toptable_gui_bg"); closePrivButton ("toptable_maintitle"); closePrivButton ("toptable_tracktitle"); closePrivButton ("toptable_track"); closePrivButton ("toptable_title_car"); closePrivButton ("toptable_title_nickname"); closePrivButton ("toptable_title_time"); FOR ( $i = 1; $i <= 20; $i = $i + 1 ) closePrivButton("toptable_title_car_".$i); closePrivButton("toptable_title_nickname_" . $i); closePrivButton("toptable_title_time_" . $i); ENDFOR closePrivButton ("toptable_gui_close"); EndSub