The online racing simulator
Searching in All forums
(446 results)
Updated utils.lpr & who.lpr
Krayy
S2 licensed
Hi Gai,

These files update the !who command to use a standardised Dialog box layout, and also adds these new utility functions:

DialogCreate ( $userName, $DialogPrefix, $origL, $origT, $Width, $Height, $Title, $showClose, $secondsDisplayed)
This function creates a standardised Dialog so that it creates continuity with the user interface

DialogClose
This function is called from the standardised DialogCreate function, and closes the entire dialog

ButtonExists( $userName, $ButtonToFind )
This function returns TRUE if a button already exists for a user, or FALSE if it doesn't. Called like this:

<?php 
    
IF ( ButtonExists(GetCurrentPlayerVar("UserName"), $DialogPrefix ".*bg") == FALSE)
    
THEN
        DialogCreate 
GetCurrentPlayerVar("UserName"), $DialogPrefix$origL-1$origT$Width$Height$DialogTitle$ShowClose$secondsDisplayed);
    ENDIF
?>

DEBUG ($msg)
This function will output a message to any Lapper Admins with the preface "DEBUG: ". Very useful for debugging messages, and easily disabled using the Global variable $DebugOn.
Krayy
S2 licensed
Quote from amp88 :Sounds interesting. What happens if they overtake someone who is disabled (e.g. the car causing the need for a SC is upside down and someone overtakes them) or if a driver makes a mistake and leaves the track under SC (and can therefore be overtaken by people who are under SC conditions (as demonstrated at the Australian GP with Lewis Hamilton / Jarno Trulli))?

Easy enough...just look for an IS_FLG condition and if the player then has a yellow flag against them, allow them to move down the order. Of course, they wouldn't be able to move UP the order, unless they are passing another car with a yellow flag condition.

That would get worked out in testing I suppose.
Krayy
S2 licensed
I'm making an addon for Lapper to simulate a safety car, as there is no way to launch a safety car from a dedicated server.

Basically, when a safety car is called by an admin, the race will go full course yellow, indicated by a flag in the centre of the display. The drivers will then need to slow down to a maximum of 120km/h, and if they ovrtake, there will be messages on the screen telling them to get back in order (drop X places). They will also get messages to slow donw/speed up depending on the gap between the next racer in line.

Then when it restart time, they will be green lighted as they cross the start/finish.
Krayy
S2 licensed
Quote from lysergic :Hi, I'm trying to update my old Lapper to the last version but I need the pb values stored in old format PB.txt to be imported in the new .elp file.

Any help?

Just take your old PB.txt file and copy it into the new Lapper/bin/<instance> directory (usually Lapper/bin/default) and rename it to match the database name entries in your Lapper.lpr file with ".txt" on the end. So if your lkapper file has:

<?php 
$GripDatabase 
"./GripPB"
$DriftDatabase "./DriftPB";
?>

Then rename the PB.txt file to "GripPB.txt", and your drift.txt file to "DriftPB.txt".

After you have done that, remove any *dbs files in your Lapper instance directory and restart lapper.
Krayy
S2 licensed
Quote from Krayy :Hi GL,

Please have a look at the attached patch file for soem additional vars and functions that I would like intergrated into your next release to help support a number of race tracking and managing addons that I am in the process of creating. Here is a summary of what's in the patch:

Functions
closePrivButtonRegex & closeButtonRegex - these functions will close all of the active buttons that match the given Regular Expression, so to close all of the buttons on the !who command, just use:

<?php 
closePrivButtonRegex 
("dowho.*");
?>

Events
OnPracStart - This event is run when a practice session is started

Lapper Vars
raceinprog - this lapper vars will return the current race state that match the following entries in the consts.lpr file:

<?php 
# Race type
const RACEINPROG_NONE        0# Race not in progress
const RACEINPROG_RACE        1# Race
const RACEINPROG_QUALIFY    2# Qualify
?>

raceid - this lapper var returns a unique identifier for the race based on the race start time. This is used to track if a player has already been in the race prior to a disconnect, and also lets us gather stats based on the raceid for series points calculations.

Many thanks.

* Updated patch file attached *

