The online racing simulator
#1 - SEV7N
"!" functions in a button (!help)
Here I made 2 windows, one is !da and the other is !info (both have working "close" buttons, and a non working "NEXT" button).

I am trying to put the !da command in the "next button" so when someone presses "NEXT" button in !info it opens the window in !da








<?php 
CASE "!da":
                   
openPrivButton"top",3,49,100,75,6,-1,16,"" );
                                     
                                     
openPrivButton"leftbx",3,49,25,75,6,-1,32,"");
                                     
openPrivButton"Header",28,50,74,5,6,-1,32,"");
                                     
openPrivButton"da",15,50,74,5,6,-1,0,"^2DRIFT^3AUSTRALIA");
                                     
openPrivButton"Score",32,50,74,5,6,-1,0,"^7Scoring");
                                     
openPrivButton"light",42,50,74,5,6,-1,12,"^2•");
                                     
                                     
                                     
openPrivButton"lappa",3,59,25,5,5,-1,16,"^7Lapper");
                                     
openPrivButton"box",28,59,74,5,6,-1,16,"");
                                     
openPrivButton"infos",3,59,125,5,5,-1,0,"^7Lapper ^7Will ^7Give ^7You ^7Point's ^7For ^7Drifting ^7According ^7To ^7Angle:");

                                      
openPrivButton"Angle",31,71,15,5,5,-1,0,"^7Min ^7Angle:");
                                      
openPrivButton"Anglenum",41,71,15,5,5,-1,0,"^715°");
                                      
openPrivButton"speed",31,79,15,5,5,-1,0,"^7Min ^7Speed:");
                                      
openPrivButton"speednum",43,79,15,5,5,-1,0,"^710KMP");
                                      
openPrivButton"Clips",3,89,25,5,5,-1,16,"^7Clip ^7Point's");
                                      
openPrivButton"infos2",28,89,74,5,5,-1,16,"^7LFS ^7Gives ^7Points ^7According ^7To ^7The ^7Amount ^7Of ^7Clip's ^7Hit.:");
                                      
openPrivButton"clipp",32,98,20,5,5,-1,0,"^7One ^7Pole/Cone ^7=");
                                      
openPrivButton"clippn",48,98,15,5,5,-1,0,"^750pts");
                                      
openPrivButton"next",31,117,15,5,5,-1,32,"^7NEXT");
openPrivButton"pstclose",60,110,20,10,5,-1,32langEngine("%{main2_close}%"),ClosePstInfo );
                                 BREAK;
                                        ENDIF
                                        
                                
                              CASE
"!info":
                                      
openPrivButton"top",3,49,100,75,6,-1,16,"" );
                                      
openPrivButton"infos",3,51,25,5,5,-1,0,"^7HELP");
                                      
openPrivButton"lappa",3,59,25,5,5,-1,16,"");
                                      
openPrivButton"leftbx",3,49,25,75,6,-1,32,"");
                                      
openPrivButton"Clips",3,89,25,5,5,-1,0,"");
                                      
openPrivButton"Anglenum",3,59,25,5,5,-1,0,"^7Custom ^7Commands ^7(!da)");
                                      
openPrivButton"Header",28,50,74,5,6,-1,32,"");
                                      
openPrivButton"Score",32,50,74,5,6,-1,0,"^7Info/Help");
                                      
openPrivButton"light",45,50,74,5,6,-1,12,"^2•");
                                      
openPrivButton"da",15,50,74,5,6,-1,0,"^2DRIFT^3AUSTRALIA");

openPrivButton"pstclose",60,110,20,10,5,-1,32langEngine("%{main2_close}%"),ClosePstInfo );
BREAK
ENDIF
?>

And the part that makes the buttons close when close is pressed.

<?php 
Sub ClosePstInfo
$KeyFlags,$id )
    
closePrivButton

"pstclose&Back&Angle&top&top2&leftbx2&Header2&leftbx&Header&da&Score&lappa&light&light2&box&infos&Angle&Anglenum&speed&speednum&Clips&infos2&clipp&clippn&PSNickNa

me&PSDistance&PSFuel&PSLaps&PSWins&PSSecond&PSThird&PSFinished&PSQuals&PSPole&next&prev"
);
Closeclosescore$KeyFlags,$id )
    
closePrivButton("closescore");
EndSub
?>


I was thinking a Do function but I am unsure how to code properly and all attempts failed.
Help would be much appreciated, Cheers!
Quote from SEV7N :... a non working "NEXT" button....

