The online racing simulator
Searching in All forums
(446 results)
Krayy
S2 licensed
Long story short, 6.0.1.2 does not handle multi-dimensional arrays the same way that 5.8.4.6 does and it's breaking as the arrays are getting nerfed so the data isn't available any more:

---- Dump of user_array ----
$user_array[1,4] = ""
$user_array[1,5] = "Krayy[LFSNZ]"
$user_array[1,6] = 1
$user_array[1,7] = 0
$user_array[1,8] = 0
---- End Dump of user_array ----

I'm working on a Lapper add on that will provide array support, so give me a day or so and I'll have a solution for both 5* and 6* Lappers.
Krayy
S2 licensed
If you're talking about running a function after the user logins, then use the privDelayedCommand after the last ENDIF, but before the EndEvent:


<?php 
    
ENDIF
        
privdelayedcommand4MyDelayedFunc);
EndEvent

Sub MyDelayedFunc
$userName )
...
EndSub
?>


Krayy
S2 licensed
My lapper includes directory is wildly different from the stock at the moment, so could you zip yours up and send it me and krayy0@gmail.com and I'll have a look at it for you.
Krayy
S2 licensed
The $user_array hasnt been used for a bit nowadays as it was part of an older module. In 6.0* use the folowing to loop through users:

<?php 
            $ListOfPlayers 
GetListOfPlayers("N");
            FOREACH ( 
$Player IN $ListOfPlayers)
                
privMsg (" Player = " $Player["value"]);
            ENDFOREACH
?>