The attached patch file has modified some of the code that was not required and updated the RaceID so that it can be used with the SplitToArray function.
New Function/Var requests
Krayy
S2 licensed
Hi GL,

Please have a look at the attached patch file for soem additional vars and functions that I would like intergrated into your next release to help support a number of race tracking and managing addons that I am in the process of creating. Here is a summary of what's in the patch:

Functions
closePrivButtonRegex & closeButtonRegex - these functions will close all of the active buttons that match the given Regular Expression, so to close all of the buttons on the !who command, just use:

<?php 
closePrivButtonRegex 
("dowho.*");
?>

Events
OnPracStart - This event is run when a practice session is started

Lapper Vars
raceinprog - this lapper vars will return the current race state that match the following entries in the consts.lpr file:

<?php 
# Race type
const RACEINPROG_NONE        0# Race not in progress
const RACEINPROG_RACE        1# Race
const RACEINPROG_QUALIFY    2# Qualify
?>

raceid - this lapper var returns a unique identifier for the race based on the race start time. This is used to track if a player has already been in the race prior to a disconnect, and also lets us gather stats based on the raceid for series points calculations.

Many thanks.

* Updated patch file attached *
Last edited by Krayy, .
Krayy
S2 licensed
Fire_Optikz is right...use the OnSplit1, OnSplit2 and OnSplit3 functions to set a player var like this (Sector 1 is from Start/Finish to Split 1):


<?php 
CatchEvent OnLap
$userName # Player event
    # Update event lap count
    
SetCurrentPlayerVar "Sector");
    
$RaceLaps GetCurrentPlayerVar ("RaceLaps");
    
$RaceLaps $RaceLaps 1;
    
SetCurrentPlayerVar "RaceLaps"$RaceLaps );
    
SetUserStoredValue "RaceLaps"$RaceLaps);

        
# Update the PB if the current lap is faster than the PB
    
$RacePB GetCurrentPlayerVar("RacePB");
    
$CurrLapTime GetCurrentPlayerVar ("LapTime");
    IF ( 
ToNum($RacePB) < || ToNum($CurrLapTime) < ToNum($RacePB) )
    
THEN
        SetCurrentPlayerVar 
"RacePB"$CurrLapTime );
        
SetUserStoredValue "RacePB"$CurrLapTime);
    ENDIF

    
RaceTickerUpdate();
EndCatchEvent

CatchEvent OnSplit1
$userName # Player event
    
SetCurrentPlayerVar "Sector");
EndCatchEvent

CatchEvent OnSplit2
$userName # Player event
    
SetCurrentPlayerVar "Sector");
EndCatchEvent

CatchEvent OnSplit3
$userName # Player event
    
SetCurrentPlayerVar "Sector");
EndCatchEvent

?>


NB: This code is from a race tracker that I will release soon. it's main purpose is to track a racers state if they disconnect or pit/re-enter, and also to provide custom race reporting for our web site.
Krayy
S2 licensed
Update on the CloseButtonRegex...it works bloddy brilliantly! No more having to search through the code to find what buttoins i'd forgotten to put in the close command. happy as. Saves a lot of time.

New code...

AdminMsg. It's basically the same base code as the GlobalMsg command, but it only displays the message to Admins. i use this fro Debug and other Admin related messages, so that normal racers don't get spammed.

In scriptFunctions.cs:

<?php 
            newCfg
.CurrApp.registerCallBackFunction("adminmsg"adminmsg);
...
        public 
void adminmsg(GLScript.unionVal valArrayList args)
        {
            
infoPlayer currInfoPlayer;
            
string ident val.nameFunction;
            
testArgs(ident"S"args);
            
string text args[0].ToString();
            
string newText "";
            
uGroup.clear"admin");
            
uGroup.addUserFromFile("admin",newCfg.varsLapper.WorkingDir "/" newCfg.varsLapper.AdminFile );
            foreach (
DictionaryEntry de in listOfPlayers.playersUCID)
            {
                
currInfoPlayer = (infoPlayer)de.Value;
                if (
uGroup.userExist("admin"currInfoPlayer.userName) || currInfoPlayer.UCID == 0)
                {
                    if (
text == "[[TranslateEngine]]")
                        
newText lfsLang.replaceParmsLangStr(currInfoPlayer.idLang);
                    else
                        
newText text;
                    
SendMsgToConnection(currInfoPlayer.UCIDnewText);
                }
            }
        }
