The online racing simulator
Searching in All forums
(446 results)
Krayy
S2 licensed
Quote from Fire_optikz001 :is there somthing like GetListOfPlayers( ) but for on track?


<?php 
 
FOREACH ($Racer in getListOfPlayers())
IF (
GetPlayerVar($Racer"ontrack"))
THEN
   globalmsg
$Racer " is currently in a race");
ENDIF
ENDFOREACH
?>

In other words, the "ontrack" player variable is set when the player is in a race
Krayy
S2 licensed
Quote from Fire_optikz001 :ok now lets say a user did !chat hey whats up dude hows it been....

insim would endup cutting of message i was wondering if there is a way to make it split lines after so many charecters

was wondering it i could do like

$argv2 = substr($argv,30, strlen($argv));

the second paramter of the substr function is the numeric start point, the third is the last, so yes that would show every thing in the string from character 30.

You can also use the indexOf function to find the first occurence of a particular character in a string like this:

<?php 
    $idxOfFirtsSpace 
indexOf$text" ");
$argv2 substr($argv,$idxOfFirtsSpace strlen($argv));
?>

In fact, this is doen all the time in processing the command strings in the OnMSO Event in the .lpr files like this:

<?php 
    
IF( $idxOfFirtsSpace == -THEN
      $command 
$text;
      
$argv "";
    ELSE
      
$command subStr$text,0,$idxOfFirtsSpace );
      
$argv trimsubStr$text,$idxOfFirtsSpace ) );
    ENDIF
?>

Krayy
S2 licensed
Updated to ver 1.0.2 for Lapper 5.924
Krayy
S2 licensed
Quote from Fire_optikz001 :how do u (if possible) remove the fisrt X number of letters from a string so like Chat_tatata would be just tatata

Use a combination of "strlen" and "substr" like this:


<?php 
$oldstr
="Chat_tatata";
$newstr substr($oldstr,5strlen($oldstr));
?>

That would make $newstr the part of $oldstr from character 5 to the end of the string
Krayy
S2 licensed
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)
Log writing facility
Krayy
S2 licensed
A GL function to allow the writing of data to a log file.

See post http://www.lfsforum.net/showthread.php?p=1354403#post1354403 fro details
Krayy
S2 licensed
What would be handy here is a GLScript function to log a line of text to a file in the ./logs directory. So if it was called like:

<?php 
Log
("report""Fireoptikz did something naughty");
?>

then there would now be a line written to the file ./logs/report.log with the text:
1/15/2010 11:07:48 PM -> Fireoptikz did something naughty

(Customised with your own text format etc) This owuld alos be good for DEBUG information to a debug.log file, recording log ins, disconnects etc.

How about it Gai?
Krayy
S2 licensed
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.
Selecting AI cars
Krayy
S2 licensed
Okies,

You can specify a particular ai to join the rcae using "/ai [name]", but is there any way to make an AI select a different car to the user who invokes it (like an XFG if we are running TBO class).
Krayy
S2 licensed
Updated to support Lapper v 5.923+
Krayy
S2 licensed
Quote from YamaSuba.NL :...
Loads of work.. Also disconnects, spectates, pit etc. should be taken in account then.

Here's a starting point for you. I'm using this in one of my addons, so if you do decide to use it, please change tha var and Sub names.
Krayy
S2 licensed
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
Last edited by Gai-Luron, .
Krayy
S2 licensed
Quote from Fire_optikz001 :is there a way to strip colors from anything?

like Strip( GetCurrentPlayerVar("NickName") );

Gai would have to write a GL callable function to pass and return the string to the stripLFSColor function.
Krayy
S2 licensed
Quote from Gai-Luron :In console window when you use writeline

The problem there is that you will need to convert the color codes (^7 etc) to ANSI color codes, which is a pain in the arse. Just write the output using the NickNameStripped player var which has the color codes already removed.
Krayy
S2 licensed
Quote from YamaSuba.NL :That definitely would work for determining the fastest racelap and the player that drove it, but it's not quite what I need..
This determination should be followed by adding a point to this player's score, which is stored in the database. And that won't be possible in a following lapperevent like the next racestart, when using the SetUserStoredValue.
For that to work one should know who's the last finisher in order to make the fastest-racelap final, and that's a bit hard to determine.
That's the reason I chose to use a delayed command..