You need to add a sub-routine to the end of the line, e.g.

<?php 
openPrivButton
"next",31,117,15,5,5,-1,32,"^7NEXT",Sub_Next);
?>


<?php 
Sub Sub_Next
()
# Close and Open Button(s) etc coding here
EndSub
?>


For your "DO" query, do you mean a CASE command such as !do?

If so code same way as your !da - that is;
specify the CASE command
make button(s) with relevant text
if required, add sub-routine to clickable button that will take you to a sub-routine
make up a sub-routine after the BREAK ending (this sub-routine probably needs to close the button you clicked to get to the sub-routine).

Query: Do you need the ENDIF at the end of you CASE commands?
#3 - SEV7N
Quote from sinanju :You need to add a sub-routine to the end of the line, e.g.

<?php 
openPrivButton
"next",31,117,15,5,5,-1,32,"^7NEXT",Sub_Next);
?>


<?php 
Sub Sub_Next
()
# Close and Open Button(s) etc coding here
EndSub
?>


For your "DO" query, do you mean a CASE command such as !do?

If so code same way as your !da - that is;
specify the CASE command
make button(s) with relevant text
if required, add sub-routine to clickable button that will take you to a sub-routine
make up a sub-routine after the BREAK ending (this sub-routine probably needs to close the button you clicked to get to the sub-routine).

Query: Do you need the ENDIF at the end of you CASE commands?

OK cheers for the info,

If i wanted to make a new include( "./DAinfo.lpr");
how would I get it started?
(My !da code is in the lapper.LPR file it's self. I want it in a neat and tidy DAinfo.lpr file?

I have the .LPR file named DAinfo and I have included it in the addonsused.LPR file,

Heres how I guessed heheh. (I know next to nothing about this)


<?php 
SWITCH

CASE 
"!da":
openPrivButton"top",3,49,100,75,6,-1,16,"" );
        
ENDSWITCH
?>

Thanks Again!
Quote from SEV7N :


<?php 
SWITCH
CASE 
"!da":
openPrivButton"top",3,49,100,75,6,-1,16,"" );     
ENDSWITCH
?>


This bit of code will only open a large blank button that doesn't do anything - which, of course, might be your intention?

If you want things to be in different .lpr files, then you need to have an Event that triggers your code. AND because you want to have a command in a separate .lpr file, you will have to start off with "CatchEvent On".

For instance, any CASE commands, like your !do would have to be like the following;


<?php 
CatchEvent OnMSO
$userName$text # Player event
    
$idxOfFirstSpace indexOf$text" ");
    IF( 
$idxOfFirstSpace == -)
    
THEN
      $command 
$text;
      
$argv "";
    ELSE
      
$command subStr$text,0,$idxOfFirstSpace );
      
$argv trimsubStr$text,$idxOfFirstSpace ) );
    ENDIF

    SWITCH ( 
$command )
        CASE 
"!to
            # instructions (sub-routine) for lapper to follow when command typed
        BREAK;     
    ENDSWITCH
EndCatchEvent
?>


#5 - SEV7N
Quote from sinanju :This bit of code will only open a large blank button that doesn't do anything - which, of course, might be your intention?

If you want things to be in different .lpr files, then you need to have an Event that triggers your code. AND because you want to have a command in a separate .lpr file, you will have to start off with "CatchEvent On".

For instance, any CASE commands, like your !do would have to be like the following;


<?php 
CatchEvent OnMSO
$userName$text # Player event
    
$idxOfFirstSpace indexOf$text" ");
    IF( 
$idxOfFirstSpace == -)
    
THEN
      $command 
$text;
      
$argv "";
    ELSE
      
$command subStr$text,0,$idxOfFirstSpace );
      
$argv trimsubStr$text,$idxOfFirstSpace ) );
    ENDIF

    SWITCH ( 
$command )
        CASE 
"!to
            # instructions (sub-routine) for lapper to follow when command typed
        BREAK;     
    ENDSWITCH
EndCatchEvent
?>



Thank's your a Legend in ya own Lunchbox!!
#6 - SEV7N
Hi again, I have made this, but everytime i try the Sub part, it never closes when I click close? I think I need to make a new event but I am un-sure how. Or the

<?php 
Sub Close_all
()
?>

needs something in the ()?


<?php 
CatchEvent OnMSO
$userName$text # Player event
    