?>

Ten I use it in my lappers like this:


<?php 
Sub DEBUG 
($msg)
    IF ( 
$DebugOn )
    
THEN
        adminMsg
"^5DEBUG: ^8" $msg );
    ENDIF
EndSub

Sub ADMIN 
($msg)
    IF ( 
$DebugOn )
    
THEN
        adminMsg
"^7ADMIN: ^8" $msg );
    ENDIF
EndSub

Event OnRaceStart
$NumP # Lapper event
    
ADMIN ("Race starting: " $NumP);
    
DEBUG ("Race type is: " getLapperVar"RaceInProg" ));
EndEvent
?>


Krayy
S2 licensed
Very nice. I think I'll display them when you enter pits with a warning about the speed limit, then remove when pits left.
Krayy
S2 licensed
If I'm in a race and need a condom and some KY Jelly, I'd better not be bringing up the rear :eye-poppi
(come to think of it, I'd rather not be first in the line either)
Krayy
S2 licensed
Cute. Maybe you could apply it when the racer gets a yellow flag with the dots having different fade out times to simulate the drops flying off as they speed up.
Krayy
S2 licensed
Quote from Fire_optikz001 :i get 3 Massive ?s

What editor are you using...it might be set to use a TTF font that does not include the std ASCII character set (like Arial).

Try using a different editor like Notepad++ or PSPad
Krayy
S2 licensed
Quote from YamaSuba.NL :To cut things short, the adding to the array of the player at hand seems to have caused the rest of the array being blanked out. And that I don't understand... Might I have come across some mystical bug, or am I doing something terribly wrong myself??

It's not mystical, just annoying

I have found in my mucking about that Lapper handles arrays in an unpredicatble fashion when trying to assign values to elements that have already been defined, particularly if you got that value out of an existing array. Doing a type conversion (cast) solves the problem (are we getting technical yet?).

I think the problem in your code is when you are trying to reassign the array values here:


<?php 
    $a_user_array
[$x"username"] = $userName;
    
$a_user_array[$x"finishedpos"] = GetCurrentPlayerVar("FinishedPos");
?>

Try changing it to:

<?php 
    $a_user_array
[$x"username"] = ToString($userName);
    
$a_user_array[$x"finishedpos"] = ToNum(GetCurrentPlayerVar("FinishedPos"));
?>

and see how you got. The ToString and ToNum functions essentially do a type cast on those values.
Krayy
S2 licensed
Quote from Yisc[NL] :I replied at you, but forgot to quote and for the word 'not' (corrected last one in my original posting).
What I meant is that I think I already made a closing button routine (which I included in my original posting) so you might be able to use that.
If I misunderstood you, then I apologise for that.

Ah, in that case, tyhanks for the reply, but it's not quite what I mean (and I use that technique in the handicapper and who scripts).

What I mean is that the generic open routine would create the base buttons and then you add on your custom buttons after that. Now when it comes time to close the buttons, the generic close cannot know what buttons you have created, but if you use a common Prefix, then we can use a regular expression to determine if that button should be closed. i.e.

If i have buttons called "who_title", "who_background, "who_line1, "who_line2, then doing a closePrivButtonRegex("^who_.*"); would iterate through all of the buttons, check which ones start with "who_" and delete them. This means it does not matter what you have called the buttons, as long as the prefix is the same. This needs to be done in the lapper executable like this:

insimButton.cs:

<?php 
        
public void deleteButtonRegex(string patternint UCID)
        {
            
ArrayList al = new ArrayList();
            foreach (
DictionaryEntry de in hashMsgBox)
            {
                
box currBox = (box)de.Value;
                if (
Regex.IsMatch(currBox.idpatternSystem.Text.RegularExpressions.RegexOptions.IgnoreCase))
                {
                    
al.Add((string) currBox.id);
                }
            }
            
string[] butToClose = (string[]) al.ToArray(typeof(string));
            for (
int i 0butToClose.Lengthi++)
            {
                
this.delete(butToClose[i], UCID);
            }
        }
?>

infoPlayer.cs

<?php 
        
public void privateButtonCloseRegex(string argString)
        {
            
this.playerBox.deleteButtonRegex(argStringthis.UCID);
        }
?>

scriptFunction.cs:

<?php 
            newCfg
.CurrApp.registerCallBackFunction("closebuttonregex"closebuttonregex);
            
newCfg.CurrApp.registerCallBackFunction("closeprivbuttonregex"closeprivbuttonregex);
...
        public 
void closebuttonregex(GLScript.unionVal valArrayList args)
        {
            
infoPlayer currPly;
            
string ident val.nameFunction;
            
currPly listOfPlayers.getPlayerByUserName((string)args[0]);
            if (
currPly == null)
            {
                throw new 
GLScript.GLApp.GLScriptException("Player name " + (string)args[0] + " in function " ident " not a player");
            }
            
args.RemoveAt(0);
            
testArgs(ident"S"args);
            
currPly.privateButtonCloseRegex(args[0].ToString());
        }
        public 
void closeprivbuttonregex(GLScript.unionVal valArrayList args)
        {
            
infoPlayer currInfoPlayer newCfg.getCurrInfoPlayer();
            
string ident val.nameFunction;
            if (
currInfoPlayer == null)
                throw new 
GLScript.GLApp.GLScriptException("You can't use " ident " in this context, not a player event");
            
testArgs(ident"S"args);
            
currInfoPlayer.privateButtonCloseRegex(args[0].ToString());
        }
?>

then called like:

<?php 
Sub kGUIclose 
$KeyFlags$id )
    