Using a delayed event would never work as a player might just stop halfway around or crash etc and never finish. You either need to choose an arbitrary point such as a restart to apply points (what CTRA did), or you can go the whole hog and use a counter. As the race starts, use the NumP to set the number of racers. Increase the counter by 1 when a new player joins (but not after the first person has finished). When a player finishes (OnResult), decrease the counter. When it hits 0, the race is over.

PS: I use the SetStoredValue instead of setUserToredValue, as this will exists even when a user has disconnected
Last edited by Krayy, .
Krayy
S2 licensed
When the race starts, do this:

<?php 
CatchEvent OnRaceStart
$NumP # Lapper event
   
SetStoredValue "RacePB""0;NULL");
EndCatchEvent
?>


Store the users PBs each lap similar to this (note that thgis is for one of my addons, so will require you to muck about with var names, initial settings etc):

<?php 
CatchEvent OnLap
$userName # Player event
    # Update the PB if the current lap is faster than the PB
    
$EventLapPB GetUserStoredValue ("EventLapPB");
    
$CurrLapTime GetCurrentPlayerVar ("LapTime");
    IF ( 
ToNum($EventLapPB) < || ToNum($CurrLapTime) < ToNum($EventLapPB) )
    
THEN
        SetUserStoredValue 
"EventLapPB"$CurrLapTime);
    ENDIF
EndCatchEvent
?>


As part of the OnResult function, do something like this:


<?php 
CatchEvent OnResult
$userName,$flagConfirm # Player event
    
$EventLapPB GetUserStoredValue ("EventLapPB");
   
$RacePB GetStoredValue "RacePB");
   
$BestTime split$RacePB,";",);
   IF ( 
ToNum($EventLapPB) < ToNum($BestTime) )
      
SetStoredValue "RacePB"$EventLapPB ";" $userName);
   ENDIF
EndCatchEvent
?>


Now the stored var RacePB will contain the PB and username, seperated with a semi-colon. Now you can query that to display the fastest time when doing a race restart or other event.

NB: As mentioned, this code is hacky since I'm at work and don't have much time, but thats essentially the eway I'm doing it.
Send IS_CPP packets when LFS hosted on dedicated server
Krayy
S2 licensed
As discussed in the thread http://www.lfsforum.net/showthread.php?t=65036 I think it would be a good addition to be able to get IS_CPP packets sent when the host is a dedicated server, and also IS_CCH packets when a user hits the Tab key or changes view (V) when viewing another player. At present when using a deidcated host, you get an IS_CCH packet when chnaging local view or using Tab to view another player, but you only get the packet once until you return to your local view. So we can tell if you are viewing someone else, but not whom.

The reason for this is so that we can create InSim applications that can determine what car a player is viewing (ViewPLID in IS_CPP) so that we can display information to the viewing player about the viewed player such as split times, F1 style gap and lap counters etc. This would be particularly useful if we are allowing spectators into the rcae server.
Krayy
S2 licensed
Quote from morpha :Well right now I can only think of one reliable way: If UCID 0 has a UName, it's a client, otherwise a dedi.

Ta. So just to clarify what you've said...if the Host is a dedicated server, then there is no way to get an IS_CPP packet for any Player and therefore no way to see who that Player is viewing (ViewPLID)?

The only thing we can determine (via the IS_CCH that is sent when the users view changes) is that they are viewing someone other than thenselves?
Krayy
S2 licensed
Quote from morpha :The dedicated server doesn't actively run the simulation, it doesn't "view" any player at all. There is no way to get this to work with a dedi and there's no alternative to achieve the same

Dang. That is seriously annoying

I'll just make it so that you get extra functionality if the host is run on a client rather than a dedicated server.

The question is, how do you tell if you are connected to a dedi host rather than a client based host?
Krayy
S2 licensed
Quote from DarkTimes :Was worried this might be a bug with the Sniffer so I checked it out, but it works perfectly for me. I connect to LFS, join a race, go to Request > TINY_SCP, and LFS immediately replies with a IS_CPP. How are you trying to get it to work?

