The online racing simulator
Remaining Fuel Warning function request
Hi Gai

Just been trying your LFSRelax applications for 1st time..very good!

As part of this app, you have a function called EnableRemainFuel

This acts as a warning when your fuel will only last x more laps (change x to suit).

Could this function be added to lapper?
Hello,

No because, fuel info is only sended by LFS in outgauge and only for local player.
How about a new Event called OnChangePos that is executed if the players position changes in the MCI handler:


<?php 
...
                        if (
lastPos != currPos)
                        {
                            
PLIDChangePos.AddcurrInfoPlayer );
args[0] = currInfoPlayer.userName;
args[1] = lastPos;
args[2] = currPos;
newCfg.executeFunction("OnChangePos"currInfoPlayerargs);
                        }
...
?>

and then call it from a lapper script using:

<?php 
Event OnChangePos
$userName$lastPos$currPos # Player event

EndEvent
?>


Specifically, I want to expand the use of the Safety car so that I can determine if aplayer has passed another player and warn them to drop back to their original position before crossing the start/finish at race restart.

Also the text "Krayy takes the lead!" would look cool ;-)


Edit By Gai-Luron
DONE
Quote :
How about a new Event called OnChangePos that is executed if the players position changes in the MCI handler:


Specifically, I want to expand the use of the Safety car so that I can determine if aplayer has passed another player and warn them to drop back to their original position before crossing the start/finish at race restart.

+1

With this is it also posible to make a script for a rolling start.
Quote :With this is it also posible to make a script for a rolling start.

Can you explain more?
Using the Safety car updates that I am working on, it would be possible to do rolling starts. Basically the process would be:

1. Grid is at start with pacecar at pole
2. Race starts as per normal in pacecar mode. After the start, the ppacecar gets a stop/go penalty so it will enter pits at the end of teh start lap, and when it gets an "OnPitEnter", it will get spec'ed
3. In pacecar mode, racers are not allowed to pass each other, so we will store thier position at the start of the pacecar mode (in this case the grid order)
4. When a OnChangePos is raised when in pacecar mode, the racer will get a RCM telling them that they are out of position and must move forward/back a pos to get back in order
5. If the racers are out of order when they cross the line, they will receive a Drive Through penalty.
Log writing facility
Quote from Fire_optikz001 :better yet why not this:


<?php 
WriteToFile
("./report.txt""Fireoptikz did something naughty");

OR

WriteLineToFile("./report.txt""Fireoptikz did something naughty");

?>

what ever u like better

'Cos the idea is that the file written to would be a log file in the ./log directory, and the extension is superflous because it would always be .log (as least that's the idea...any extension should be ok, and can be set via a const)
Quote from Krayy :'Cos the idea is that the file written to would be a log file in the ./log directory, and the extension is superflous because it would always be .log (as least that's the idea...any extension should be ok, and can be set via a const)

well why does it half to be in the log file i think it would be cool if we could put it any where
i would like a thing for open privbutton that u can open it for a certain user like

<?php 
openButton
$argv"test2",160,15,35,5,5,-1,32$var1 ); #for another player
?>

Already exist. But it's better to use new version of LFSLapper because your it's not maintened yet

Gai-Luron
Where is option for this in new version?
What is the name?

Thx.
-
(Chacall Br) DELETED by Gai-Luron : Out of discussion
Use same database name in config file
is there a way you could add a random number generator Like


<?php 
$Start_Number 
1;
$End_Number 100;
privMsgRanNum$Start_Number,$End_Number ) ); # does not have to be in a privMsg
?>

i came up with


public void rannum(GLScript.unionVal val, ArrayList args)
{
string ident = val.nameFunction;
testArgs(ident, "SS", args);
int min = Convert.ToInt32(args[0]);
int max = Convert.ToInt32(args[1]);
Random random = new Random();
val.typVal = GLScript.typVal.str;
val.sval = utils.quote( Convert.ToString( random.Next(min, max) ) );
return;
}

IT WORKS!
Quote from Fire_optikz001 :is there a way you could add a random number generator Like


<?php 
$Start_Number 
1;
$End_Number 100;
privMsgRanNum$Start_Number,$End_Number ) ); # does not have to be in a privMsg
?>

i came up with


public void rannum(GLScript.unionVal val, ArrayList args)
{
string ident = val.nameFunction;
testArgs(ident, "SS", args);
int min = Convert.ToInt32(args[0]);
int max = Convert.ToInt32(args[1]);
Random random = new Random();
val.typVal = GLScript.typVal.str;
val.sval = utils.quote( Convert.ToString( random.Next(min, max) ) );
return;
}

IT WORKS!

also could u add an event for
// A player hits an autocross object
private void AXO_PlayerHitsAutocrossObject(Packets.IS_AXO AXO)
{
}

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
I'm not totaly sure but I think I made that a long time ago.
See attached script and sorry if you meant something different.
Attached files
schedule_rr.txt - 12.8 KB - 333 views
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?
Quote from Krayy :Ummm....who were you replying to?

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.
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
?>


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
?>


i would like to request this

<?php 
IF( FileExist"./file.txt") = 1)
THEN
PrivMsg
"File Exist" );
ELSE
PrivMsg"File Does not Exist" );
ENDIF
?>

and


<?php 
IF( contains($argv":" ) = )
THEN
PrivMsg
"You Cant have : in your argv" );
ENDIF
?>


FGED GREDG RDFGDR GSFDG