$idxOfFirstSpace indexOf$text" ");
    IF( 
$idxOfFirstSpace == -)
    
THEN
      $command 
$text;
      
$argv "";
    ELSE
      
$command subStr$text,0,$idxOfFirstSpace );
      
$argv trimsubStr$text,$idxOfFirstSpace ) );
    ENDIF

    SWITCH ( 
$command )


                                                     
##DAscoring Box##
             
CASE "!da"
                                     
openPrivButton"top",3,49,100,75,6,-1,16,"" ); 
                                     
openPrivButton"leftbx",3,49,25,75,6,-1,32,""); 
                                     
openPrivButton"Header",28,50,74,5,6,-1,32,""); 
                                     
openPrivButton"da",15,50,74,5,6,-1,0,"^2DRIFT^3AUSTRALIA"); 
                                     
openPrivButton"Score",32,50,74,5,6,-1,0,"^7Scoring"); 
                                     
openPrivButton"light",42,50,74,5,6,-1,12,"^2•"); 
                                     
openPrivButton"lappa",3,59,25,5,5,-1,16,"^7Lapper"); 
                                     
openPrivButton"box",28,59,74,5,6,-1,16,""); 
                                     
openPrivButton"infos",3,59,125,5,5,-1,0,"^7Lapper ^7Will ^7Give ^7You ^7Point's ^7For ^7Drifting ^7According ^7To ^7Angle:"); 
                                     
openPrivButton"Angle",31,71,15,5,5,-1,0,"^7Min ^7Angle:"); 
                                     
openPrivButton"Anglenum",41,71,15,5,5,-1,0,"^715°"); 
                                     
openPrivButton"speed",31,79,15,5,5,-1,0,"^7Min ^7Speed:"); 
                                     
openPrivButton"speednum",43,79,15,5,5,-1,0,"^710KMP"); 
                                     
openPrivButton"Clips",3,89,25,5,5,-1,16,"^7Clip ^7Point's"); 
                                     
openPrivButton"infos2",28,89,74,5,5,-1,16,"^7LFS ^7Gives ^7Points ^7According ^7To ^7The ^7Amount ^7Of ^7Clip's ^7Hit.:"); 
                                     
openPrivButton"clipp",32,98,20,5,5,-1,0,"^7One ^7Pole/Cone ^7="); 
                                     
openPrivButton"clippn",48,98,15,5,5,-1,0,"^750pts"); 
                                     
openPrivButton"daptscls",51,117,15,5,5,-1,32,"^7CLOSE",Close_all);
                                     
openPrivButton"next",31,117,15,5,5,-1,32,"^7NEXT",Sub_Next);
                                             

              BREAK;                                        
##DAinfo Box##
             
CASE "!info":
                                     
openPrivButton"topinfo",3,49,100,75,6,-1,16,"" );
                                     
openPrivButton"leftbxinfo",3,49,25,75,6,-1,32,""); 
                                     
openPrivButton"Headerinfo",28,50,74,5,6,-1,32,"");
                                               
                                              
             BREAK;      
    ENDSWITCH 
EndCatchEvent###If I move this to the bottom nothing works

    ######CLOSE-ALL Button won't close anything?########

Sub Close_all() 
(
"top&leftbx");
EndSub
?>


2 obvious things;

Don't do your code within the CASE command. Instead give lapper an instruction to go to a sub-routine.

If you want to close buttons, you have to use one of the following;
closePrivButton (for closing a Private button)
closeGlobalButton (for closing a Global button)
closeButtonRegex (for closing buttons for specific players).

An example of how you should have coded;


<?php 
CatchEvent OnMSO
$userName$text # Player event
    
$idxOfFirstSpace indexOf$text" ");
    IF( 
$idxOfFirstSpace == -)
    
THEN
      $command 
$text;
      
$argv "";
    ELSE
      
$command subStr$text,0,$idxOfFirstSpace );
      
$argv trimsubStr$text,$idxOfFirstSpace ) );
    ENDIF

    SWITCH ( 
$command)
             CASE 
"!da"
    
GoToScoringBox(0,0);    ## DAscoring Box ##    (The 0,0 in the brackets refers to the $KeyFlags,$id in the brackets of the sub's first line - could just as easily be 0,0 = $KeyFlags,$userName depending on what the sub-routine trying to do)  
              
BREAK;
    ENDSWITCH 
EndCatchEvent