The GetListOfPlayers command returns an array of all players, sorted by name (using "N' param).
Krayy
S2 licensed
Just as an aside, some of those Subs are computationally expensive which may slow Lapper down a bit.

As GLscript is an interpreted language, referencing a local variable vs making calls to Lapper to get a value takes quite a few cycles.

e.g. instead of using lots of calls like 'IF ( getLapperVar( "ShortTrackName" ) == "BL1" || getLapperVar( "ShortTrackName" ) == "BL2" ...' etc, use this:


<?php 
$myShortTrackName 
getLapperVar"ShortTrackName" );
IF ( 
$myShortTrackName == "BL1" || $myShortTrackName == "BL2" || ...
?>

Essentially try and limit the amount of things in your scripts that use multiple "getLapperVar" or "GetPlayerVar" commands that return the same data. Do 1 call into a local variable and query that and your scripts will run faster.
Krayy
S2 licensed
That would be the obvious thing that I've missed then.

Thanks
Krayy
S2 licensed
Is there a list of freeride track codes, or are they just the normal track IDs with freeride enabled?

If thats the case, I cannot see any InSim packet that identifies if we're in freeride mode which may affect split times by people taking shortcuts etc. Am I missing something quite obvious?
Krayy
S2 licensed
Quote from Yisc[NL] :I've already send an email to Gai about it, but do you think that Lapper 6.012 needs an update after the recent changes in InSim? I'm not talking about the added packages, only about what already is in Lapper.

With regards to the new version of LFS and InSim (v5), I would think that Lapper would need to be reversioned with 6.0.1.2 being for up to LFS .5Z and a new version for LFS .6B. The reasoning behind this is that pretty much all of the InSim functions will need to have wrappers put around them to check what version of InSim (LFS server) is being run which would be a hell of a lot of work. Taking the code to a new version and making it specific to .6B+ would be a lot easier.

I'll send some mods to GL for what I have done to 6.0.1.2 to do things like fix the countdown timers, and do some tricky stuff to allow some Lapper mods to do race setups and then I think he'll need to archive it and start a new fork.
Krayy
S2 licensed
The InSim API does not allow us to make any changes to in game Player options like pit owkr, fuel levels etc. The best we can do is to check what they have done by using thePitWork variable that is set after they leave the pits.

I have updated my Lapper to add a heap of extra stuff to the OnPitWork event so will forward that to Gai later.
Krayy
S2 licensed
Quote from sinanju :Just realised yesterday evening that the 2 different versions I have of your who.lpr are both called version 1.0.1

Everytime I install new fresh version of lapper on my pc to work on things, I include your CIF modules, and looking thru my old installs, all but 1 are using the older version!

If you do any new modules or updates, can you zip them all together along with current utils.lpr file, so that I know that I'm current?

Ta.

I'll reversion and submit new ones soon
Krayy
S2 licensed
Quote from Whiskey :/p_clear license

I'll send an update to Sinanju soon on how to do this. The wife broke her finger on Monday so I'm running a bit behind
Krayy
S2 licensed
The errors that you are seeing in the headers are probably due to an error in the LFSLapper.lpr file. The language ids called built_nicj etc are donw at the bottom of the lapper file. If there is an error above them, then they wont be loaded. Check you error log file (C:\LFSLapper\default\logs\127.0.0.1-31993-ERR.log or similar)to see if theres anything about an error there.

The higlightin is controlled in the includes/tops.lpr file
Krayy
S2 licensed
I know what you mean about getting old...I had a ZX80, ZX81 and a Spectrum! Almost had enough cash for the Sinclair QL, but it didn't take off like the Spectrum.

Anyhoo, I'll do up a module in CIF that you can easily modify for RCM and I'll comment it properly so you can see what it's doing. Most of the techniques I use are to get rid of multiple functions that do that same thing, as if you need to change something, doing it in 1 place instead of 32 is easier.
Krayy
S2 licensed
The way I'd look at doing it is to divide the screen into a top 2/3 and a bottom 1/3. Top 2/3 lists players in a 4x8 matrix to fit 32 in. Bottom 1/3 would show all your penalties in another matrix with default text grey. When a penalty is applied it shows in Yellow, so you can clear as well as set a penalty.

Have a couple of buttons at the bottom like Clear, Apply, Cancel and you're done.

I'm too busy to work out at the moment, but I'll do it in a CIF add on then you can modify it to your RCM

PS. For gods sake man, look at my code examples for how to do loops and common functions. You dont want to create 32 separate functions to do the same thing. Give me a day or so and I'll show you what I mean.
Last edited by Krayy, .
Krayy
S2 licensed
Just cut and paste the second lot of code over the first in the racecontrol.lpr file
Last edited by Krayy, .
Krayy
S2 licensed
The problem is that the code is opening Global buttons when a new player joins (leaves pits):


<?php 
# HUD Status Section
####################

Event OnNewPlayerJoin$userName )  # Player event

    
openGlobalButton"hud_back",70,0,60,14,1,-1,16,"");
    
openGlobalButton"hud_penback",71,1,39,6,1,-1,32,"");
    
openGlobalButton"hud_pexback",71,7,39,6,1,-1,32,"");
    
openGlobalButton"hud_trackback",110,1,19,12,1,-1,32,"");
    
openGlobalButton"hud_lightsbackleft",66,2,4,12,1,-1,16,"");
    
openGlobalButton"hud_lightsbackright",130,2,4,12,1,-1,16,"");
    
openGlobalButton"hud_pentext",71,1,40,5,5,-1,64,langEngine"%{hud_pentext}%"));
    
openGlobalButton"hud_pextext",71,7,40,5,5,-1,64,langEngine"%{hud_pextext}%"));
    
openGlobalButton"hud_tracktext",109,1,21,5,1,-1,0,langEngine"%{hud_tracktext}%"));
    
openGlobalButton"hud_penfront",97,2,12,4,1,-1,16,"");
    
openGlobalButton"hud_pexfront",97,8,12,4,1,-1,16,"");
    
openGlobalButton"hud_trackfront",111,6,17,6,1,-1,16,"");     
       
EndEvent
?>


Change all those openGlobalButton to openPrivButon and that should fix it. BTW, other modules use the OnNewPlayerJoin event, so it's best to change the declaration to use CatchEvent so you don't overwrite them like this:


<?php 
CatchEvent OnNewPlayerJoin
$userName )  # Player event
    
