# Author: Yisc[NL] # # Lapper version needed: 6.0.1.4 or above # # # # Handicap system V1.01 03-06-11 -Initial release # # Handicap system V1.02 07-06-11 -Added button to clear the whole form # # Handicap system V1.03 07-06-11 -Given car names are checked if they exist # # -Mass values can't be added when no car is selected # # -Given mass value can't be higher then the maximum of the selected car # # -When car name is changed, values for mass are reset # # Handicap system V1.04 07-06-11 -Added 2 buttons to set all values for mass / intake to zero # # Handicap system V1.05 18-06-11 -Added button to Force handicap(s) # # (Handicap settings of each connected player will be checked # # and if not matching handicap settings, player will be spectated) # # -Expanded the number of classes from 4 to 5 # # -Expanded the number of cars from 3 to 4 # # -Fixed a bug in Set all mass to zero function # # Handicap system V1.07 20-06-11 -Fixed a bug in the class checking routine # # Handicap system V1.08 03-07-11 -Fixed a bug in the force handicap subroutine # # -Added the option to save values (HCS_[servername]) # # -Added the option to load saved values # # Handicap system V1.09 26-03-13 -Removed all code related to using $user_array # # Handicap system V1.10 24-04-13 -Added StripLFSColor to the playername check routine # # 24-04-13 -Added option to set a manual class indicator # # Handicap system V1.11 21-01-15 -Auto load handicaps on Lapper start (matched to race using Race ID) # # Handicap system V1.12 24-01-15 -Added option to set handicaps for 3 subclasses # # Handicap system V1.12b 25-01-15 -Clear button wasn't clearing restr. class 4 when subclasses was used # # -Classes were also checked when having set subclasses # # -Mass and intake values weren't always converted to numbers # # -Force handicap(s) button wasn't checking subclasses if they were used # # Handicap system V1.12c 26-01-15 -Fixed isue in "OnNewPlayerJoin_Handicap" that cause Lapper to crash # # Handicap system V1.12d 27-01-15 -Re-write of code to detect color in case of subclasses been used # # Handicap system V1.12e 08-03-15 -Fixed two bugs that checked for the wrong value for subclass # # Handicap system V1.13 24-02-17 -Added checks for every P_Tres to see if variable is number # # -Added checks for every P_Mass to see if variable is number # # Handicap system V1.14 08-08-17 -Added checks on saving HCS and set values to 0 if needed # # Handicap system V1.15 25-09-17 -Added version number as GlobalVar # # -Made message about missing class number dynamic based on nbr of classes used # # Handicap system V2.00.1 BETA 14-10-17 -Fixed a bug about not closing buttons when switching from using no subclasses to using subclasses # # -Renamed sub 'config_class_indicator' to 'config_class_indicator_input' # # -Merged sub 'config_class_indicator_fws' and 'config_class_indicator_pipe' into one sub 'config_class_indicator' # # -A lot of code has been re-written to make it more efficient # # -Added a field to show which cars are used in the race with that Race ID # # -Added a button and routine to copy handicap settings from another Race ID to the current Race ID # # -Added check to make sure a car name is only entered once into the handicap settings of a race # # -Added a button to delete all handicap settings for the selected Race ID # # -Added a check to prevent people from using a * as class indicator (* is used to seperate data when being stored) # ######################################################################################################################################################################### CatchEvent OnLapperStart() OnLapperStart_Handicap(); EndCatchEvent CatchEvent OnConnect( $userName ) OnConnect_Handicap(); EndCatchEvent CatchEvent OnNewPlayerJoin( $userName ) OnNewPlayerJoin_Handicap(); 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 "!hcs": SetCurrentPlayerVar( "data_whipe" , "no" ); Handicap( $KeyFlags,"manual" ); BREAK; ENDSWITCH EndCatchEvent Sub OnLapperStart_Handicap() ### Admin GUI Handicap system #### GlobalVar $version_hcs; GlobalVar $class_indicator; GlobalVar $number_of_classes; GlobalVar $use_subclasses; GlobalVar $number_of_cars; GlobalVar $race_id_handicaps; GlobalVar $copy_hcs_from; $version_hcs = "V2.00.1 BETA"; $class_indicator = "^s"; # ^s is the code to simulate a / $number_of_classes = ""; $use_subclasses = ""; $number_of_cars = ""; $race_id_handicaps = ""; ### End ### ### Declare arrays with carnames and their maximum added weight ### GlobalVar $car_names; GlobalVar $car_weight; $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"; $car_weight[1,1] = 120; $car_weight[1,2] = 190; $car_weight[1,3] = 200; $car_weight[1,4] = 100; $car_weight[1,5] = 110; $car_weight[1,6] = 200; $car_weight[1,7] = 200; $car_weight[1,8] = 200; $car_weight[1,9] = 160; $car_weight[1,10] = 200; $car_weight[1,11] = 120; $car_weight[1,12] = 170; $car_weight[1,13] = 200; $car_weight[1,14] = 200; $car_weight[1,15] = 200; $car_weight[1,16] = 40; $car_weight[1,17] = 90; $car_weight[1,18] = 100; $car_weight[1,19] = 120; $car_weight[1,20] = 110; ### END ### EndSub Sub OnConnect_Handicap() # Player event $pl_name = StripLFSColor( GetCurrentPlayerVar( "NickName" ) ); $pl_name_b = GetCurrentPlayerVar( "NickName" ); $name_length = strlen( $pl_name ); $name_length_b = strlen( $pl_name_b ); $class_string = $name_length-1; $class_string_b = $name_length-3; FOR ($i=0;$i<$name_length_b;$i=$i+1) $j=$i+1; $char_1 = subStr( $pl_name_b, $i, 1 ); $char_2 = subStr( $pl_name_b, $j, 1 ); IF ( $char_1 == "^" && $char_2 == 0 ) THEN $color_to_indicate_subclass="black"; $i=$i+1; ENDIF IF ( $char_1 == "^" && $char_2 == 1 ) THEN $color_to_indicate_subclass="red"; $i=$i+1; ENDIF IF ( $char_1 == "^" && $char_2 == 2 ) THEN $color_to_indicate_subclass="green"; $i=$i+1; ENDIF IF ( $char_1 == "^" && $char_2 == 3 ) THEN $colour_to_indicate_subclass="yellow"; $i=$i+1; ENDIF IF ( $char_1 == "^" && $char_2 == 4 ) THEN $color_to_indicate_subclass="blue"; $i=$i+1; ENDIF IF ( $char_1 == "^" && $char_2 == 5 ) THEN $color_to_indicate_subclass="violet"; $i=$i+1; ENDIF IF ( $char_1 == "^" && $char_2 == 6 ) THEN $color_to_indicate_subclass="cyan"; $i=$i+1; ENDIF IF ( $char_1 == "^" && $char_2 == 7 ) THEN $color_to_indicate_subclass="white"; $i=$i+1; ENDIF IF ( $char_1 == "^" && $char_2 == 9 ) THEN $color_to_indicate_subclass="no_color"; $i=$i+1; ENDIF ENDFOR #" #hashtag quote is there to stop the rest of the script showing up as pink text in EditPlus with the Lapper syntax highlighting IF ( $color_to_indicate_subclass != "red" ) THEN IF ( $color_to_indicate_subclass != "blue" ) THEN IF ($color_to_indicate_subclass != "green" ) THEN $color_to_indicate_subclass = "FALSE"; ENDIF ENDIF ENDIF IF ($class_string > 0) THEN $class = $class_indicator . subStr( $pl_name, $class_string ); $class_ind_player = subStr( $pl_name, $class_string_b,2 ); #Put class & class indicator found in playername into a current player var #Putting it into the $user_array isn't working since OnConnect and OnNewPlayerJoin are run simultaneously #Saving it as a uservar and then reading it back in the OnNewPlayerJoin event, isn't working either because of the same reason SetCurrentPlayerVar ( "class_player", $class ); SetCurrentPlayerVar ( "class_indicator_player", $class_ind_player ); SetCurrentPlayerVar ( "color_to_indicate_subclass", $color_to_indicate_subclass ); ENDIF EndSub Sub OnNewPlayerJoin_Handicap() # Check class indicator in playername again, in case player changed name during his stay on the server # This is not put in CatchEvent OnNameChange($userName,$oldNickName,$newNickName) because you can't spectate someone in that event # Which means people can still join the track with a wrong nickname $pl_name = StripLFSColor( GetCurrentPlayerVar( "NickName" ) ); $pl_name_b = GetCurrentPlayerVar( "NickName" ); $name_length = strlen( $pl_name ); $name_length_b = strlen( $pl_name_b ); $class_string = $name_length-1; $class_string_b = $name_length-3; FOR ($i=0;$i<$name_length_b;$i=$i+1) $j=$i+1; $char_1 = subStr( $pl_name_b, $i, 1 ); $char_2 = subStr( $pl_name_b, $j, 1 ); IF ( $char_1 == "^" && $char_2 == 0 ) THEN $color_to_indicate_subclass="black"; $i=$i+1; ENDIF IF ( $char_1 == "^" && $char_2 == 1 ) THEN $color_to_indicate_subclass="red"; $i=$i+1; ENDIF IF ( $char_1 == "^" && $char_2 == 2 ) THEN $color_to_indicate_subclass="green"; $i=$i+1; ENDIF IF ( $char_1 == "^" && $char_2 == 3 ) THEN $colour_to_indicate_subclass="yellow"; $i=$i+1; ENDIF IF ( $char_1 == "^" && $char_2 == 4 ) THEN $color_to_indicate_subclass="blue"; $i=$i+1; ENDIF IF ( $char_1 == "^" && $char_2 == 5 ) THEN $color_to_indicate_subclass="violet"; $i=$i+1; ENDIF IF ( $char_1 == "^" && $char_2 == 6 ) THEN $color_to_indicate_subclass="cyan"; $i=$i+1; ENDIF IF ( $char_1 == "^" && $char_2 == 7 ) THEN $color_to_indicate_subclass="white"; $i=$i+1; ENDIF IF ( $char_1 == "^" && $char_2 == 9 ) THEN $color_to_indicate_subclass="no_color"; $i=$i+1; ENDIF ENDFOR #" #hashtag quote is there to stop the rest of the script showing up as pink text in EditPlus with the Lapper syntax highlighting IF ( $color_to_indicate_subclass != "red" ) THEN IF ( $color_to_indicate_subclass != "blue" ) THEN IF ($color_to_indicate_subclass != "green" ) THEN $color_to_indicate_subclass = "FALSE"; ENDIF ENDIF ENDIF IF ($class_string > 0) THEN $class = $class_indicator . subStr( $pl_name, $class_string ); $class_ind_player = subStr( $pl_name, $class_string_b,2 ); SetCurrentPlayerVar ( "class_player", $class ); SetCurrentPlayerVar ( "class_indicator_player", $class_ind_player ); SetCurrentPlayerVar ( "color_to_indicate_subclass", $color_to_indicate_subclass ); ENDIF IF (GetCurrentPlayerVar( "class_indicator_player" ) != $class_indicator) THEN cmdLFS("/spec " . GetCurrentPlayerVar("NickName") ); PrivMsg ("^1You haven't set your class and will..." ); PrivMsg ("^1...therefor not be able to race here" ); FOR ( $class=1;$class<=$number_of_classes;$class=$class+1 ) IF ($class == 1) THEN $announcement="".$class_indicator.$class; $last_class=$class_indicator.$class; ELSE $announcement=$announcement." , " . $class_indicator.$class; $last_class=$class_indicator.$class; ENDIF ENDFOR PrivMsg ("^3Put class number " . $announcement . " behind your nickname. Use " . $last_class . " if it's your first season" ); ENDIF IF ($use_subclasses == "yes" && GetCurrentPlayerVar( "color_to_indicate_subclass" ) == "FALSE") THEN cmdLFS("/spec " . GetCurrentPlayerVar("NickName") ); PrivMsg ("^1You haven't set a correct subclass color and..." ); PrivMsg ("^1...will therefor not be able to race here" ); PrivMsg ("^3Put your class either in red, blue or green" ); ENDIF ### Check restrictions when us of subclasses is set to 'yes' ### IF ( $use_subclasses == "yes" ) THEN FOR ( $car_nbr=1;$car_nbr<=$number_of_cars;$car_nbr=$car_nbr+1 ) $storage_name = "HCS_".$race_id_handicaps."_"; $car_details = SplitToArray ( GetStoredValue( $storage_name . "car_" . $car_nbr ) , "*" ); $mass_var = 1; $intake_var = 2; IF ( GetCurrentPlayerVar( "color_to_indicate_subclass" ) == "red" ) THEN $subclass_ply=1; $subclass_color="red"; ELSE IF ( GetCurrentPlayerVar( "color_to_indicate_subclass" ) == "blue" ) THEN $subclass_ply=2; $subclass_color="blue"; ELSE IF ( GetCurrentPlayerVar( "color_to_indicate_subclass" ) == "green" ) THEN $subclass_ply=3; $subclass_color="green"; ENDIF ENDIF ENDIF IF ( GetCurrentPlayerVar("Car") == $car_details[0] ) THEN FOR( $subclasses=1;$subclasses<=3;$subclasses=$subclasses+1 ) IF ( $subclasses == $subclass_ply ) THEN IF ( GetCurrentPlayerVar("P_Mass") != "" ) THEN IF ( ToNum( GetCurrentPlayerVar( "P_Mass") ) < ToNum( $car_details[$mass_var] ) ) THEN cmdLFS("/spec " . GetCurrentPlayerVar("NickName") ); PrivMsg ("^1Subclass " . $subclass_color . ", set added mass to " . $car_details[$mass_var] . "kg for " . $car_details[0] ); ENDIF ENDIF IF ( GetCurrentPlayerVar("P_Tres") != "" ) THEN IF ( ToNum(GetCurrentPlayerVar("P_Tres") ) < ToNum( $car_details[$intake_var] ) ) THEN cmdLFS("/spec " . GetCurrentPlayerVar("NickName") ); PrivMsg ("^1Subclass " . $subclass_color . ", set intake restriction to " . $car_details[$intake_var] . "% for " . $car_details[0] ); ENDIF ENDIF ENDIF $mass_var = $mass_var + 2; $intake_var = $intake_var + 2; ENDFOR ENDIF ENDFOR ENDIF ### End ### ### Check restrictions when us of subclasses is set to 'no' ### IF ( $use_subclasses == "no" ) THEN FOR ( $car_nbr=1;$car_nbr<=$number_of_cars;$car_nbr=$car_nbr+1 ) $storage_name = "HCS_".$race_id_handicaps."_"; $car_details = SplitToArray ( GetStoredValue( $storage_name . "car_" . $car_nbr ) , "*" ); $mass_var = 1; $intake_var = 2; IF ( GetCurrentPlayerVar("Car") == $car_details[0] ) THEN FOR( $classes=1;$classes<=$number_of_classes;$classes=$classes+1 ) IF ( $class_indicator.$classes == $class ) THEN IF ( GetCurrentPlayerVar("P_Mass") != "" ) THEN IF ( ToNum( GetCurrentPlayerVar( "P_Mass") ) < ToNum( $car_details[$mass_var] ) ) THEN cmdLFS("/spec " . GetCurrentPlayerVar("NickName") ); PrivMsg ("^1Class " . $classes . ", set added mass to " . $car_details[$mass_var] . "kg for " . $car_details[0] ); ENDIF ENDIF IF ( GetCurrentPlayerVar("P_Tres") != "" ) THEN IF ( ToNum(GetCurrentPlayerVar("P_Tres") ) < ToNum( $car_details[$intake_var] ) ) THEN cmdLFS("/spec " . GetCurrentPlayerVar("NickName") ); PrivMsg ("^1Class " . $classes . ", set intake restriction to " . $car_details[$intake_var] . "% for " . $car_details[0] ); ENDIF ENDIF ENDIF $mass_var = $mass_var + 2; $intake_var = $intake_var + 2; ENDFOR ENDIF ENDFOR ENDIF ### End ### EndSub Sub Handicap ( $KeyFlags,$id ) IF ( subStr( $id, 0, 16 ) == "schedule_race_id" ) THEN schedule_set_close ( $KeyFlags,$id ); $race_number = subStr( $id, 17, 4 ); SetCurrentPlayerVar( "came_from_race",$race_number ); $race_id_handicaps=GetStoredValue( GetCurrentPlayerVar( "storage_name_schdl" ) . "race_id_".$race_number ); ### If race_id_handicaps ISN'T empty, load storedvalues ### ### Split storedvalues into an array using '*' as splitting value ### ### Set class_indicator, use_subclasses, number_of_classes and number_of cars based on the values in the array but only if they are empty ### IF ( $race_id_handicaps != "" ) THEN $storage_name = "HCS_".$race_id_handicaps."_"; $main_settings = SplitToArray ( GetStoredValue( $storage_name . "main_settings" ),"*" ); $class_indicator = $main_settings[0]; $use_subclasses = $main_settings[1]; $number_of_classes = $main_settings[2]; $number_of_cars = $main_settings[3]; SetCurrentPlayerVar( "data_whipe" , "no" ); ENDIF ### End ### ENDIF ### Set initial values for left/right and top/bottom coordinates ### $left_right_handicap = 1; $top_bottom_handicap = 30; ### End ### openPrivButton( "handicap_gui_bg",$left_right_handicap,$top_bottom_handicap,142,152,5,-1,16,""); openPrivButton( "handicap_title",$left_right_handicap+1,$top_bottom_handicap+1,140,5,5,-1,32,"^7Handicap system " . $version_hcs ); openPrivButton( "handicap_race_id",$left_right_handicap+1,$top_bottom_handicap+6,30,5,5,-1,96,"^7Handicap settings race ID: " ); openPrivButton( "handicap_race_id_input",$left_right_handicap+31,$top_bottom_handicap+6,20,5,5,-1,32,"^7".$race_id_handicaps ); openPrivButton( "cars_used_title",$left_right_handicap+51,$top_bottom_handicap+6,20,5,5,-1,96,"^7Cars used: " ); ### Set server_name and storage_name ### IF ( GetCurrentPlayerVar( "server_name_schedule" ) == "" ) THEN SetCurrentPlayerVar( "server_name_schedule", StripLFSColor( getLapperVar( "HostName" ) ) ); ENDIF SetCurrentPlayerVar( "storage_name_schdl" , "SCHEDULE_" . GetCurrentPlayerVar( "server_name_schedule" ) ."_" ); ### End ### ### Loop through all 14 possible race numbers to find the race number with the matching Race ID ### ### Once found, get the cars used for that race from the databasase and set them to $cars_used ### FOR ($race_nbr=1;$race_nbr<=14;$race_nbr=$race_nbr+1) IF ( GetStoredValue( GetCurrentPlayerVar( "storage_name_schdl" ) . "race_id_".$race_nbr ) == $race_id_handicaps ) THEN $cars_used = GetStoredValue( GetCurrentPlayerVar( "storage_name_schdl" ) . "cars_".$race_nbr ); BREAK; ENDIF ENDFOR ### End ### openPrivButton( "cars_used_value",$left_right_handicap+71,$top_bottom_handicap+6,30,5,5,-1,96,"^7" . $cars_used ); IF ( $copy_hcs_from == "" ) THEN openPrivTextButton( "copy_hcs_from",$left_right_handicap+101,$top_bottom_handicap+6,40,5,5,32,"^3Enter Race ID to copy handicap settings from","^3Copy handicap settings from" . "%nl%^3Race ID ???" . "%nl%^3Click this button to set ID",3,load_hcs_from ); ELSE openPrivButton( "copy_hcs_from",$left_right_handicap+101,$top_bottom_handicap+6,40,5,5,-1,32,"^2Copy settings from Race ID " . $copy_hcs_from . "%nl%^3Click left mouse button to copy" . "%nl%^3Click right mouse button to cancel", copy_hcs_from ); ENDIF openPrivButton( "handicap_class_indicator",$left_right_handicap+1,$top_bottom_handicap+16,30,5,5,-1,96,"^7Class indicator: " ); IF ( $class_indicator == "^s") #simulate: / THEN openPrivButton( "handicap_class_indicator_input_1",$left_right_handicap+31,$top_bottom_handicap+16,10,5,5,-1,32,"^2".$class_indicator,config_class_indicator ); ELSE openPrivButton( "handicap_class_indicator_input_1",$left_right_handicap+31,$top_bottom_handicap+16,10,5,5,-1,32,"^3/",config_class_indicator ); ENDIF IF ( $class_indicator == "^v") #simulate: | THEN openPrivButton( "handicap_class_indicator_input_2",$left_right_handicap+41,$top_bottom_handicap+16,10,5,5,-1,32,"^2".$class_indicator,config_class_indicator ); ELSE openPrivButton( "handicap_class_indicator_input_2",$left_right_handicap+41,$top_bottom_handicap+16,10,5,5,-1,32,"^3|",config_class_indicator ); ENDIF IF ( $class_indicator != "^s" && $class_indicator != "^v" && $class_indicator != "" ) THEN openPrivTextButton( "handicap_class_indicator_input_3",$left_right_handicap+51,$top_bottom_handicap+16,20,5,5,32,"^2Class indicator","^2".$class_indicator,3,config_class_indicator_input ); ELSE openPrivTextButton( "handicap_class_indicator_input_3",$left_right_handicap+51,$top_bottom_handicap+16,20,5,5,32,"^3Class indicator","^3Click to set",3,config_class_indicator_input ); ENDIF openPrivButton( "handicap_use_subclasses",$left_right_handicap+1,$top_bottom_handicap+21,30,5,5,-1,96,"^7Use subclasses: " ); IF ( $use_subclasses == "no" || $use_subclasses == "" ) THEN openPrivButton( "handicap_use_subclasses_no",$left_right_handicap+31,$top_bottom_handicap+21,20,5,5,-1,32,"^2No" ); openPrivButton( "handicap_use_subclasses_yes",$left_right_handicap+51,$top_bottom_handicap+21,20,5,5,-1,32,"^3Yes",set_subclass ); IF ( $use_subclasses == "" ) THEN $use_subclasses="no"; ENDIF ELSE openPrivButton( "handicap_use_subclasses_no",$left_right_handicap+31,$top_bottom_handicap+21,20,5,5,-1,32,"^3No",set_subclass ); openPrivButton( "handicap_use_subclasses_yes",$left_right_handicap+51,$top_bottom_handicap+21,20,5,5,-1,32,"^2Yes" ); ENDIF IF ( $use_subclasses != "yes" ) THEN openPrivButton( "handicap_number_of_classes",$left_right_handicap+1,$top_bottom_handicap+26,30,5,5,-1,96,"^7Number of classes: " ); IF ( $number_of_classes == "" ) THEN openPrivTextButton( "handicap_number_of_classes_input",$left_right_handicap+31,$top_bottom_handicap+26,40,5,5,32,"^3Number of classes (max 5)","^3Click to set",1,config_number_of_classes ); ELSE openPrivTextButton( "handicap_number_of_classes_input",$left_right_handicap+31,$top_bottom_handicap+26,40,5,5,32,"^3Number of classes (max 5)","^3".$number_of_classes,1,config_number_of_classes ); ENDIF ENDIF openPrivButton( "handicap_number_of_cars",$left_right_handicap+1,$top_bottom_handicap+31,30,5,5,-1,96,"^7Number of cars: " ); openPrivButton( "handicap_mass_title",$left_right_handicap+101,$top_bottom_handicap+26,20,5,5,-1,32,"^7Mass (kg)" ); IF ($number_of_classes != "" && $number_of_cars != "") THEN openPrivButton( "handicap_mass_zero",$left_right_handicap+101,$top_bottom_handicap+31,20,5,5,-1,32,"^3Set all to 0",mass_all_to_zero ); ENDIF openPrivButton( "handicap_intake_title",$left_right_handicap+121,$top_bottom_handicap+26,20,5,5,-1,32,"^7Intake (%)" ); IF ($number_of_classes != "" && $number_of_cars != "") THEN openPrivButton( "handicap_intake_zero",$left_right_handicap+121,$top_bottom_handicap+31,20,5,5,-1,32,"^3Set all to 0",intake_all_to_zero ); ENDIF IF ( $number_of_cars == "") THEN openPrivTextButton( "handicap_number_of_cars_input",$left_right_handicap+31,$top_bottom_handicap+31,40,5,5,32,"^3Number of cars (max 4)","^3Click to set",1,config_number_of_cars ); ELSE openPrivTextButton( "handicap_number_of_cars_input",$left_right_handicap+31,$top_bottom_handicap+31,40,5,5,32,"^3Number of cars (max 4)","^3".$number_of_cars,1,config_number_of_cars ); $top_offset=36; $top_offset_2=36; IF ( $use_subclasses == "yes" ) THEN FOR ($car=1;$car<=$number_of_cars;$car=$car+1) openPrivButton( "handicap_car_name_" . $car,$left_right_handicap+1,$top_bottom_handicap+$top_offset,30,5,5,-1,96,"^7Car " . $car . ": " ); $storage_name = "HCS_".$race_id_handicaps."_"; $car_details = SplitToArray ( GetStoredValue( $storage_name . "car_" . $car ) , "*" ); IF ( GetCurrentPlayerVar( "car_name_" . $car ) == "" && GetCurrentPlayerVar( "data_whipe" ) != "yes" ) THEN SetCurrentPlayerVar( "car_name_" . $car , $car_details[0] ); ENDIF IF ( GetCurrentPlayerVar( "car_name_" . $car ) == "" ) THEN openPrivTextButton( "handicap_input_car_name_" . $car,$left_right_handicap+31,$top_bottom_handicap+$top_offset,40,5,5,32,"^3Short name of car " . $car,"^3Click to set", 3, config_car_name ); ELSE openPrivTextButton( "handicap_input_car_name_" . $car,$left_right_handicap+31,$top_bottom_handicap+$top_offset,40,5,5,32,"^3Short name of car " . $car,"^3" . GetCurrentPlayerVar( "car_name_" . $car ), 3, config_car_name ); ENDIF $mass_var = 1; $intake_var = 2; FOR ( $subclass=1;$subclass<=3;$subclass=$subclass+1 ) IF ( GetCurrentPlayerVar( "car_mass_" . $car . "_" . $subclass ) == "" && GetCurrentPlayerVar( "data_whipe" ) != "yes" ) THEN SetCurrentPlayerVar( "car_mass_" . $car . "_" . $subclass , $car_details[$mass_var] ); $mass_var = $mass_var + 2; ENDIF IF ( GetCurrentPlayerVar( "car_intake_" . $car . "_" . $subclass ) == "" && GetCurrentPlayerVar( "data_whipe" ) != "yes" ) THEN SetCurrentPlayerVar( "car_intake_" . $car . "_" . $subclass , $car_details[$intake_var] ); $intake_var = $intake_var + 2; ENDIF IF ( $subclass == 1 ) THEN $subclass_color="^1red"; ENDIF IF ( $subclass == 2 ) THEN $subclass_color="^4blue"; ENDIF IF ( $subclass == 3 ) THEN $subclass_color="^2green"; ENDIF openPrivButton( "handicap_restiction_class_" . $car . "_" . $subclass,$left_right_handicap+71,$top_bottom_handicap+$top_offset_2,30,5,5,-1,96,"^7Restr. subclass " . $subclass_color . "^7: " ); IF ( GetCurrentPlayerVar( "car_mass_" . $car . "_" . $subclass ) == "" ) THEN openPrivTextButton( "handicap_mass_restiction_class_" . $car . "_" . $subclass,$left_right_handicap+101,$top_bottom_handicap+$top_offset_2,20,5,5,32,"^3Mass car " . $car . " - subclass " . $subclass_color,"^3Click to set" , 3 , config_car_mass ); ELSE openPrivTextButton( "handicap_mass_restiction_class_" . $car . "_" . $subclass,$left_right_handicap+101,$top_bottom_handicap+$top_offset_2,20,5,5,32,"^3Mass car " . $car . " - subclass " . $subclass_color,"^3" . GetCurrentPlayerVar( "car_mass_" . $car . "_" . $subclass ) , 3 , config_car_mass ); ENDIF IF ( GetCurrentPlayerVar( "car_intake_" . $car . "_" . $subclass ) == "" ) THEN openPrivTextButton( "handicap_intake_restiction_class_" . $car . "_" . $subclass,$left_right_handicap+121,$top_bottom_handicap+$top_offset_2,20,5,5,32,"^3Intake car " . $car . " - subclass " . $subclass_color,"^3Click to set" , 2 , config_car_intake ); ELSE openPrivTextButton( "handicap_intake_restiction_class_" . $car . "_" . $subclass,$left_right_handicap+121,$top_bottom_handicap+$top_offset_2,20,5,5,32,"^3Intake car " . $car . " - subclass " . $subclass_color,"^3" . GetCurrentPlayerVar( "car_intake_" . $car . "_" . $subclass ) , 2 , config_car_intake ); ENDIF $top_offset_2=$top_offset_2+5; ENDFOR $top_offset=$top_offset+$number_of_classes*5; ENDFOR ENDIF IF ( $use_subclasses == "no" ) THEN FOR ($car=1;$car<=$number_of_cars;$car=$car+1) openPrivButton( "handicap_car_name_" . $car,$left_right_handicap+1,$top_bottom_handicap+$top_offset,30,5,5,-1,96,"^7Car " . $car . ": " ); $storage_name = "HCS_".$race_id_handicaps."_"; $car_details = SplitToArray ( GetStoredValue( $storage_name . "car_" . $car ) , "*" ); IF ( GetCurrentPlayerVar( "car_name_" . $car ) == "" && GetCurrentPlayerVar( "data_whipe" ) != "yes" ) THEN SetCurrentPlayerVar( "car_name_" . $car , $car_details[0] ); ENDIF IF ( GetCurrentPlayerVar( "car_name_" . $car ) == "" ) THEN openPrivTextButton( "handicap_input_car_name_" . $car,$left_right_handicap+31,$top_bottom_handicap+$top_offset,40,5,5,32,"^3Short name of car " . $car,"^3Click to set", 3, config_car_name ); ELSE openPrivTextButton( "handicap_input_car_name_" . $car,$left_right_handicap+31,$top_bottom_handicap+$top_offset,40,5,5,32,"^3Short name of car " . $car,"^3" . GetCurrentPlayerVar( "car_name_" . $car ), 3, config_car_name ); ENDIF $mass_var = 1; $intake_var = 2; FOR ( $class=1;$class<=$number_of_classes;$class=$class+1 ) IF ( GetCurrentPlayerVar( "car_mass_" . $car . "_" . $class ) == "" && GetCurrentPlayerVar( "data_whipe" ) != "yes" ) THEN SetCurrentPlayerVar( "car_mass_" . $car . "_" . $class , $car_details[$mass_var] ); $mass_var = $mass_var + 2; ENDIF IF ( GetCurrentPlayerVar( "car_intake_" . $car . "_" . $class ) == "" && GetCurrentPlayerVar( "data_whipe" ) != "yes" ) THEN SetCurrentPlayerVar( "car_intake_" . $car . "_" . $class , $car_details[$intake_var] ); $intake_var = $intake_var + 2; ENDIF openPrivButton( "handicap_restiction_class_" . $car . "_" . $class,$left_right_handicap+71,$top_bottom_handicap+$top_offset_2,30,5,5,-1,96,"^7Restriction class " . $class . ": " ); IF ( GetCurrentPlayerVar( "car_mass_" . $car . "_" . $class ) == "" ) THEN openPrivTextButton( "handicap_mass_restiction_class_" . $car . "_" . $class,$left_right_handicap+101,$top_bottom_handicap+$top_offset_2,20,5,5,32,"^3Mass car " . $car . " - class " . $class,"^3Click to set" , 3 , config_car_mass ); ELSE openPrivTextButton( "handicap_mass_restiction_class_" . $car . "_" . $class,$left_right_handicap+101,$top_bottom_handicap+$top_offset_2,20,5,5,32,"^3Mass car " . $car . " - class " . $class,"^3" . GetCurrentPlayerVar( "car_mass_" . $car . "_" . $class ) , 3 , config_car_mass ); ENDIF IF ( GetCurrentPlayerVar( "car_intake_" . $car . "_" . $class ) == "" ) THEN openPrivTextButton( "handicap_intake_restiction_class_" . $car . "_" . $class,$left_right_handicap+121,$top_bottom_handicap+$top_offset_2,20,5,5,32,"^3Intake car " . $car . " - class " . $class,"^3Click to set" , 2 , config_car_intake ); ELSE openPrivTextButton( "handicap_intake_restiction_class_" . $car . "_" . $class,$left_right_handicap+121,$top_bottom_handicap+$top_offset_2,20,5,5,32,"^3Intake car " . $car . " - class " . $class,"^3" . GetCurrentPlayerVar( "car_intake_" . $car . "_" . $class ) , 2 , config_car_intake ); ENDIF $top_offset_2=$top_offset_2+5; ENDFOR $top_offset=$top_offset+$number_of_classes*5; ENDFOR ENDIF ENDIF openPrivButton( "handicap_gui_clear",$left_right_handicap+1,$top_bottom_handicap+141,35,5,5,-1,32,"^3Clear settings", handicap_gui_clear ); openPrivButton( "handicap_gui_delete",$left_right_handicap+36,$top_bottom_handicap+141,35,5,5,-1,32,"^1Delete settings", handicap_gui_delete ); openPrivButton( "handicap_gui_force",$left_right_handicap+71,$top_bottom_handicap+141,35,5,5,-1,32,"^3Force handicap(s)", handicap_gui_force ); openPrivButton( "handicap_gui_save",$left_right_handicap+106,$top_bottom_handicap+141,35,5,5,-1,32,"^3Save settings", handicap_gui_save ); openPrivButton( "handicap_gui_close",$left_right_handicap+1,$top_bottom_handicap+146,140,5,5,-1,32,"^3Close", handicap_gui_close ); EndSub Sub config_class_indicator ( $KeyFlag,$id ) IF ( $id == "handicap_class_indicator_input_1" ) THEN $class_indicator="^s"; # simulate: / ELSE IF ( $id == "handicap_class_indicator_input_2" ) THEN $class_indicator="^v"; # simulate: | ENDIF ENDIF $indicator_length = strlen( $class_indicator ); Handicap( $KeyFlags,$id ); EndSub Sub config_class_indicator_input ( $id,$text ) IF ( $text == "/" ) THEN $class_indicator="^s"; # simulate: / ELSE IF ( $text == "|" ) THEN $class_indicator="^v"; # simulate: | ELSE IF ( $text == "*" ) THEN PrivMsg ( "^1WARNING: ^7A * may not be used as class indicator" ); ELSE $class_indicator=$text; ENDIF ENDIF ENDIF $indicator_length = strlen( $class_indicator ); Handicap( $KeyFlags,$id ); EndSub Sub config_number_of_classes ( $id,$text ) IF ($number_of_classes != "") THEN FOR ( $car_nbr=1;$car_nbr<=$number_of_cars;$car_nbr=$car_nbr+1 ) SetCurrentPlayerVar( "car_name_" . $car_nbr , "" ); closePrivButton( "handicap_car_name_" . $car_nbr ); closePrivButton( "handicap_input_car_name_" . $car_nbr ); FOR( $subclass=1;$subclass<=5;$subclass=$subclass+1 ) SetCurrentPlayerVar( "car_mass_" . $car_nbr . "_" . $subclass , "" ); SetCurrentPlayerVar( "car_intake_" . $car_nbr . "_" . $subclass , "" ); closePrivButton( "handicap_restiction_class_" . $car_nbr . "_" . $subclass ); closePrivButton( "handicap_mass_restiction_class_" . $car_nbr . "_" . $subclass ); closePrivButton( "handicap_intake_restiction_class_" . $car_nbr . "_" . $subclass ); ENDFOR ENDFOR SetCurrentPlayerVar( "data_whipe" , "yes" ); ENDIF IF ($text > 5) THEN PrivMsg ("^1Given number of classes is too high, value won't be changed"); ELSE IF ($text == 0) THEN PrivMsg ("^1Given number of classes can't be zero, value won't be changed"); ELSE $number_of_classes=$text; ENDIF ENDIF Handicap( $KeyFlags,$id ); EndSub Sub set_subclass ( $KeyFlags, $id ) FOR ( $car_nbr=1;$car_nbr<=$number_of_cars;$car_nbr=$car_nbr+1 ) SetCurrentPlayerVar( "car_name_" . $car_nbr , "" ); closePrivButton( "handicap_car_name_" . $car_nbr ); closePrivButton( "handicap_input_car_name_" . $car_nbr ); FOR( $subclass=1;$subclass<=5;$subclass=$subclass+1 ) SetCurrentPlayerVar( "car_mass_" . $car_nbr . "_" . $subclass , "" ); SetCurrentPlayerVar( "car_intake_" . $car_nbr . "_" . $subclass , "" ); closePrivButton( "handicap_restiction_class_" . $car_nbr . "_" . $subclass ); closePrivButton( "handicap_mass_restiction_class_" . $car_nbr . "_" . $subclass ); closePrivButton( "handicap_intake_restiction_class_" . $car_nbr . "_" . $subclass ); ENDFOR ENDFOR SetCurrentPlayerVar( "data_whipe" , "yes" ); IF ( $id == "handicap_use_subclasses_yes" ) THEN $use_subclasses = "yes"; $number_of_classes = 3; $number_of_cars = ""; closePrivButton("handicap_number_of_classes"); closePrivButton("handicap_number_of_classes_input"); ELSE $use_subclasses = "no"; $number_of_classes = ""; $number_of_cars = ""; ENDIF Handicap( $KeyFlags,$id ); EndSub Sub config_number_of_cars ( $id,$text ) IF ($number_of_cars != "") THEN FOR ( $car_nbr=1;$car_nbr<=$number_of_cars;$car_nbr=$car_nbr+1 ) SetCurrentPlayerVar( "car_name_" . $car_nbr , "" ); closePrivButton( "handicap_car_name_" . $car_nbr ); closePrivButton( "handicap_input_car_name_" . $car_nbr ); FOR( $subclass=1;$subclass<=5;$subclass=$subclass+1 ) SetCurrentPlayerVar( "car_mass_" . $car_nbr . "_" . $subclass , "" ); SetCurrentPlayerVar( "car_intake_" . $car_nbr . "_" . $subclass , "" ); closePrivButton( "handicap_restiction_class_" . $car_nbr . "_" . $subclass ); closePrivButton( "handicap_mass_restiction_class_" . $car_nbr . "_" . $subclass ); closePrivButton( "handicap_intake_restiction_class_" . $car_nbr . "_" . $subclass ); ENDFOR ENDFOR SetCurrentPlayerVar( "data_whipe" , "yes" ); ENDIF IF ( $number_of_classes == "" ) THEN PrivMsg ( "^1Number of classes has to be set first, value won't be changed" ); ELSE IF ( $text > 4 ) THEN PrivMsg ( "^1Given number of cars is too high, value won't be changed" ); ELSE IF ( $text == 0 ) THEN PrivMsg ( "^1Given number of cars can't be zero, value won't be changed" ); ELSE $number_of_cars=$text; ENDIF ENDIF ENDIF Handicap( $KeyFlags,$id ); EndSub Sub config_car_name ( $id,$text ) ### Extract car number from the $id that is used to enter the Sub ### $car = SubStr ( $id , 24 , 1 ); ### End ### ### Delete CurrentPlayerVar '"car_name_" . $car' in order to able to check wether it is in the car_names array or not ### SetCurrentPlayerVar( "car_name_" . $car , "" ); ### End ### ### Delete all values for mass related to $car, otherwise an incorrect value for the previously chosen car could left behind ### FOR( $subclass=1;$subclass<=5;$subclass=$subclass+1 ) SetCurrentPlayerVar( "car_mass_" . $car . "_" . $subclass , "" ); ENDFOR ### End ### SetCurrentPlayerVar( "data_whipe" , "yes" ); ### Search array $car_names for corresponding car value ### ### If value is found, set name of car accordingly ### FOR( $car_nbr=1;$car_nbr<=20;$car_nbr=$car_nbr+1 ) IF ( ToUpper( $text ) == $car_names[1,$car_nbr] ) THEN $error="false"; FOR( $cars=1;$cars<=4;$cars=$cars+1 ) IF ( GetCurrentPlayerVar( "car_name_" . $cars ) != "" ) THEN IF ( GetCurrentPlayerVar( "car_name_" . $cars ) == $text ) THEN $error="true"; BREAK; ENDIF ENDIF ENDFOR IF ( $error == "false" ) THEN SetCurrentPlayerVar( "car_name_" . $car , ToUpper( $text ) ); ENDIF ENDIF ENDFOR ### End ### ### In case car name isn't set, notify user about it ### IF ( GetCurrentPlayerVar( "car_name_" . $car ) == "" && $error == "true" ) THEN PrivMsg("^1Car name is already used, value won't be changed"); ELSE IF ( GetCurrentPlayerVar( "car_name_" . $car ) == "" ) THEN PrivMsg("^1Car name (Car " . $car . ") not found, value won't be changed"); ENDIF ENDIF ### End ### ### Go back to Sub Handicap ### Handicap( $KeyFlags,$id ); ### End ### EndSub Sub config_car_mass ( $id,$text ) ### Extract car number and subclass from the $id that is used to enter the Sub ### $car = SubStr ( $id , 31 , 1 ); $subclass = SubStr ( $id , 33 , 1 ); ### End ### ### If carname isn't empty, search array $car_names for corresponding value and then check if weight input isn't above maximum for that car ### ### Notify user if it is, otherwise set car_mass ### ### Notify user if carname is empty ### IF ( GetCurrentPlayerVar( "car_name_" . $car ) != "") THEN FOR( $car_nbr=1;$car_nbr<=20;$car_nbr=$car_nbr+1 ) IF ( GetCurrentPlayerVar( "car_name_" . $car ) == $car_names[1,$car_nbr] ) THEN IF ( ToNum( $text ) > $car_weight[1,$car_nbr] ) THEN PrivMsg ( "^1Value can't be above " . $car_weight[1,$car_nbr] . ", value won't be changed" ); ELSE SetCurrentPlayerVar( "car_mass_" . $car . "_" . $subclass , ToNum( $text ) ); ENDIF ENDIF ENDFOR ELSE PrivMsg("^1Name of Car " . $car . " isn't set, value won't be changed"); ENDIF ### End ### ### Go back to Sub Handicap ### Handicap( $KeyFlags,$id ); ### End ### EndSub Sub config_car_intake ( $id,$text ) ### Extract car number and subclass from the $id that is used to enter the Sub ### $car = SubStr ( $id , 33 , 1 ); $subclass = SubStr ( $id , 35 , 1 ); ### End ### ### Check if given value isn't above 50 (maximum percentage intake restriction can be) ### ### If so, notify user about that, otherwise set value ### IF (ToNum( $text ) > 50) THEN PrivMsg ("^1Value can't be above 50, value won't be changed"); ELSE SetCurrentPlayerVar( "car_intake_" . $car . "_" . $subclass , ToNum( $text ) ); ENDIF ### End ### ### Go back to Sub Handicap ### Handicap( $KeyFlags,$id ); ### End ### EndSub Sub config_handicap_race_id ($race_id_handicaps_value,$text) $race_id_handicaps=ToNum( $text ); Handicap( $KeyFlags,$id ); Endsub Sub handicap_gui_clear( $KeyFlags,$id ) FOR ( $car_nbr=1;$car_nbr<=$number_of_cars;$car_nbr=$car_nbr+1 ) SetCurrentPlayerVar( "car_name_" . $car_nbr , "" ); closePrivButton( "handicap_car_name_" . $car_nbr ); closePrivButton( "handicap_input_car_name_" . $car_nbr ); FOR( $subclass=1;$subclass<=5;$subclass=$subclass+1 ) SetCurrentPlayerVar( "car_mass_" . $car_nbr . "_" . $subclass , "" ); SetCurrentPlayerVar( "car_intake_" . $car_nbr . "_" . $subclass , "" ); closePrivButton( "handicap_restiction_class_" . $car_nbr . "_" . $subclass ); closePrivButton( "handicap_mass_restiction_class_" . $car_nbr . "_" . $subclass ); closePrivButton( "handicap_intake_restiction_class_" . $car_nbr . "_" . $subclass ); ENDFOR ENDFOR $use_subclasses=""; $number_of_classes=""; $number_of_cars=""; #$race_id_handicaps=""; Handicap( $KeyFlags,$id ); EndSub Sub mass_all_to_zero( $KeyFlags,$id ) $error=0; FOR ( $car_nbr=1;$car_nbr<=$number_of_cars;$car_nbr=$car_nbr+1 ) IF ( GetCurrentPlayerVar( "car_name_" . $car_nbr ) == "" ) THEN PrivMsg("^1Name of Car " . $car_nbr . " isn't set, value won't be changed"); $error=$error+1; ENDIF ENDFOR IF ( $error == 0 ) THEN FOR ( $car_nbr=1;$car_nbr<=$number_of_cars;$car_nbr=$car_nbr+1 ) IF ( $use_subclasses == "yes" ) THEN FOR ( $subclass=1;$subclass<=3;$subclass=$subclass+1 ) SetCurrentPlayerVar( "car_mass_" . $car_nbr . "_" . $subclass , 0 ); ENDFOR ENDIF IF ( $use_subclasses == "no" ) THEN FOR ( $class=1;$class<=$number_of_classes;$class=$class+1 ) SetCurrentPlayerVar( "car_mass_" . $car_nbr . "_" . $class , 0 ); ENDFOR ENDIF ENDFOR ENDIF Handicap( $KeyFlags,$id ); EndSub Sub intake_all_to_zero( $KeyFlags,$id ) $error=0; FOR ( $car_nbr=1;$car_nbr<=$number_of_cars;$car_nbr=$car_nbr+1 ) IF ( GetCurrentPlayerVar( "car_name_" . $car_nbr ) == "" ) THEN PrivMsg("^1Name of Car " . $car_nbr . " isn't set, value won't be changed"); $error=$error+1; ENDIF ENDFOR IF ( $error == 0 ) THEN FOR ( $car_nbr=1;$car_nbr<=$number_of_cars;$car_nbr=$car_nbr+1 ) IF ( $use_subclasses == "yes" ) THEN FOR ( $subclass=1;$subclass<=3;$subclass=$subclass+1 ) SetCurrentPlayerVar( "car_intake_" . $car_nbr . "_" . $subclass , 0 ); ENDFOR ENDIF IF ( $use_subclasses == "no" ) THEN FOR ( $class=1;$class<=$number_of_classes;$class=$class+1 ) SetCurrentPlayerVar( "car_intake_" . $car_nbr . "_" . $class , 0 ); ENDFOR ENDIF ENDFOR ENDIF Handicap( $KeyFlags,$id ); EndSub Sub handicap_gui_force( $KeyFlags,$id ) $counter_intake = 0; $counter_mass = 0; $mList = GetListOfPlayers("N"); $mCount = arrayCount( $mList ); $plyNum=0; WHILE ($plyNum < $mCount) $uName = $mList[$plyNum]; ### Check restrictions when us of subclasses is set to 'yes' ### IF ( $use_subclasses == "yes" ) THEN FOR ( $car_nbr=1;$car_nbr<=$number_of_cars;$car_nbr=$car_nbr+1 ) $storage_name = "HCS_".$race_id_handicaps."_"; $car_details = SplitToArray ( GetStoredValue( $storage_name . "car_" . $car_nbr ) , "*" ); $mass_var = 1; $intake_var = 2; IF ( GetPlayerVar( $uName,"color_to_indicate_subclass" ) == "red" ) THEN $subclass_ply=1; $subclass_color="red"; ELSE IF ( GetPlayerVar( $uName,"color_to_indicate_subclass" ) == "blue" ) THEN $subclass_ply=2; $subclass_color="blue"; ELSE IF ( GetPlayerVar( $uName,"color_to_indicate_subclass" ) == "green" ) THEN $subclass_ply=3; $subclass_color="green"; ENDIF ENDIF ENDIF IF ( GetPlayerVar( $uName,"Car" ) == $car_details[0] ) THEN FOR( $subclasses=1;$subclasses<=3;$subclasses=$subclasses+1 ) IF ( $subclasses == $subclass_ply ) THEN IF ( GetPlayerVar( $uName,"P_Mass" ) != "" ) THEN IF ( ToNum( GetPlayerVar( $uName,"P_Mass" ) ) < ToNum( $car_details[$mass_var] ) ) THEN cmdLFS("/spec " . GetPlayerVar( $uName,"NickName" ) ); PrivMsg ("^1Subclass " . $subclass_color . ", set added mass to " . $car_details[$mass_var] . "kg for " . $car_details[0] ); $counter_mass=$counter_mass+1; ENDIF ENDIF IF ( GetPlayerVar( $uName,"P_Tres" ) != "" ) THEN IF ( ToNum( GetPlayerVar( $uName,"P_Tres" ) ) < ToNum( $car_details[$intake_var] ) ) THEN cmdLFS("/spec " . GetPlayerVar( $uName,"NickName" ) ); PrivMsg ("^1Subclass " . $subclass_color . ", set intake restriction to " . $car_details[$intake_var] . "% for " . $car_details[0] ); $counter_intake=$counter_intake+1; ENDIF ENDIF ENDIF $mass_var = $mass_var + 2; $intake_var = $intake_var + 2; ENDFOR ENDIF ENDFOR ENDIF ### End ### ### Check restrictions when us of subclasses is set to 'no' ### IF ( $use_subclasses == "no" ) THEN FOR ( $car_nbr=1;$car_nbr<=$number_of_cars;$car_nbr=$car_nbr+1 ) $storage_name = "HCS_".$race_id_handicaps."_"; $car_details = SplitToArray ( GetStoredValue( $storage_name . "car_" . $car_nbr ) , "*" ); $mass_var = 1; $intake_var = 2; IF ( GetPlayerVar( $uName,"Car" ) == $car_details[0] ) THEN FOR( $classes=1;$classes<=$number_of_classes;$classes=$classes+1 ) IF ( GetPlayerVar( $uName,"class_player" ) == $class_indicator.$classes ) THEN IF ( GetPlayerVar( $uName,"P_Mass" ) != "" ) THEN IF ( ToNum( GetPlayerVar( $uName,"P_Mass" ) ) < ToNum( $car_details[$mass_var] ) ) THEN cmdLFS("/spec " . GetPlayerVar( $uName,"NickName" ) ); PrivMsg ("^1Class " . $classes . ", set added mass to " . $car_details[$mass_var] . "kg for " . $car_details[0] ); $counter_mass=$counter_mass+1; ENDIF ENDIF IF ( GetPlayerVar( $uName,"P_Tres" ) != "" ) THEN IF ( ToNum( GetPlayerVar( $uName,"P_Tres" ) ) < ToNum( $car_details[$intake_var] ) ) THEN cmdLFS("/spec " . GetPlayerVar( $uName,"NickName" ) ); PrivMsg ("^1Class " . $classes . ", set intake restriction to " . $car_details[$intake_var] . "% for " . $car_details[0] ); $counter_intake=$counter_intake+1; ENDIF ENDIF ENDIF $mass_var = $mass_var + 2; $intake_var = $intake_var + 2; ENDFOR ENDIF ENDFOR ENDIF ### End ### $plyNum=$plyNum+1; ENDWHILE IF ($counter_intake != 0) THEN globalMsg ("^1ADMIN forced " . $counter_intake . " car(s) from track, for..."); globalMsg ("^1...not having the right intake restriction"); globalMsg (" "); ELSE globalMsg ("^3ADMIN hasn't forced any cars from track..."); globalMsg ("^3...for not having the right intake restriction"); globalMsg (" "); ENDIF IF ($counter_mass != 0) THEN globalMsg ("^1ADMIN forced " . $counter_mass . " car(s) from track, for..."); globalMsg ("^1...not having the right amount of added mass"); ELSE globalMsg ("^3ADMIN hasn't forced any cars from track...."); globalMsg ("^3...for not having the right amount of added mass"); ENDIF EndSub Sub load_hcs_from ( $id,$text ) IF ( $text != "" && IsNum ( $text ) == 1 ) THEN $storage_name = "HCS_".$text."_"; IF ( GetStoredValue( $storage_name . "main_settings" ) != "" ) THEN $copy_hcs_from=$text; ELSE privMsg ("^1WARNING: ^7No settings have been found for Race ID " . $text ); ENDIF ELSE privMsg ("^1WARNING: ^7No value is entered or value isn't a numeric value" ); ENDIF Handicap( $KeyFlags,$id ); EndSub Sub copy_hcs_from ( $KeyFlags,$id ) IF ( $KeyFlags == 1 ) THEN $storage_name = "HCS_".$copy_hcs_from."_"; $main_settings = SplitToArray ( GetStoredValue( $storage_name . "main_settings" ),"*" ); $class_indicator = $main_settings[0]; $use_subclasses = $main_settings[1]; $number_of_classes = $main_settings[2]; $number_of_cars = $main_settings[3]; FOR ( $car_nbr=1;$car_nbr<=$number_of_cars;$car_nbr=$car_nbr+1 ) $car_details = SplitToArray ( GetStoredValue( $storage_name . "car_" . $car_nbr ) , "*" ); SetCurrentPlayerVar( "car_name_" . $car_nbr , $car_details[0] ); $mass_var = 1; $intake_var = 2; FOR( $subclass=1;$subclass<=$number_of_classes;$subclass=$subclass+1 ) SetCurrentPlayerVar( "car_mass_" . $car_nbr . "_" . $subclass , $car_details[$mass_var] ); $mass_var = $mass_var + 2; SetCurrentPlayerVar( "car_intake_" . $car_nbr . "_" . $subclass , $car_details[$intake_var] ); $intake_var = $intake_var + 2; ENDFOR ENDFOR FOR ( $car_nbr=1;$car_nbr<=4;$car_nbr=$car_nbr+1 ) closePrivButton( "handicap_car_name_" . $car_nbr ); closePrivButton( "handicap_input_car_name_" . $car_nbr ); FOR( $subclass=1;$subclass<=5;$subclass=$subclass+1 ) closePrivButton( "handicap_restiction_class_" . $car_nbr . "_" . $subclass ); closePrivButton( "handicap_mass_restiction_class_" . $car_nbr . "_" . $subclass ); closePrivButton( "handicap_intake_restiction_class_" . $car_nbr . "_" . $subclass ); ENDFOR ENDFOR closePrivButton("handicap_number_of_classes"); closePrivButton("handicap_number_of_classes_input"); ENDIF $copy_hcs_from=""; Handicap( $KeyFlags,$id ); EndSub Sub handicap_gui_save( $KeyFlags,$id ) $storage_name = "HCS_".$race_id_handicaps."_"; IF ( $class_indicator != "" && $use_subclasses != "" && $number_of_classes != "" && $number_of_cars != "" ) THEN SetStoredValue( $storage_name . "main_settings", $class_indicator."*".$use_subclasses."*".$number_of_classes."*".$number_of_cars ); ELSE privMsg ("^3WARNING: ^7Not all main settings are filled, therefor main settings can't be saved" ); ENDIF FOR ( $car_nbr=1;$car_nbr<=$number_of_cars;$car_nbr=$car_nbr+1 ) $storage_key = "car_" . $car_nbr; $storage_value = GetCurrentPlayerVar( "car_name_" . $car_nbr ); IF ( $use_subclasses == "yes" ) THEN FOR ( $subclass=1;$subclass<=3;$subclass=$subclass+1 ) IF ( GetCurrentPlayerVar( "car_mass_" . $car_nbr . "_" . $subclass ) == "" ) THEN SetCurrentPlayerVar( "car_mass_" . $car_nbr . "_" . $subclass , 0 ); ENDIF IF ( GetCurrentPlayerVar( "car_intake_" . $car_nbr . "_" . $subclass ) == "" ) THEN SetCurrentPlayerVar( "car_intake_" . $car_nbr . "_" . $subclass , 0 ); ENDIF $storage_value = $storage_value . "*" . GetCurrentPlayerVar( "car_mass_" . $car_nbr . "_" . $subclass ) . "*" . GetCurrentPlayerVar( "car_intake_" . $car_nbr . "_" . $subclass ); ENDFOR ENDIF IF ( $use_subclasses == "no" ) THEN FOR ( $class=1;$class<=$number_of_classes;$class=$class+1 ) IF ( GetCurrentPlayerVar( "car_mass_" . $car_nbr . "_" . $class ) == "" ) THEN SetCurrentPlayerVar( "car_mass_" . $car_nbr . "_" . $class , 0 ); ENDIF IF ( GetCurrentPlayerVar( "car_intake_" . $car_nbr . "_" . $class ) == "" ) THEN SetCurrentPlayerVar( "car_intake_" . $car_nbr . "_" . $class , 0 ); ENDIF $storage_value = $storage_value . "*" . GetCurrentPlayerVar( "car_mass_" . $car_nbr . "_" . $class ) . "*" . GetCurrentPlayerVar( "car_intake_" . $car_nbr . "_" . $class ); ENDFOR ENDIF SetStoredValue( $storage_name . $storage_key, $storage_value ); ENDFOR privMsg ("^7Handicap settings saved" ); EndSub Sub handicap_gui_delete ( $KeyFlags,$id ) ### Check wether there are handicap settings that needs to be deleted and if so, delete them ### $storage_name_hcs = "HCS_" . $race_id_handicaps . "_"; IF ( GetStoredValue( $storage_name_hcs . "main_settings" ) != "" ) THEN $main_settings = SplitToArray ( GetStoredValue( $storage_name_hcs . "main_settings" ),"*" ); $number_of_cars = $main_settings[3]; DeleteStoredValue( $storage_name_hcs . "main_settings" ); FOR ( $car_nbr=1;$car_nbr<=$number_of_cars;$car_nbr=$car_nbr+1 ) DeleteStoredValue( $storage_name_hcs . "car_" . $car_nbr ); ENDFOR PrivMsg ( "^7INFO: Handicap settings for Race ID " . $race_id_handicaps . " have been deleted" ); handicap_gui_close( $KeyFlags,$id ); ENDIF ### End ### EndSub Sub handicap_gui_close( $KeyFlags,$id ) closePrivButton( "handicap_gui_bg" ); closePrivButton( "handicap_title" ); closePrivButton( "handicap_server_name" ); closePrivButton( "handicap_class_indicator" ); closePrivButton( "handicap_class_indicator_input_1" ); closePrivButton( "handicap_class_indicator_input_2" ); closePrivButton( "handicap_class_indicator_input_3" ); closePrivButton( "handicap_use_subclasses" ); closePrivButton( "handicap_use_subclasses_no" ); closePrivButton( "handicap_use_subclasses_yes" ); closePrivButton( "handicap_number_of_classes" ); closePrivButton( "handicap_number_of_classes_input" ); closePrivButton( "handicap_number_of_cars" ); closePrivButton( "handicap_race_id" ); closePrivButton( "handicap_race_id_input" ); closePrivButton( "cars_used_title" ); closePrivButton( "cars_used_value" ); closePrivButton( "copy_hcs_from" ); closePrivButton( "handicap_mass_title" ); closePrivButton( "handicap_mass_zero" ); closePrivButton( "handicap_intake_title" ); closePrivButton( "handicap_intake_zero" ); closePrivButton( "handicap_number_of_cars_input" ); FOR ( $car_nbr=1;$car_nbr<=$number_of_cars;$car_nbr=$car_nbr+1 ) SetCurrentPlayerVar( "car_name_" . $car_nbr , "" ); closePrivButton( "handicap_car_name_" . $car_nbr ); closePrivButton( "handicap_input_car_name_" . $car_nbr ); FOR( $subclass=1;$subclass<=5;$subclass=$subclass+1 ) SetCurrentPlayerVar( "car_mass_" . $car_nbr . "_" . $subclass , "" ); SetCurrentPlayerVar( "car_intake_" . $car_nbr . "_" . $subclass , "" ); closePrivButton( "handicap_restiction_class_" . $car_nbr . "_" . $subclass ); closePrivButton( "handicap_mass_restiction_class_" . $car_nbr . "_" . $subclass ); closePrivButton( "handicap_intake_restiction_class_" . $car_nbr . "_" . $subclass ); ENDFOR ENDFOR closePrivButton ( "handicap_gui_save" ); closePrivButton ( "handicap_gui_clear" ); closePrivButton ( "handicap_gui_delete" ); closePrivButton ( "handicap_gui_force" ); closePrivButton ( "handicap_gui_close" ); IF ( GetCurrentPlayerVar( "came_from_race" ) != "" ) THEN SetCurrentPlayerVar( "came_from_race" , "" ); Set_Schedule ( $KeyFlags ); ENDIF EndSub