$GUIprefix split$id,"_",);
    
closePrivButtonRegex ($GUIprefix ".*");
EndSub
?>


Last edited by Krayy, .
Krayy
S2 licensed
Quote from Yisc[NL] :I'm totaly sure but I think I made that a long time ago.
See attached script and sorry if you meant something different.

Ummm....who were you replying to?
Krayy
S2 licensed
I would like to see if it's possible to put in a function to do a CloseButton that accepts a regular expresion to specify the buttons to close. What I'm trying to do is create a generic function to create a set of buttons in a standard GUI format, and anohter function to close it. The creation code works fine, but the problem is that when I try to use a generic close function, I don't know what the names of the buttons that have been laid over the standard frame. If I can do something like 'ClosePrivButtonRegex("prefix_.*")' then that would enable me to close all of the buttons that use that prefix and make life a lot easier. Code below:


<?php 
Sub kGUICreate 
$userName$GUIprefix$origL$origT$GUIwidth$GUIHeight$GUItitle$showClose$secondsDisplayed)

    
# Draw window titles with Prev, Next and Close buttons
    
openButton $userName$GUIprefix "_bg",$origL-1,$origT-10,$GUIwidth+2,$GUIHeight+18,1,-1,16,"");
    
openButton $userName$GUIprefix "_title",$origL,$origT-10,$GUIwidth,10,5,-1,0,"^0" $GUItitle );

    IF (
$showClose == true)
    
THEN
        openButton 
$userName$GUIprefix "_close",81,$origT+$GUIHeight+1,38,6,8,-1,16,"^0[  Close This Dialog  ]",kGUIclose );
    ENDIF

    
# Draw the main contents window on top of the titles
    
openButton $userName$GUIprefix "_contents_bg",$origL,$origT,$GUIwidth,$GUIHeight,1,-1,32,"");

EndSub

Sub kGUIclose 
$KeyFlags$id )
    
$GUIprefix split$id,"_",);
    
closePrivButtonRegex ($GUIprefix);
EndSub
?>


PS: Also allow this for the new CloseButton function to do this for a nominated user
Krayy
S2 licensed
I'll do some modifications to my version later on as I wouldn't want it to do a DISMAL if someone is leaving the pits and it takes them ~20 secs to get up to speed, so I'll just drop the first test (longest time), then maybe cut the number of speed bands to 3 for AMAZING, GREAT and PEDESTRIAN.
Krayy
S2 licensed
Quote from Bass-Driver :hi
i'm make something that lapper change the track automaticly after 3 hours.
also i have made something that u can turn it off and on , so when u turn it off that the admin can change the track manualy or he need to turn ATC( AutoTrachChange) Off.

