When writing code for Lapper, you basicly have two options to put your code in:
1) Write it directly in 'LFSLapper.lpr' which can be found in folder 'bin\default'
2) Write it in a seperate file, save that file in the 'bin\default\includes' folder and mention the newly written file in 'bin\default\includes\addonsused.lpr'
The second option is the best one, as it keeps the default script clean and by adjusting file 'addonsused.lpr' you can easily turn on/off scripts you have written.
With buttons there are two options as well:
openPrivButton - this will open a button only to be seen by the player that has triggered the event
openGlobalButton - this will be seen by all players and is triggered by the first player that triggered the event.
PrivButton is mainly used to display information that is player specific, while GlobalButton is used for general information
The syntax for both buttons is the same:
1 - Unique id for this button
2 - Left coordinate for this button ( 0-200 ) , $origL = (value between 0-200); - when this value is used, every next value can be made relative to this one (example: $origL + 5; )
3 - Top coordinate for this button ( 0-200 ) , $origT = (value between 0-200); - when this value is used, every next value can be made relative to this one (example: $origT + 5; )
4 - Width of the button ( 0-200 )
5 - Heigth of the button ( 0-200 )
6 - Space between line in multiline button
7 - Duration in seconds for the button to be displayed (use -1 if you don't want an automatic close)
8 - Format of the button, look at insim.txt for values
9 - Button caption, for multiline, separate each line with &
10 - Option name of the backcalled sub
When formatting a button, these are the codes you can use:
0 - transparent button
16 - light button
32 - dark button
64 - align text to left
128 - align text to right
If you want to make a light colored button with text aligned to the left, combine the codes to one new code, for example 16+64 = 80
When a button is clicked a next routine can be started and it's possible to know which mousebutton is used to click the button with.
This can be read using the $KeyFlags value in the sub-routine and can return the following values:
// CFlags byte : click flags
1 // left click
2 // right click
4 // ctrl + click
8 // shift + click
If left click and right click, you receive 2 + 1 = 3
That are the basics of creating a button, which hopefully make some sense.
Now back to your question about displaying a button when a zone is reached.
Let's say we register a zone on the basic Blackwood track (BL1):
RegisterZoneAction( "MyZone", "BL1" , 0 , SA_Test_1, "" );
This means that as soon as a player enters zone 0, the sub-routine 'SA_Test_1' will be executed.
As you can see, there's also "" in the RegisterZoneAction, which can be used to define a sub-routine to be executed when a player leaves zone 0.
The sub-routine could look like this:
<?php
Sub SA_Test_1 ( $userName, $id )
openPrivButton( "test_button",25,28,150,10,5,-1,0,"This is a test", "" );
EndSub
?>
As you can see, a PrivButton is opened and has been given the name 'test_button'.
This name is important and should be unique, because you need that name to close the button at some point and if multiple buttons have the same name, they will all close when using that name.
Value 25 means that the button is starting from position 25 seen from the left side of the screen. (the screen for buttons is a 200 by 200 square, where the top left corner has coordinate 0,0)
Value 28 means that the button is starting from position 28 seen from the top of the screen.
Value 150 means that the button has a width of 150 (since it is starting 28 from the left, the end of the button is at position 178, which is within the range of 200.
Value 10 means that the button has a height of 10 (if you want to display text on the button, then it will take a height of 5, to display one line of text, 2 lines means a height of 10 is needed, ect. etc.)
Value 5 has to do with space between a multiline button, but in most cases 5 will do.
Value -1 means that the button won't close automaticly and will be waiting for the user to click on it and then execute the sub-routine.
Value 0 means that the button will be transparent.
Value 'This is a test' is the text that will be displayed on the button.
Value "" means that no further sub-routine will be executed when the player clicks the button.
Since we haven't specified a time (we used -1) after which the button will close automaticly and since whe haven't specified a sub-routine when the player clicks the button, it will mean the player is stuck with that button until he disconnects from the server, which isn't very useful.
So either we specify a time (in seconds) to automaticly close the button, or we specify a sub-routine to be executed when the player clicks the button.
Be carefull though, when players are driving their car using the mouse as control, such button will screw up their car control for as long as such button is on their screen.
I hope this post is useful to you, but don't hesitate to ask more questions if you have any.