############################################################################# # Pace Car by Krayy ############################################################################# # The Pace Car system is designed to track players under Pace car conditions # to ensure that they do not pass each other. a Drive Through penalty will # be applied if any racer is out of position when the race restarts. # # In order to use this addon, you MUST have defined an AI called "PACECAR". ############################################################################# # Ver 1.0.1 19/01/10 Initial release ############################################################################# CatchEvent OnLapperStart() GlobalVar $CountLoop; $CountLoop = 0; EndCatchEvent CatchEvent OnNewPlayerJoin( $userName ) # Player event #globalMsg ("New player: " . $userName); 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 "!red": IF( $argv != "" ) THEN $temp = GetListOfPlayers( ); FOREACH( $maVar IN $temp ) $NickName = GetPlayerVar($maVar["value"], "NickName"); $NickStrip = StripLFSColor( ToLower($NickName) ); privMsg("red for: " . $NickStrip); $IdxOfTag = indexOf( $NickStrip , "[r]"); IF( $IdxOfTag != -1 ) THEN privMsg ($maVar["value"],"^1Red: ^7".$argv); ENDIF ENDFOREACH ENDIF BREAK; CASE "!cmds": dumpVar($LapperCommands); dumpVar($AdminCommands); dumpVar( $OnIdleTimeout1 ); globalmsg ("TimeIdleWarning = " . $TimeIdleWarning); BREAK; CASE "!t5": # openPrivButton( "drewpitleave02",50,12,100,10,10,10,ISB_DARK,"1%at%2%at%3%at%4%at%5%at%6%at%7%at%8%at%9%at%10" ); # openGlobalButton ("test5",60,95,80,10,5,4,16,"^7t5 will run in (%cpt%) second(s)", DoTest5); $CountLoop = 0; HostDelayedCommand ( "GoCL", 10, DoCL ); BREAK; CASE "!t1": privMsg ("ShortTrackName = " . GetLapperVar("ShortTrackName")); # DoTest1( ); BREAK; CASE "!t2": DoTest2( ); BREAK; CASE "!t3": $myCarList = SplitToArray($LFSCarList,","); DumpVar($myCarList); $i = 0; $num = arrayCount( $myCarList ); WHILE ($i < $num) privMsg ( $i . " is " . $myCarList[$i]); $i = $i + 1; ENDWHILE DoTest3( ); BREAK; CASE "!t7": DoTest7( ); BREAK; CASE "!t8": $currPly = GetPlayerInfo(); dumpvar ($currPly); # DoTest8( ); BREAK; CASE "!t9": # privMsg ("Ontrack = " . GetCurrentPlayerVar( "OnTrack" ) ); # privMsg ("FinishedPos = " . GetCurrentPlayerVar( "FinishedPos" ) ); $currPly = GetPlayerInfo2(); dumpvar ($currPly); #RequestREO( ); # privMsg ("Race order requested"); BREAK; CASE "!t4": # $CurrPly = GetPlayerInfo( $userName ); # dumpVar ($CurrPly); privMsg("RacePercentComplete: " . getLapperVar( "racepercentcomplete")); privMsg("RaceLapsLeft: " . getLapperVar( "racelapsleft")); privMsg("Mustpit: " . getLapperVar( "MustPit")); # $MustPitMsg = "^1ALERT: ^8Race ^175%^8 complete and you have yet to pit"; # openPrivButton( "mustpitalert",40,28,120,12,12,7,0,$MustPitMsg); #DoTest4( ); BREAK; CASE "!t6": DoTest6( ); BREAK; CASE "!cd": $rip = 1; start_countdown( ); BREAK; CASE "!raceid": globalMsg ("RaceID: " . getLapperVar( "RaceId" )); BREAK; ENDSWITCH EndCatchEvent Sub DoTest1( ) $Racers[0] = "4aged,5500"; $Racers[1] = "krayy,5350"; $Racers[2] = "lifesteala,5259"; $Racers[3] = "slyguy,5100"; dumpVar( $Racers ); privMsg( "Racers count is " . arrayCount( $Racers ) ); $i=0; $num = arrayCount( $Racers ); WHILE ($i < $num) $iNum = ToNum(Split($Racers[$i],",",1)); $iStr = ToString($Racers[$i]); IF ($i == 0) THEN $i = $i + 1; ELSE $jNum = ToNum(Split($Racers[$i-1],",",1)); $jStr = ToString($Racers[$i-1]); IF ( $iNum < $jNum ) THEN $Racers[$i] = ToString($jStr); $Racers[$i-1] = ToString($iStr); privMsg( "Racers[" . $i . "] = " . $Racers[$i] ); $i = $i - 1; ELSE $i = $i + 1; ENDIF ENDIF ENDWHILE dumpVar( $Racers ); EndSub Sub DoTest2( ) # $toto[2] = "Deux,Deux"; # $toto[3] = "Trois,Un"; # $toto[6] = "Quatre,zero"; # dumpVar( $toto ); $Racers[0,0,1] = "4aged,5500"; $Racers[1,0,1] = "krayy,5350"; $Racers[2,0,1] = "lifesteala,5259"; $Racers[2,1,1] = "lifesteala,6259"; $Racers[3,0,1] = "slyguy,5100"; # dumpVar( $Racers ); privMsg( "Racers count is " . arrayCount( $Racers ) ); # WriteLine( "Racers[3,0] = " . $Racers[3,0] ); # WriteLine( "Racers[3,1] = " . $Racers[3,1] ); $v1 = $Racers[2]; # dumpvar($v1); $v2 = $Racers[2,1]; # dumpvar($v2); $LOF = getListOfPlayers(); # dumpVar( $LOF ); $LOFS = getListOfPlayers(); # dumpVar( $LOFS ); /* dumpVar( $Times ); unset $Sorted; $Sorted[0] = 0; $i=0; $num = arrayCount( $Times ); WHILE ($i < $num) $iTmp = ToNum($Times[$i]); IF ($i == 0) THEN $Times[$i] = ToString($iTmp); $i = $i + 1; ELSE # $iTmp = Split($Racers[$i],",",1); # $jTmp = Split($Racers[$i - 1],",",1); # WriteLine( "iTmp: " . $iTmp . ", jTmp: " . $jTmp ); # IF ( ToNum($iTmp) < ToNum($jTmp )) $jTmp = ToNum($Times[$i-1]); IF ( $iTmp < $jTmp ) THEN $Times[$i] = ToString($jTmp); $Times[$i-1] = ToString($iTmp); WriteLine( "Times[" . $i . "] = " . $Times[$i] ); $i = $i - 1; ELSE $i = $i + 1; ENDIF ENDIF ENDWHILE dumpVar( $Times ); # FOR ($i=0;$i