Sub GoToScoringBox
$KeyFlags,$id )
    
openPrivButton"da_top",3,49,100,75,6,-1,16,"" ); 
    
openPrivButton"da_leftbx",3,49,25,75,6,-1,32,""); 
    
openPrivButton"da_header",28,50,74,5,6,-1,32,""); 
    
openPrivButton"da_da",15,50,74,5,6,-1,0,"^2DRIFT^3AUSTRALIA"); 
    
openPrivButton"da_score",32,50,74,5,6,-1,0,"^7Scoring"); 
    
openPrivButton"da_light",42,50,74,5,6,-1,12,"^2•"); 
    
openPrivButton"da_lappa",3,59,25,5,5,-1,16,"^7Lapper"); 
    
openPrivButton"da_box",28,59,74,5,6,-1,16,""); 
    
openPrivButton"da_infos",3,59,125,5,5,-1,0,"^7Lapper Will Give You Point's For Drifting According To Angle:");     #    (I've removed all the ^7's as lapper will always use last colour specified until you specify new colour)
    
openPrivButton"da_angle",31,71,15,5,5,-1,0,"^7Min Angle:"); 
    
openPrivButton"da_anglenum",41,71,15,5,5,-1,0,"^715°"); 
    
openPrivButton"da_speed",31,79,15,5,5,-1,0,"^7Min Speed:"); 
    
openPrivButton"da_speednum",43,79,15,5,5,-1,0,"^710KMP"); 
    
openPrivButton"da_clips",3,89,25,5,5,-1,16,"^7Clip Point's"); 
    
openPrivButton"da_infos2",28,89,74,5,5,-1,16,"^7LFS Gives Points According To The Amount Of Clip's Hit.:"); 
    
openPrivButton"da_clipp",32,98,20,5,5,-1,0,"^7One Pole/Cone ="); 
    
openPrivButton"da_clippn",48,98,15,5,5,-1,0,"^750pts"); 
    
openPrivButton"da_daptscls",51,117,15,5,5,-1,32,"^7CLOSE",SR_CloseAll);    # Clicking this button will take you to the sub SR_CloseAll (I've used SR as a descriptive so you know it's a Sub-Routine)
    
openPrivButton"da_next",31,117,15,5,5,-1,32,"^7NEXT",SR_Next);          
EndSub

      
Sub SR_CloseAll
($KeyFlags,$id 
    
closeButtonRegex (GetCurrentPlayerVar("UserName"), "da_*");    # this will close ALL buttons that start with "da_"
EndSub

#    Alternative method of closing buttons
#####################################

Sub SR_CloseAll($KeyFlags,$id )
    
closePrivButton"da_top&da_leftbx&da_header&da_da&da_score&da_light&da_lappa");    # button names separated with an ampersand (&) symbol
    
closePrivButton"da_box&da_box&da_infos&da_angle");    # you can have all button names in one line, or you can have on multiple lines (multiple lines can stop word wrapping making it easier to understand your code if you need to go back to correct)
EndSub
?>


None of the above code has been checked; it's only to show what you need to do.
#8 - SEV7N
Thanks for that, worked "out the box"

Can you help with this please? I tried to implement my knowledge of buttons, but its not as easy as I thought.

How do I show different info on different zones?




I added on to the lapper file, can I make my own add-on
for the addonsincluded.lpr
Thanks 1000000


<?php 
Sub DisplaySpeed
$userName )
    
PrivMsglangEngine"%{main_clip}%" ToPlayerUnitGetCurrentPlayerVar"InstantSpeed" ) ),GetCurrentPlayerVar("UnitSpeed") ) );
EndSub

Sub DisplayLight
$userName )
    
PrivMsglangEngine"%{main_light}%" ToPlayerUnitGetCurrentPlayerVar"InstantSpeed" ) ),GetCurrentPlayerVar("UnitSpeed") ) );
EndSub ##THE LIGHT"S SUB?###



    
RegisterZoneAction"AU1" 43,-774DisplaySpeed,ExitDisplaySpeed);
    
RegisterZoneAction"AU1" 28,-862DisplaySpeed,ExitDisplaySpeed);
    
RegisterZoneAction"AU1" 28,-871DisplayLight); ##LIGHT calling SUB?##
?>

I have in the ENG part,

<?php 
main_light2 
"^1test= {0}
?>


Thanks man.
This thread is closed

FGED GREDG RDFGDR GSFDG