In terms of changing cameras, although the IS_CPP isn't sent all the time, each time I change views a IS_STA is sent, which has the ViewPLID of the driver I'm watching.

If I'm using the LFS client to start a new host then starting an InSim session, then the IS_CPP packets are sent when requesting a TINY_SCP. Also any view change does generate an IS_STA when viewing another player or AI.

However, I get no STA,or CPP packets if I run a Dedicated host and then attach the Sniffer and the Client to it. Could you please start a Dedicated host, then use the Sniffer and a Client to see if that works for you?
IS_CPP & IS_CCH...bug or feature
Krayy
S2 licensed
Hi guys,

I'm writing an add-on to LFS Lapper and am having trouble working out how to determine which PLID a player is viewing. What I am trying to do is to capture the ViewPLID from the IS_CPP packet, but have run into a view problems.

First is how to actually get LFS to send an IS_CPP packet. The docs say to send an IS_TINY with a SubT of TINY_SCP, but I cannot for the life of me get LFS to respond to that packet (using the InSimSniffer tool). If anyone has a working example of how to get an IS_CPP sent, that would be appreciated.

Secondly, to determine if the player is viewing a different user, I'm looking at using the IS_CCH packet to determine that a view change has occurred. The problem is that when using the Tab key to switch players, an IS_CCH is generated when you first move away from your PLID, but never for any subsequent Tabs. So you know that the View has shifted to another player only once, and if someone is tabbing like heck, you cannot capture those events. Is this a bug in the IS_CCH method, or by design?

If it's by design, then I suppose I have to poll the player a few times a second to get an IS_CPP packet to see who they are viewing and adjust the output accordingly, but see problem above on how to get an IS_CPP packet sent back.

Any help would be appreciated.
Krayy
S2 licensed
Quote from Fire_optikz001 :is there a way to add it so that Lost conection and timed outs are not classified as dissconect like make a new ec=event for timing out/Lost connection

The InSim docs describe the following reasons for a session disconnect:

// Leave reasons

enum
{
LEAVR_DISCO, // 0 - disconnect
LEAVR_TIMEOUT, // 1 - timed out
LEAVR_LOSTCONN, // 2 - lost connection
LEAVR_KICKED, // 3 - kicked
LEAVR_BANNED, // 4 - banned
LEAVR_SECURITY, // 5 - OOS or cheat protection
LEAVR_NUM
};

Currently Lapper executes the OnDisConnect function but only supplies the Username as an argument. If Gai can add another argument that is the reason number of the disconnect, then you could use a CASE/SWITCH statement to do different things when a disconnect occurs.
Last edited by Krayy, .
Krayy
S2 licensed
If you're going to update this, could you please remove the lines that force the laps/weather/quali etc to the defaults when lapper restarts as it is a pain in the butt. Or at least make it a selectable option tat can be stored in the DB (using setstoredvar).

If you need a hand on doing that, I'm happy to lend it.
Krayy
S2 licensed
This also raises the pproblem of maintenance. If there is one large lang file with all the language definitions in it, then if someone changes a module to have a slightly different text, then its a global update rather than just their .lpr module. If a user wants to have a spearate file, then it is a very simple matter to just cut & paste the Lang sections of a number of lapper files out if they are kept at the end of the modules.

I agree with keeping things tidy, but in reality you should never need to move the Lang sections out of the main files for anything other than to segregate them, as it makes no operational difference to lapper.

Also, module makers should look at chnaging their language definitions to <module>_<name> instead of main_<name> to differentiate between the main lapper definitions and their custom ones. This would also aid in debugging so that we could track down any typographic errors faster.
Last edited by Krayy, .
Krayy
S2 licensed
Found the problme and it's a bug in the parser. After the last lang item, but before the EndLang statement, include a blank line or two and also 1 afterwards. The parser expects another line before/after the EndLang statement to reset its token (technical bit):


<?php 
...
    
built_lapsdone "Runder gjort";

EndLang

?>


FGED GREDG RDFGDR GSFDG