openPrivButton "hud_back",70,0,60,14,1,-1,16,"");
    
openPrivButton "hud_penback",71,1,39,6,1,-1,32,"");
    
openPrivButton "hud_pexback",71,7,39,6,1,-1,32,"");
    
openPrivButton "hud_trackback",110,1,19,12,1,-1,32,"");
    
openPrivButton "hud_lightsbackleft",66,2,4,12,1,-1,16,"");
    
openPrivButton "hud_lightsbackright",130,2,4,12,1,-1,16,"");
    
openPrivButton "hud_pentext",71,1,40,5,5,-1,64,langEngine"%{hud_pentext}%"));
    
openPrivButton "hud_pextext",71,7,40,5,5,-1,64,langEngine"%{hud_pextext}%"));
    
openPrivButton "hud_tracktext",109,1,21,5,1,-1,0,langEngine"%{hud_tracktext}%"));
    
openPrivButton "hud_penfront",97,2,12,4,1,-1,16,"");
    
openPrivButton "hud_pexfront",97,8,12,4,1,-1,16,"");
    
openPrivButton "hud_trackfront",111,6,17,6,1,-1,16,"");     
EndCatchEvent
?>


Krayy
S2 licensed
The config_membership CIF plugin uses the !ma command for membership admin, but that's easy to add !admins as well like this:


<?php 
    
SWITCH( $command )
        CASE 
"!admins":
        CASE 
"!ma":
            
DoCifConfigMembership(0,0);
        BREAK;
    ENDSWITCH
?>

Krayy
S2 licensed
The CIF has superseded the !admins command and other gui based commands that I created.

If you're having problems with the CIF gui, I can help you out with that
Krayy
S2 licensed
Just use the membership admin part of the CIF with the !ma command from here: http://www.lfsforum.net/showthread.php?t=72589

You will be able to set users to be admins, members, guests etc
Krayy
S2 licensed
Here's a modified version taht is designed to allow a more modular approach for setting Traps in mid-corner, corner exit or whever you want. I've changed the display to be basic PrivMsg's, so you'll need to change them if you want to use it in your HUD.

Add extras nodes like this (although the Nodes are worng, this is just a demo):


<?php 
    RegisterNodeAction
"FE1" 50StMidCorner1,"" );
    
RegisterNodeAction"FE1" 105SpeedTrap1,"" );
    
RegisterNodeAction"FE1" 288SpeedTrap2,"" );
?>

This also displays the speed based on the players UnitSpeed.

PS: This version is mostly optimised by reducing the number of calls to the Lapper.exe by using the GetPlayerInfo function that returns an array to the Lapper script that contains all relevant calls. Also, the GetStored* and SetStored* functions can be called without the $UserName parameter as it will default to current player.


<?php 
Sub DoSpeedTrap
$TrapType$TrapText$TrapNum )
    
$currPly GetPlayerInfo();
    
$TopSpeed ToNum$currPly["InstantSpeed"] );

    
$StoredVarName "TrapSpeed" "-" $TrapType "-" $TrapNum "-" getLapperVar("ShortTrackName") . "-" $currPly["Car"];
    
$OldTopSpeed GetUserStoredNum $StoredVarName);
    
    IF ( 
$OldTopSpeed # Have not had a valid Speedtrap time before
    
THEN
        privMsg 
langEngine "%{main_st_none}%" $TrapTextToPlayerUnit($TopSpeed), $currPly["UnitSpeed"] ) );
        
SetUserStoredNum $StoredVarName$TopSpeed);
    ELSE
        IF ( 
$TopSpeed $OldTopSpeed)
        
THEN
            privMsg 
langEngine "%{main_st_faster}%" $TrapTextToPlayerUnit($TopSpeed ), ToPlayerUnit($TopSpeed $OldTopSpeed), $currPly["UnitSpeed"] ) );
            
SetUserStoredNum $StoredVarName$TopSpeed);
        ELSE
            
