The online racing simulator
Switch Case arguments
If i use the code below i can only insert argument string if 5 letters. I think it's because "Cadet" has 5 letters. How can i change this?

CASE "!promote":
IF ( UserIsAdmin( $userName ) == 1 )
THEN
IF ( $argv != "" )
THEN
$idxSpace = indexOf( $argv, " ");
IF ( $idxSpace != -1 )
THEN
$option = subStr( $argv,0,$idxSpace );
$argv = trim( subStr( $argv,$idxSpace ) );
SWITCH ( ToLower($option) )

CASE "cadet":
IF ( $argv != "" )
THEN
$speler = subStr( $argv,0,$idxSpace );
$argv = trim( subStr( $argv,$idxSpace ) );
privMsg( "test" );
IF ( UserInGroup( "Police",$speler ) == 1 )
THEN
privMsg( "^7User is already A Officer!!!");
ELSE
MoveUserToGroup( "Police",$speler );
UserGroupToFile( "Police", $Dir["Police"] );
GlobalMsg( langEngine( "%{cruise_cop_new}%",$speler) );
ENDIF
ELSE
privMsg( "Select player" );
ENDIF
BREAK;
ENDSWITCH
ENDIF
ELSE
privMsg ( "Specify Cadet, Officer or OC" );
ENDIF
BREAK;

This is a question about Lapper and should have gone into the Lapper forum section. Maybe a moderator can direct this thread to the correct forum?
I will look into your question and will come up with an answer.
I have looked into your script and it turned out that an ENDIF was missing.
There was also too much complicated code to make the rank-cases work, so I have re-written that:


<?php 
SWITCH( $command )

    CASE 
"!promote":
    IF ( 
UserIsAdmin$userName ) == )
    
THEN
        
IF ( $argv != "" 
        
THEN
        $idxSpace 
indexOf$argv" ");
        IF ( 
$idxSpace != -
        
THEN
            $pl_name 
subStr$argv,0,$idxSpace ); #user- or nickname
            
$rank trimsubStr$argv,$idxSpace ) ); #rank

            
IF ( $rank != "")
            
THEN
                
SWITCH ( ToLower($rank) )    

                CASE 
"cadet":
                    
privMsg"test" );
                    IF ( 
UserInGroup"Police",$pl_name ) == )
                    
THEN
                        privMsg
"^7User is already A Officer!!!");
                    ELSE
                        
MoveUserToGroup"Police",$pl_name );
                        
UserGroupToFile"Police"$Dir["Police"] );
                        
GlobalMsglangEngine"%{cruise_cop_new}%",$pl_name) );
                    ENDIF
                BREAK;

                CASE 
"officer":
                    
privMsg"test Officer");
                BREAK;

                CASE 
"oc":
                    
privMsg"test OC");
                BREAK;
                ENDSWITCH
            ELSE
            
privMsg"Select player" );
            ENDIF
        ENDIF
        ELSE
        
privMsg "Specify Cadet, Officer or OC" );
        ENDIF
    ENDIF 
#THIS WAS MISSING
    
BREAK;
ENDSWITCH
?>


FGED GREDG RDFGDR GSFDG