To be honest, I don't understand the code you are using - I'm not a coder. I can infer it's placing specific sized and coloured buttons, but that's it.
LFS doesn't know where "Job From House 1" is (or 2, 3, etc), which is why you have to make a zone (specify the X and Y coordinates), so that when a car enters a specific zone, this triggers your buttons.
A very simple way of making a zone would be to go into Autocross mode (SHIFT U) then placing an InSim circle (can be found under Marshall tab, along with Marshalls, route checker, etc.) anywhere on or off track, in pits, etc.
Use letter O to place circle and letters W or E to make circle smaller/larger as appropriate.
Take note of circle index number, and use that number to trigger code when car enters circle.
Rather than using one giant circle to create a zone, there's nothing to stop you using multiple smaller circles to create your zone, and having multiple index numbers triggering the same piece of code.
1 x 10m circle - index number 0 = Zone 1
2 x 5m circles - index numbers 0 + 1 = Zone 1
5 x 2m circles - index numbers 0, 1, 2, 3 + 4 = Zone 1
No idea what code would look like, but it would follow rules like (assuming multiple circles for same zone) ....
IF car enters index number 0
or
IF car enters index number 1
or
IF car enters index number 2
....
You need to find the X and Y coordinates that you want to use in each area of track and surrounds (pits, access roads, off-road area, etc) and define this X Y 'zone' for each task.
As in;
Zone1 - arrive in specified area (zone) and this is used as a trigger to be given details of 'job', and told where delivery should be made
Zone2 - specified area (zone trigger point) for delivery
There is an Open Source Cruise Insim (HERE) that you may be able to use to find the info you need.
And someone asked similar question in that topic about XY Zones (HERE), but I never searched to find out if it was answered.
Also, you could try searching on forum with 'x y coordinates' as the keywords.
Be nice if you didn't shout and spam all over the forum - one post could have done for both your questions - one of which has been answered, but just in case...
sets - these go in LFS/data/setups folder
layouts - look in this forum for the Files section, then Autocross Layouts - or if you can't be bothered looking for it, or use the search function, then look here. Will require that you have a S1 license to use them.
I made a Menu system years ago that has section for choosing languages HERE, although you could easily just use !myconfig by making a button that calls that sub.
I've always allowed both racing and drifting on my server ...
I didn't just make up the name on my server for this post - it's been there a couple of weeks now (link).
I even made a drift scoreboard that shows for everyone that goes on my server, even if they only want to race, and it's been like that for a number of years now.
What if I don't want LFS to differentiate my server into either race or drift?
According to the 'Hosting Information' link at bottom of forum pages, under INSIM PLUGINS within panel on right hand side of page (about half way down), only the free version of Airio is supported ....
To be honest, don't see why 'lapper' isn't supported; probably just as easy/hard to set up as Airio, but that's down to the LFS team. As a lapper user myself, I think it's a shame, as I find you can be more creative in lapper than in airio.
Apologies, but I gave you code that works in my V6 - there was an update in V7.0.4.4 that makes my code obsolete if using this newer, or even later, version.
Means you will have to add an 'ID' to your code (in front of your BL2 track abbreviation).
To be honest, i've no idea why this was changed, nor what the code example above means.
TESTID/$ZoneID - I want my RNA (RegisterNodeAction) to be a trigger for something to happen. I already have the sub name (in example above, sub is 'test'). I'm not going to output the name or number of the node. Why would I need or want to? If I did, I could just write the info in the button. What happens if I use the zone id more than once in different nodes, or with different subs?
getLapperVar( "ShortTrackName" ) - Is this right? Why am I asking for the track abbreviation. I want me to tell lapper which track I want the sub to run on. If I use this, will it actually run, or will it run on every single track?
getCurrentPlayerVar("CurrNode") - Is this right? Why am I asking for the current node. I want me to tell lapper which exact node I want the sub to run on. If I use this, will it actually run, or will it run at every node?
test - this is the sub - tells lapper to run this sub when you cross node - perfectly understandable.
"" - never understood the logic behind this 2nd sub callback. I know its for when leaving the node you've just crossed, but distance between nodes is so small, you would be travelling at speed (even if only few mph/kph, and would probably only be milliseconds between nodes). So why not put all your actions in 1st sub? If you want to display 2 different pieces of information, why not just make 2 buttons in one sub, rather than 2 subs with one button each?
I have the same issues with the RZA (zones), as I don't need a zone id or a 2nd sub. Can sort of see why you might want 2nd sub callback as zones can be made large, but I'd rather have 2 small zones, each with their own sub.
Looking back at my add-ons where I use zones, none of the RZA's has a zone id - only track abbreviation, X, Y, size, sub1, "" (never a 2nd sub). And they all work.
Think of RegisterNodeAction and/or RegisterZoneAction as a way to make your own Event.
At an Event, you can code something within lapper to happen, as in
Event OnSplit1( $userName ) # Player event
you can have lapper put a button on screen with some text, like
There's an Event for both Split 1 and Split 2, but if you want something to happen in between, you would have to make up your own using RegisterNodeAction / RegisterZoneAction.
So if you knew the node number between Split 1 and Split 2, then you could put that number into the RegisterNodeAction line along with a sub-routine, and the sub-routine could have something like
If you watch a video I made while ago and put on YouTube ...
... you can see messages pop up on my Pace Notes section on right hand side of screen.
Because I was not driving on a track, where I could use nodes, I had to use zones, but if the off-track roads did have nodes, then my code would have looked like ...
RegisterNodeAction( "WE2X",100,PN3,"" );
The above line would have been in the Event OnLapperStart() section.
The following sub, would be somewhere under EndEvent ...
Sub PN3( $userName ) openPrivButton( "pn_note",180,60,34,6,7,-1,0,langEngine( "%{pn_3}%" )); EndSub
And the following would appear in my EN language file
pn_3 = "Start 1st sector from Yellow gate" . "%nl%Large hairpin right" . "%nl%leads to narrow gate" . "%nl%3 left" . "%nl%" . "%nl%^3150 right into tunnel ^1HAZARD";
The 1st 4 lines have uncoloured (grey) text, while last line has yellow text to highlight what's next, and red HAZARD letters.
In my code, I had over 60 zones, and on entering a zone, a message for only that zone appeared on screen.
Like I said, if I could have used nodes, then everytime I crossed a node, the message for that particular node would have appeared.
LFS uses Nodes for setting it's own events, such as sectors/splits/finish lines, as a node goes from one side of the track to the other, but LFS in Autocross mode, allows you to place zones. An LFS zone is usually either a restricted (visible or invisible marshall) circle, or a checkpoint circle.
Zones can be placed almost anywhere, including on the track, off-track, and in the pits.
In a recent upgrade, LFS allows the placing of InSim circles in Autocross mode. These are zones. Great thing about using these, is you don't have to know the X,Y co-ordinates; only the InSim Circle number - but you then have to use slightly different coding (NOT RegisterNodeAction and/or RegisterZoneAction).
If you need to find Node or Zone co-ordinates in lapper, you type !node or !zone when you drive to that section of the layout, and record the exact details.
The standard 'welcome' message is in this section, so if you see the message, then the Event works.
This acts like a 'trigger', as does RegisterZoneAction.
In both of these, you have to set track abbreviation, X and Y co-ordinates, along with a sub-routine name. In the Zone action, you also have to set the size (in metres) of the zone (eg 1 would be an area 1m x 1m).
When driving the specified track, and when a car either crosses a node, or enters a zone, then lapper knows to start the sub-routine that is called within the registered action line.
You can't put an Event under a sub, nor should you put a sub under an Event.
But you can call a sub from within an Event.
For an example, look at the OnConnectClose sub in the Event OnConnect - you'll see that the sub is called within the event (at end of a button - and works when you press that button), but the sub is outwith the Event itself (comes after EndEvent).
Before you start getting too involved in everthing, the very first thing you should be doing is seeing if you can get the driftscores of 2 drivers onto the screen at the same time.
Forget how things will look, angles, adding scores, who's in front/behind. Just try get 2 drivers $LastDriftScore to show on screen at same time.
You won't be able to do this with private buttons, and if you use global buttons, how does lapper know how to differentiate between the 2 drivers, and not get scores mixed up?
I suspect that you may have to look at using openButton AND getListOfPlayers AND the FOREACH loop.
Following bit of code is something that I amended slightly from code that Bass-Driver gave me for something drift related, and gives you an idea of what may be required...
CatchEvent OnDriftScore($userName) # Player event $hgt = 50; $Drivers = getListOfPlayers("N"); FOREACH( $Var IN $Drivers ) #For each player in the $drivers list IF (GetPlayerVar($maVar["value"], "OnTrack") == 1) THEN #IF player is on track , display his name and totaldriftscore $hgt=$hgt+4; #Buttonheight + 4 (has to be used else your second driver will just be placed and overwrite 1st driver) openButton($Var["value"],"driver_Ply_".$maVar["value"],3,$hgt,18,4,1,-1,96,"".Getplayervar($maVar["value"],"NickName")); openButton($Var["value"],"driver_DScore_".$maVar["value"],21,$hgt,10,4,1,-1,32,"^3".Getplayervar($maVar["value"],"DriftScore")); ENDIF ENDFOREACH EndCatchEvent
You're not using the CASE command properly. Its basically there as a command to do something (usually simple), such as output a button or start a sub-routine WHEN you type in the trigger word - in this case !twin.
Think of the !top command - once you type in !top, you get a list of the top best times.
It happens once. It normally does not update. If someone does a new faster time while you're looking at the top table, you have to type in !top again, for table to refresh.
Yours should have been something like
CASE "!twin": openPrivButton( "twin_message",([i]dimensions here[/i]),"Twin Drift System now enabled" ); DoTwinSub(); BREAK;
so when you type !twin, lapper knows to then start the sub called DoTwinSub
Why do you think you need the $me/$behind/$front variables?
Also. I don't understand the IF statements....
IF (9 > 7)
IF (7 > 6)
9 is always going to be more than 7 and 7 is always going to be more than 6.
What do the numbers indicate?
Now, if you meant
IF ($behind > $me) - or - IF ($behind < $me)
that would make more sense, although may not work, as lapper has already worked out the UNameBehind and UNameBefore users.
If I was making a twin drift system, then there would be 1 question; do i want to give users/admin option to switch twin system off/on, or would it be on all the time?
If an option to turn off/on, then you would have to start playing about with GlobalVars and a simple CASE command to get started - complicated subject. if you want to see it in action, look at Yisc[NL]'s pitboard lapper script for a GlobalVar that has "off" or "on" set.
In either case, all the code should be within the Event OnDriftScore( $userName ) section.
You can either use the section within the lfslapper.lpr file, or make your own add-on, in which case you would need to Catch the Event, as in CatchEvent OnDriftScore( $userName ).
If you went down the GlobalVars route, then you would need another IF-ENDIF section, which could be done various ways, as in,
IF enabled,
THEN...
- or -
IF not enabled
THEN use usual code,
ELSE use this code
....etc
====================
There are probably only a handful of people who use lapper that could make a twin drift system, and I'm not one of them. Not only that, all but 2 of these people don't actually give advice or put their code on the forum, and even if I could make a twin drift system, I wouldn't make it public.
This is a fairly good feature to have to 'sell' your server, and have people use your server rather than someone else's, so why give it away?
I'm not sure, but I don't think these UNameBefore/UNameBehind will work in a sub like that, as i'm sure they need a split/sector/lap Event to trigger, such as Event OnSpbSplit1( $userName ).
Maybe you could try with the distance done Event (Event OnDistDone)? If it does work, don't make it every single meter, but try every 10, 25, or 50?
Alternatively, maybe using Nodes, Zones or InSim circles in AutoX mode as the triggers?
/axlist X :get list of layouts for track X - e.g. AU1 /axload X :load layout X on host /axsave X :save layout X on host /axlaps X :set autocross number of laps /axclear :clear layout ?>
.... then you can probably use the cmdLFS command within a button.
If you want to see script that has cmdLFS in action, see HERE (Tim NL's Config GUI). It's a bit out of date now, but fairly easy to see how he used cmdLFS to load cars, tracks, etc. You just need to do something similar for autocross layouts.
To make sure they're the right commands, and they work, try typing these commands on your server.
At the moment its not yet possible, as there is no sql field for the layout, only the track.
As you can see from screen dump, it saves the track abbreviation (BL1X) as trackname, but if you use more than one layout on this track, then all the drift scores will get mixed up, and your current layout will show the old drift scores too.
It isn't just drift scores that will be affected, as sector and lap times will be too, as they are also only saved under track abbreviation.
The way I do it is to make new file directory for each and every layout, and only save times and points to that directory.
Probably, but as I replace a lot of files at once, I replace layout at same time, so I have no need for it.
Made a slightly shorter track @ 6,290 metres / 3.1 miles, against original long track length of 6,927 metres / 4.3 miles - so 10% shorter. Removed some of the difficult hairpin turns (which I struggled with using keyboard).
Because it's shorter, used extra objects to put painted lines in centre of track in some corners.
Just finished one of the walls right round the track - the high one on the left, that's meant to look cliff like.
Other side, with lower concrete walls, armco and some tyre stacks, is maybe quarter done; long way from being finished.
There are some floating overhead direction marker boards to help navigate round.
I won't be available to work on the layout again till early next week, so layout will stay 'as is' for next few days.
Be aware that if you complete a lap, and your time recorded in the top 12 on front screen, it will be wiped when I update layout. However, any times under 5 minutes will be saved by my InSim, so you can look at the !top times.
Drift scores: Regardless of time taken to get round, a complete lap will mean that any score will also be recorded/saved.
There are currently about a dozen drift scores saved, the highest just over 9,200, recorded by Willi.