privMsg langEngine "%{main_st_slower}%" $TrapTextToPlayerUnit($TopSpeed), ToPlayerUnit($OldTopSpeed $TopSpeed), $currPly["UnitSpeed"]  ) );
        ENDIF
    ENDIF
EndSub

Sub StMidCorner1
$userName )
    
DoSpeedTrap"MC""Mid-Corner speed");
EndSub

Sub StCornerExit1
$userName )
    
DoSpeedTrap"CE""Corner Exit speed");
EndSub

Sub SpeedTrap1
$userName )
    
DoSpeedTrap"RT""Radar Trap speed");
EndSub

Sub SpeedTrap2
$userName )
    
DoSpeedTrap"RT""Radar Trap speed");
EndSub

Sub SpeedTrap3
$userName )
    
DoSpeedTrap"RT""Radar Trap speed");
EndSub

Sub SpeedTrap4
$userName )
    
DoSpeedTrap"RT""Radar Trap speed");
EndSub

Sub SpeedTrap5
$userName )
    
DoSpeedTrap"RT""Radar Trap speed");
EndSub

Sub SpeedTrap6
$userName )
    
DoSpeedTrap"RT""Radar Trap speed");
EndSub

Lang 
"EN"
    
main_st_faster "{0}: {1} {3} (^2+{2}^0)";
    
main_st_slower "{0}: {1} {3} (^1-{2}^0)";
    
main_st_none  "{0}: {1} {2}";
EndLang

?>


Last edited by Krayy, .
Krayy
S2 licensed
Just a thought...one addition you could make to the above code is to add an OnRaceStart CatchEvent to cycle through a list of players (GetListOfPlayers) to set their current track & car times to -1 before the race starts so people get fresh stats each race. Of course you would need to set the stored value for all of the split numbers you have (6 at the moment).

Although seeing the stats based on your best time does give you something to aim for.

Alternativey, use this code tthat doesnt store vars:

<?php 
Sub DoSpeedTrap
$num )
    
$userName GetCurrentPlayerVar"UserName" );
    
$car GetCurrentPlayerVar("Car");
    
$track getLapperVar("ShortTrackName");
    
$TopSpeed ToNumGetCurrentPlayerVar"InstantSpeed" ));
    
$OldTopSpeed ToNum(GetCurrentPlayerVar "ST" $num "TopSpeed-" $track "-" $car));
    
    IF ( 
$OldTopSpeed # Have not had a valid Speedtrap time before
    
THEN
        openPrivButton
"st_text",1,16,20,5,3,4,80langEngine "%{main_st_none}%" ,ToMph($TopSpeed) ) );
        
SetCurrentPlayerVar "ST" $num "TopSpeed-" $track "-" $car$TopSpeed);
    ELSE
        IF ( 
$TopSpeed $OldTopSpeed)
        
THEN
            openPrivButton
"st_text",1,16,30,5,3,4,80langEngine "%{main_st_faster}%" ToMph($TopSpeed ), ToMph($TopSpeed $OldTopSpeed) ) );
            
SetCurrentPlayerVar "ST" $num "TopSpeed-" $track "-" $car$TopSpeed);
        ELSE
            
openPrivButton"st_text",1,16,30,5,3,4,80langEngine "%{main_st_slower}%" ,ToMph($TopSpeed), ToMph($OldTopSpeed $TopSpeed)  ) );
        ENDIF
    ENDIF
EndSub
?>


Last edited by Krayy, .
Krayy
S2 licensed
Nice mod. I'll put that into our Lapper installs.

Couple of things:

1) Use GetStoredNum to return a numeric, not a string otherwise you need to do a string to num conversion for compare
- thats where your script error came from, trying to minus a string from a number - the following would have fixed it:

<?php 
  $OldTopSpeed 
GetUserStoredValue$userName"OldTopSpeed" );
  
$STdiff ToNum($OldTopSpeed) - $TopSpeed;
?>

BUT...

