################################################################################ # Tops - Gui Race Admin Module by Krayy ################################################################################ # Butchered by Sinanju to work in stand alone mode (Sept 2021 - Lapper V7.080) ################################################################################ CatchEvent OnMSO( $userName, $text ) # Player event $idxOfFirstSpace = indexOf( $text, " "); IF( $idxOfFirstSpace == -1 ) THEN $command = $text; $argv = ""; ELSE $command = subStr( $text,0,$idxOfFirstSpace ); $argv = trim( subStr( $text,$idxOfFirstSpace ) ); ENDIF SWITCH ( $command ) CASE "!newtops": DoSinrsTops (); BREAK; ENDSWITCH EndCatchEvent #Sub DoSinrsTops($KeyFlags,$id) - this will not work with CASE command, but does with a button Sub DoSinrsTops() # - this will work with a CASE command IF ( $DefTopCar == "" ) THEN # Get the players TopCar list $TopCarList = GetPlayerTopCars(); ELSE $TopCarList = $DefTopCar; ENDIF SetCurrentPlayerVar("TopCars", $TopCarList); # Set various vars for GUI size and location $TOL = 35; # TOL - Top Origin Left edge of main content window $TOT = 33; # Top Origin Top edge of main content window $TRH = 4; # TRH - Top Row Height # Draw the dialog box openPrivButton ("SinrsTop_topback",$TOL,$TOT,91,$TRH+123,1,-1,16,""); openPrivButton ("SinrsTop_toptitle",$TOL+1,$TOT+1,89,$TRH+1,5,-1,32,"^3Top times on this server"); # Headings openPrivButton ("SinrsTop_toppos",$TOL+1,$TOT+6,8,$TRH+1,1,-1,35, langEngine ("%{built_pos}%")); openPrivButton ("SinrsTop_topcar",$TOL+9,$TOT+6,8,$TRH+1,1,-1,35, langEngine ("%{built_car}%")); openPrivButton ("SinrsTop_topnick",$TOL+17,$TOT+6,36,$TRH+1,1,-1,99, langEngine ("%{built_nick}%")); openPrivButton ("SinrsTop_toppb",$TOL+53,$TOT+6,12,$TRH+1,1,-1,35, langEngine ("%{built_pb}%")); openPrivButton ("SinrsTop_topsplits",$TOL+65,$TOT+6,25,$TRH+1,1,-1,35, langEngine ("%{built_splits}%")); openPrivButton ("SinrsTop_close",$TOL+1,$TOT+121,89,$TRH+1,5,-1,35,"Close",CloseSinrsTop); # Car buttons section openPrivButton ("SinrsTop_carback",$TOL+1,$TOT+107,52,$TRH+10,5,-1,16,""); openPrivButton ("SinrsTop_carbackmessage",$TOL+1,$TOT+107,52,$TRH,5,-1,16,"^2Choose car type to see top times for only that car"); openPrivButton ("SinrsTop_UF1",$TOL+2,$TOT+112,5,$TRH,5,-1,35,"UF1",SelectCar); openPrivButton ("SinrsTop_XFG",$TOL+7,$TOT+112,5,$TRH,5,-1,35,"XFG",SelectCar); openPrivButton ("SinrsTop_XRG",$TOL+12,$TOT+112,5,$TRH,5,-1,35,"XRG",SelectCar); openPrivButton ("SinrsTop_XRT",$TOL+17,$TOT+112,5,$TRH,5,-1,35,"XRT",SelectCar); openPrivButton ("SinrsTop_RB4",$TOL+22,$TOT+112,5,$TRH,5,-1,35,"RB4",SelectCar); openPrivButton ("SinrsTop_FXO",$TOL+27,$TOT+112,5,$TRH,5,-1,35,"FXO",SelectCar); openPrivButton ("SinrsTop_RAC",$TOL+32,$TOT+112,5,$TRH,5,-1,35,"RAC",SelectCar); openPrivButton ("SinrsTop_FZ5",$TOL+37,$TOT+112,5,$TRH,5,-1,35,"FZ5",SelectCar); openPrivButton ("SinrsTop_LX4",$TOL+42,$TOT+112,5,$TRH,5,-1,35,"LX4",SelectCar); openPrivButton ("SinrsTop_LX6",$TOL+47,$TOT+112,5,$TRH,5,-1,35,"LX6",SelectCar); openPrivButton ("SinrsTop_MRT",$TOL+2,$TOT+116,5,$TRH,5,-1,35,"MRT",SelectCar); openPrivButton ("SinrsTop_UFR",$TOL+7,$TOT+116,5,$TRH,5,-1,35,"UFR",SelectCar); openPrivButton ("SinrsTop_XFR",$TOL+12,$TOT+116,5,$TRH,5,-1,35,"XFR",SelectCar); openPrivButton ("SinrsTop_FBM",$TOL+17,$TOT+116,5,$TRH,5,-1,35,"FBM",SelectCar); openPrivButton ("SinrsTop_FOX",$TOL+22,$TOT+116,5,$TRH,5,-1,35,"FOX",SelectCar); openPrivButton ("SinrsTop_FXR",$TOL+27,$TOT+116,5,$TRH,5,-1,35,"FXR",SelectCar); openPrivButton ("SinrsTop_XRR",$TOL+32,$TOT+116,5,$TRH,5,-1,35,"XRR",SelectCar); openPrivButton ("SinrsTop_FZR",$TOL+37,$TOT+116,5,$TRH,5,-1,35,"FZR",SelectCar); openPrivButton ("SinrsTop_FO8",$TOL+42,$TOT+116,5,$TRH,5,-1,35,"FO8",SelectCar); openPrivButton ("SinrsTop_BF1",$TOL+47,$TOT+116,5,$TRH,5,-1,35,"BF1",SelectCar); # Position / Place buttons openPrivButton ("SinrsTop_posback",$TOL+53,$TOT+107,37,$TRH+10,5,-1,16,""); openPrivButton ("SinrsTop_posbackmessage",$TOL+53,$TOT+107,37,$TRH,5,-1,16,"^2Choose to see results from that Position"); openPrivButton ("SinrsTop_top24",$TOL+54,$TOT+112,7,$TRH,4,-1,31,"Very%nl%Top",ListTop24); openPrivButton ("SinrsTop_top25+",$TOL+61,$TOT+112,7,$TRH,4,-1,32,"Top%nl%25+",ListTop25); openPrivButton ("SinrsTop_top49+",$TOL+68,$TOT+112,7,$TRH,4,-1,33,"Top%nl%49+",ListTop29); openPrivButton ("SinrsTop_top69+",$TOL+75,$TOT+112,7,$TRH,4,-1,34,"Top%nl%69+",ListTop69); openPrivButton ("SinrsTop_top89+",$TOL+82,$TOT+112,7,$TRH ,4,-1,35,"Top%nl%89+",ListTop89); $currUName = getCurrentPlayerVar( "UserName" ); $TopCarList = GetPlayerTopCars(); # Check if the User has checked the buttons to display tops for Near or Qual $flagQual = GetCurrentPlayerVar("flagQual"); IF ( $flagQual == "" ) THEN $flagQual = 0; ENDIF $flagNear = GetCurrentPlayerVar("flagNear"); IF ( $flagNear == "" ) THEN $flagNear = 0; ENDIF EndSub ################################ BUTTON CHOICE SECTION ###################################### # Action when you press CAR type button Sub SelectCar ( $KeyFlags, $id ) closeButtonRegex (GetCurrentPlayerVar("UserName"), "SinrsTop_val*"); # only close buttons that show actual data $selected_car = Replace($id,"SinrsTop_",""); SetCurrentPlayerVar( "selected_car",$selected_car ); DrawButtons (); EndSub Sub DrawButtons () $list = getlisttop( GetCurrentPlayerVar( "selected_car"), FALSE,FALSE ); # Set various vars for GUI size and location $TOL = 35; # TOL - Top Origin Left edge of main content window $TOT = 33; # Top Origin Top edge of main content window $TRH = 4; # TRH - Top Row Height # GetListTop cam show 24 results, so we go through them now FOR( $i = 0; $i < 24; $i = $i + 1) # Only show the line if it has a valid username IF ( $list[$i,"UserName"] != "") THEN IF( ToLower( $currUName ) == ToLower( $list[$i,"UserName"] ) ) THEN $bStyle = ISB_DARK; ELSE $bStyle = ISB_LIGHT; ENDIF $TOT = $TOT + $TRH; # Go down to the next printable row openPrivButton ("SinrsTop_val_toppos_" . $i,$TOL+1,$TOT+7,8,$TRH,1,-1,$bStyle, $list[$i,"Pos"]); openPrivButton ("SinrsTop_val_topcar_" . $i,$TOL+9,$TOT+7,8,$TRH,1,-1,$bStyle, $list[$i,"CName"]); openPrivButton ("SinrsTop_val_topnick_" . $i,$TOL+17,$TOT+7,36,$TRH,1,-1,ISB_LEFT + $bStyle, $list[$i,"NickName"]); IF ($list[$i,"PbLapTime"] > 3599000) THEN $colpb = ((3600000 - $list[$i,"PbLapTime"]) / 10) . "/" . GetConfigVar( "LapTimeUsedForPb" ) + langEngine( "%{built_lapsdone}%" ); $colpos = "-"; ELSE $colpb = NumToMSH( $list[$i,"PbLapTime"] ); ENDIF openPrivButton ("SinrsTop_val_toppb_" . $i,$TOL+53,$TOT+7,12,$TRH,1,-1,$bStyle, $colpb); $colsplit = ""; FOR( $k = 0; $k < 3; $k = $k +1 ) $SplitTime = $list[$i,"SplitTime".$k]; IF ($SplitTime != 0) THEN IF ( $colsplit != "" ) THEN $colsplit = $colsplit . "/" . NumToMSH($SplitTime); ELSE $colsplit = NumToMSH($SplitTime); ENDIF ENDIF ENDFOR openPrivButton ("SinrsTop_val_topsplits_" . $i,$TOL+65,$TOT+7,25,$TRH,1,-1,$bStyle, $colsplit); ENDIF ENDFOR EndSub # Action when you press Position type button Sub ListTop24 ( $KeyFlags, $id ) closeButtonRegex (GetCurrentPlayerVar("UserName"), "SinrsTop_*"); # close Top table $list = getlisttopuser("StoredValue",DESC,FALSE,"1" ); #TopList for stored values EndSub # Close whole table Sub CloseSinrsTop($KeyFlags,$id) closeButtonRegex (GetCurrentPlayerVar("UserName"), "SinrsTop_*"); # close Top table EndSub ############################################################################################### # Toggle flagNear between 0 and 1 Sub TopToggleNearTimes ( $KeyFlags, $id ) $flagNear = GetCurrentPlayerVar("flagNear"); IF ( $flagNear == "" | $flagNear == 0) THEN SetCurrentPlayerVar("flagNear", "1"); ELSE SetCurrentPlayerVar("flagNear", "0"); ENDIF DoSinanjuInfoTops( 0, GetCurrentPlayerVar("TopCars") ); EndSub # Toggle flagQual between 0 and 1 Sub TopToggleQualTimes ( $KeyFlags, $id ) $flagQual = GetCurrentPlayerVar("flagQual"); IF ( $flagQual == "" | $flagQual == 0) THEN SetCurrentPlayerVar("flagQual", "1"); ELSE SetCurrentPlayerVar("flagQual", "0"); ENDIF DoSinanjuInfoTops( 0, GetCurrentPlayerVar("TopCars") ); EndSub # Toggle flagNear between 0 and 1 Sub TopToggleCar ( $KeyFlags, $id ) $TopCars = GetPlayerTopCars(); $CName = split( $id,"_",1 ); $idxOfCName = indexOf( $TopCars, $CName); IF ( $idxOfCName == -1 ) THEN $TopCars = $CName . "+" . $TopCars; ELSE $TopCars = StrReplace($TopCars,$CName . "+",""); $TopCars = StrReplace($TopCars,"+" . $CName,""); ENDIF SetCurrentPlayerVar("TopCars", $TopCars); DoSinanjuInfoTops( 0, GetCurrentPlayerVar("TopCars") ); EndSub Sub GetPlayerTopCars() # Use the DeafultTopCar if a player doesn't have it already set $TopCars = GetCurrentPlayerVar("TopCars"); IF ( $TopCars == "" ) THEN $TopCars = getConfigVar("DefaultTopCar"); # Add Players current car into TopCar list as well $CName = GetCurrentPlayerVar("CName"); $idxOfCName = indexOf( $TopCars, $CName); IF ( $idxOfCName == -1 ) THEN $TopCars = $CName . "+" . $TopCars; ENDIF SetCurrentPlayerVar("TopCars", $TopCars); ENDIF return ($TopCars); EndSub