It's just like I already said, I actually have used the userStoredValue and experienced a problem with that.
It's like this: in order to award a point to the racer that did the fastest racelap, I saved the laptime and username everytime someone completed a lap and was faster than the previously saved laptime.
Because I couldn't determine the player that drove the fastest racelap when the first one finished (after that one there still could finish a player with a new fastest lap), I had to use a delayed command with a delay of about a laplength.
I used a PrivDelayedCommand for that purpose, storing the points-info in the fi_user_value, this PrivDelayedCommand was launched at the OnResult for the first finished player (finishedpos = 1).
The problem that occured was that when this first finished player was in the pitbox at the time the delayed command was due to be executed, nothing happened, i.e. this command wasn't executed. Did this player get out of the pitbox before the expiry of the delaytime, everything resumed as planned. But not when being IN the box...
After that I also tried to use a DelayedCommand in stead of a PrivDelayedCommand, using SetUserStoredValue with the usage of the userName-option, but that didn't work because that was only usable in a playerevent, whilest the DelayedCommand issued a lapperevent.
And that forced me to store the data in the fi_stored table..
This however could create a possible solution I guess, when this command would also be usable in a lapperevent.Since you have to provide the userName, it would be perfectly suited to be used in a non-playerevent..
If that could be made possible (or if this pitbox-issue could be easily resolved/avoided, of course) that would make me very happy.
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) < 1 || ToNum($CurrLapTime) < ToNum($EventLapPB) ) THEN SetUserStoredValue ( "EventLapPB", $CurrLapTime); ENDIF EndCatchEvent ?>
As part of the OnResult function, do something like this:
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
If you have player username, lapPB, you can use setUserStoredValue with this value in a delayed command. SetUserStoredValue can take an optional value that was the username and in this case you can use it in delayed Command. Use setUserStoredValue is the good storage you need if you want use topuser
That's not a problem.. This delayed command is only launched by the first player that crosses the finishline, or rather: that is getting a result. The fastest lap is saved per lap, so that's still available at the moment the delay expires.
The delay started at the moment the first result comes in, provides for that. A restart wouldn't be a good point, I think, because there might not be one. If everyone logs off after finishing the race, for instance..
Loads of work.. Also disconnects, spectates, pit etc. should be taken in account then.
Me too, but that one has the drawback that no easy !top-like list can be derived of that. And that's exactly the reason for my question..
i'm try to make a code , that lapper makes a new file for each new player in the server.
the code works but when the user disconnect and it comes back it still says : Username Is a new Driver in this server
i think the bug is : IF( UserInGroup( "Drivers" , "$userName.txt" ) == 1 )
but see the code below :