My Problem is:
when i turn it off it really doesnt work anymore so thats good.
but when i turn it back on it tried to end the race twice.
so RegisterScheduleAction Fuction still working if u turn it off,only the code doesnt work anymore

So i dont know if u can turn this off
Check attachment for the code

i Use version 5.845

I'll do something with your code tonight, but in the meanwhile, think about using the removescheduleaction function to emove the actions that you have scheduled when you turn autotrackchange off like this:

<?php 
Sub AutoTrackChangeOff
($KeyFlags,$id)
    IF(
$AutoTrackChange == "off")
    
THEN
    privMsg
"^7>ATC ALREADY TURNED ^1OFF!!!");
    ELSE
    
$AutoTrackChange "off";
    
RemoveScheduleActionSA_RotateTrack0 );
    
RemoveScheduleActionSA_RotateTrack3 );
    
RemoveScheduleActionSA_RotateTrack6 );
    
RemoveScheduleActionSA_RotateTrack9 );
    
RemoveScheduleActionSA_RotateTrack12 );
    
RemoveScheduleActionSA_RotateTrack15 );
    
RemoveScheduleActionSA_RotateTrack18 );
    
RemoveScheduleActionSA_RotateTrack21 );
    
cmdLFS("/msg ^7>" GetCurrentPlayerVar("Nickname") . "^7 Turned ATC ^1OFF!!!" );
    ENDIF
    
ClosePrivButton("ATCONOFF&ATCON&ATCOFF");
EndSub
?>


Krayy
S2 licensed
Quote from Gai-Luron :Hello,

Better method is registered action

Gai-Luron

Good point
Krayy
S2 licensed
Quote from Fire_optikz001 :is there a way to open a privbutton for a diffren user i have


<?php 
openPrivButton
$argv,"test2",160,15,35,5,5,-1,32$var1 );  
?>

but it does not work

Can you give us an example of how it should work?
Krayy
S2 licensed
You would be better to print the message (web site or whatever) when a particular event occurs, like a Race Start, or as the player leaves the pits. Have a look around the code for the events OnRaceStart, OnNewPlayerJoin, and OnConnect.

From a coding perspective however, here's how to do a recursive function:


<?php 
CatchEvent OnLapperStart
()
    
DelayedCommand120ShowAnnouncement );
EndCatchEvent

Sub ShowAnnouncement 
()
    
globalMsg"Visit our website at http://isntthisannoying.com");
    
DelayedCommand120ShowAnnouncement );
EndSub

?>


That will display the announcement every 2 mins and people will be compelled to visit your website that often, and do this -> :banghead:
PS: You will not be able to stop it.
Krayy
S2 licensed
Try this as a starting point. You may want to move the definitions into a global var, and maybe consolidate the time bands into one array, and the car names into another to streamline it a bit more.

Nice addon though...you okay for me to use it?
Krayy
S2 licensed
Quote from Backtrack3d :How could i make the lapper, or the server itself to where there is auto messages pop up on the screen, like say every minute. Things like your website, information, etc?

If someone could help me out with this, It would me much appricated.

It can be done fairly easily using Lapper, but here's why I won't tell you how:

If you're throwing pop ups every minute or two advertising a web site or something, then how are the players meant to race? People would get so annoyed with the pop ups that they won't want to race on your servers.
Krayy
S2 licensed
Quote from Fire_optikz001 :cant have 0 i need blank D:

As "" is not a valid number, then it will not stroe anything in the numeric database field. When you try to retrieve it using the GetUserStoredNum, as the stored value is not a valid number, then that function will return -1
Krayy
S2 licensed
Quote from Fire_optikz001 :ok i have a new problem in

SetUserStoredValue( $argv , "HC" , "" );
SetUserStoredValue( $argv , "Cash" , "" );
SetUserStoredValue( $argv , "Bank" , "" );
SetUserStoredValue( $argv , "KM" , "" );
SetUserStoredValue( $argv , "Energy" , "" );

found out it sets string value but not number value which is what the problem is :/

Store the variable using SetuserStoredValue, but retrieve it using GetUserStoredNum instead of GetUserStoredValue and it will come back as a number
FGED GREDG RDFGDR GSFDG