The online racing simulator
Overspeed on Rolling Lap
(4 posts, started )
Overspeed on Rolling Lap
Hello,

ive got a Script with the Help of Bass-Driver Smile and it workes fine, until i have noticed that who ever is going to speed over 30 MPH, i am getting spectated.

basically it should spectate the Player that overspeeds.


Heres the Whole ScriptSmile
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 "!run":
IF ( UserIsAdmin( $userName ) == 1 )
THEN
Safetycar_gui( $KeyFlags );

ELSE
privMsg(langEngine( "%{main_notadmin}%" ));
ENDIF
BREAK;
CASE "!race":
IF ( UserIsAdmin( $userName ) == 1 )
THEN
SetCurrentPlayerVar("StartLoop",0);
Loop($KeyFlags);
cmdLFS ("/msg ^2GREEN GREEN GREEN!!!");
cmdLFS ("/msg ^2GREEN GREEN GREEN!!!");
cmdLFS ("/msg ^2GREEN GREEN GREEN!!!");
cmdLFS ("/msg ^2GREEN GREEN GREEN!!!");
ELSE
privMsg(langEngine( "%{main_notadmin}%" ));
ENDIF
BREAK;
ENDSWITCH
EndCatchEvent

Sub Safetycar_gui( $KeyFlags )
IF ($safetycar_status == "lu")
THEN
openPrivButton( "sc_lu",70,1,10,5,5,-1,16,"^1LINE UP",SC_LU);
ELSE
openPrivButton( "sc_lu",70,1,10,5,5,-1,16,"^7LINE UP",SC_LU);
ENDIF

IF ($safetycar_status == "ht")
THEN
openPrivButton( "sc_ht",80,1,10,5,5,-1,16,"^1HEAT",SC_HT);
ELSE
openPrivButton( "sc_ht",80,1,10,5,5,-1,16,"^7HEAT",SC_HT);
ENDIF

IF ($safetycar_status == "fl")
THEN
openPrivButton( "sc_fl",90,1,10,5,5,-1,16,"^1FINAL",SC_FL);
ELSE
openPrivButton( "sc_fl",90,1,10,5,5,-1,16,"^7FINAL",SC_FL);
ENDIF

openPrivButton( "close_sc",100,1,10,5,5,-1,16,"^7Close",Close_SC);
EndSub

Sub SC_LU( $KeyFlags,$id )
$safetycar_status="lu";
cmdLFS ("/zero_all");
cmdLFS ("/rcm ^7PLEASE LINE UP FOLLOWING YOUR GRADES");
cmdLFS ("/rcm_all");
privMsg(langEngine( "^7 Line Up has been started." ));
Safetycar_gui( $KeyFlags );
EndSub

Sub SC_HT( $KeyFlags,$id )
$safetycar_status="ht";
SetCurrentPlayerVar("StartLoop",1);
Loop($KeyFlags);
cmdLFS ("/zero_all");
cmdLFS ("/laps=10");
cmdLFS ("/rcm ^7FRONT ROW ROLL AT 25 MPH PLEASE");
cmdLFS ("/rcm_all");
privMsg(langEngine( "^7 Heat has been setup and started." ));
Safetycar_gui( $KeyFlags );
EndSub

Sub SC_FL( $KeyFlags,$id )
$safetycar_status="fl";
cmdLFS ("/zero_all");
cmdLFS ("/laps=15");
cmdLFS ("/rcm ^7FRONT ROW ROLL AT 25 MPH PLEASE");
cmdLFS ("/rcm_all");
privMsg(langEngine( "^7 Final has been setup and started." ));
Safetycar_gui( $KeyFlags );
EndSub

Sub Close_SC( $KeyFlags,$id )
closePrivButton( "sc_ht&sc_fl&sc_lu&close_sc");
EndSub

Sub Loop($KeyFlags)
IF (GetCurrentPlayerVar("StartLoop") == 1) THEN
$Dr = getListOfPlayers("U"); #get List of drivers
FOREACH( $Var IN $Dr )
$Speed = GetPlayerVar($Var["value"],"InstantSpeed");
IF ($Speed > 52) THEN #Check speed in km/h
cmdLFS("/spec " . GetCurrentPlayerVar("NickName") );
ENDIF
ENDFOREACH
PrivDelayedCommand( 1, Loop ); # 1 Second Loop
ELSE
removeprivdelayedcommand(Loop); #Stop loop
ENDIF
EndSub

i hope anyone can figure it out, thanksSmile
cmdLFS("/spec " . GetCurrentPlayerVar("NickName") );

so basically here something went wrong
Must be cmdLFS("/spec " . $Var["value"] );

$Var["value"] = Current Username in the current loop

Because the FOREACH loop checks the Speed ForEach player.
Once the loop has detect overspeed, you have to Spec that player
Oh ahhhh
My fault sorrySmile
Thanks again !

Overspeed on Rolling Lap
(4 posts, started )
FGED GREDG RDFGDR GSFDG