2) Don't do the ToMph conversion before the pseed compare as this will round down the result to 2 decimal places and is inaccurate
3) Do not use commas in a storevalue key as the SQL parser will incorrectly interpret them
4) Move the notification from the top left as game messages obscure it

Try the code below, replacing all of the Speedtrap# commands with the templates below (makes it easier to maintain) and the Language defs:

<?php 
Sub DoSpeedTrap
$num )
    
$userName GetCurrentPlayerVar"UserName" );
    
$car GetCurrentPlayerVar("Car");
    
$track getLapperVar("ShortTrackName");
    
$TopSpeed ToNumGetCurrentPlayerVar"InstantSpeed" ));
    
$OldTopSpeed GetUserStoredNum $userName"ST" $num "TopSpeed-" $track "-" $car);
    
    IF ( 
$OldTopSpeed # Have not had a valid Speedtrap time before
    
THEN
        openPrivButton
"st_text",1,16,20,5,3,4,80langEngine "%{main_st_none}%" ,ToMph($TopSpeed) ) );
        
SetUserStoredNum $userName"ST" $num "TopSpeed-" $track "-" $car$TopSpeed);
    ELSE
        IF ( 
$TopSpeed $OldTopSpeed)
        
THEN
            openPrivButton
"st_text",1,16,30,5,3,4,80langEngine "%{main_st_faster}%" ToMph($TopSpeed ), ToMph($TopSpeed $OldTopSpeed) ) );
            
SetUserStoredNum $userName"ST" $num "TopSpeed-" $track "-" $car$TopSpeed);
        ELSE
            
openPrivButton"st_text",1,16,30,5,3,4,80langEngine "%{main_st_slower}%" ,ToMph($TopSpeed), ToMph($OldTopSpeed $TopSpeed)  ) );
        ENDIF
    ENDIF
EndSub

Sub SpeedTrap1
$userName )
    
DoSpeedTrap);
EndSub

Sub SpeedTrap2
$userName )
    
DoSpeedTrap);
EndSub

Sub SpeedTrap3
$userName )
    
DoSpeedTrap);
EndSub

Sub SpeedTrap4
$userName )
    
DoSpeedTrap);
EndSub

Sub SpeedTrap5
$userName )
    
DoSpeedTrap);
EndSub

Sub SpeedTrap6
$userName )
    
DoSpeedTrap);
EndSub

Lang 
"EN"
    
main_st_faster "^0Radar Trap: {0} mph (^2+{1}^0)";
    
main_st_slower "^0Radar Trap: {0} mph (^1-{1}^0)";
    
main_st_none  "^0Radar Trap: {0} mph";
EndLang
?>


Last edited by Krayy, .
Krayy
S2 licensed
I've also noticed that in LFS Lapper if you sned a TINY_SST, then a STA does not get sent to InSim Sniffer if it's connected to the server but it does get sent back to the Lapper instance. This also works the other way, where a TINY request in Sniffer does not egt sent to Lapper (TINY_REO for instance). This would indicate to me that responses to TINY_* requests are linked to the session requesting them.
Krayy
S2 licensed
That's what I'm doing currently. What I'm trying to do is to detect if an admin has used the "/start <mode>" command to set the race order rather than use the GUI interface.
Detecting "/start" mode
Krayy
S2 licensed
Hi all,

So I'm modifying Lapper to allow us to set race grid order via a GUI interface and the problem is that there does not seem to be any way wihtin InSim to detect what the "/start" mode is (fixed, random, finish, et al). InSimSniffer doesn't show any kind of state change or other packet when you type "/start random" or other mode in game, so has anyone figured a way to find this out?

If not, then I suppose I need to assume that people will contorl it via the Lapper app and do all of the ordering, mode change tracking and other ousekeeping in the script. Then I can replace the "/start" command with "!start" with the same params. The problem there is if someone uses the original "/start" command, I lose track of the state.

Any ideas, or do I just rely on people using the right method?
FGED GREDG RDFGDR GSFDG