The online racing simulator
Config help
(1112 posts, closed, started )
I don't think because i don't know in advance if the result is too big from stored file to put in arraylist. This risk to freeze LFSLapper.

I don't understand why you can't use userStoredValue. Can you explain me more and why private delayed command. Maybe there is an another solution to your problem if you explain it accurately.

Thank's
Quote from Gai-Luron :I don't understand why you can't use userStoredValue. Can you explain me more and why private delayed command. Maybe there is an another solution to your problem if you explain it accurately.

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.
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.
Quote from Krayy :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.

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

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

SetUserStoredValue( $uName, $id, $value);

$uName is the username of the player

Gai-Luron
Quote from Krayy :Using a delayed event would never work as a player might just stop halfway around or crash etc and never finish.

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.

Quote from Krayy :You either need to choose an arbitrary point

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

Quote from Krayy :use a counter.

Loads of work.. Also disconnects, spectates, pit etc. should be taken in account then.

Quote from Krayy :PS: I use the SetStoredValue instead of setUserToredValue, as this will exists even when a user has disconnected

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..
Quote from Gai-Luron :If you have player username, lapPB, you can use setUserStoredValue with this value in a delayed command.

Been there, done that.. ;-)
I've tried this before and that would be my preferred call, but Lapper tells me the setUserStoredValue can't be used in a lapper-event..
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.
Attached files
race_in_progress.txt - 2 KB - 198 views
hi

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 :


Event OnConnect() # Player event

UserGroupFromFile( "Drivers", "./User/Drivers/" . $userName . ".txt" );

IF( UserInGroup( "Drivers" , "$userName.txt" ) == 1 )
THEN
MoveUserToGroup( "Drivers" . $userName,"Joined the server @ ====>>> (" . GetLapperVar("LongDate") . " - " . GetLapperVar("LongTime") . ")" );
privMsg( "^7>Welcome Back" . GetCurrentPlayerVar( "Nickname" ));
privMsg( "^7>Enjoy your stay!!");
ELSE
MoveUserToGroup( "Drivers" . $userName,"Joined the server for the 1st time @ ====>>> (" . GetLapperVar("LongDate") . " - " . GetLapperVar("LongTime") . ")" );
SaveGroupToFile( "Drivers" . $userName, "./User/Drivers/" . $userName . ".txt" );
privMsg( "^7>Welcome in our server!!" );
privMsg( "^7>Enjoy your stay" );
cmdLFS("/msg ^7>" . GetCurrentPlayerVar("Nickname") . " ^7Is a new Driver in this server");
ENDIF

Quote from YamaSuba.NL :Been there, done that.. ;-)
I've tried this before and that would be my preferred call, but Lapper tells me the setUserStoredValue can't be used in a lapper-event..

Yes and that's a bug, sorted soon

Gai-Luron
Quote from Bass-Driver :

Event OnConnect() # Player event

UserGroupFromFile( "Drivers", "./User/Drivers/" . $userName . ".txt" );

IF( UserInGroup( "Drivers" , $userName ) == 1 )
THEN
MoveUserToGroup( "Drivers" . $userName,"Joined the server @ ====>>> (" . GetLapperVar("LongDate") . " - " . GetLapperVar("LongTime") . ")" );
privMsg( "^7>Welcome Back" . GetCurrentPlayerVar( "Nickname" ));
privMsg( "^7>Enjoy your stay!!");
ELSE
MoveUserToGroup( "Drivers" . $userName,"Joined the server for the 1st time @ ====>>> (" . GetLapperVar("LongDate") . " - " . GetLapperVar("LongTime") . ")" );
SaveGroupToFile( "Drivers" . $userName, "./User/Drivers/" . $userName . ".txt" );
privMsg( "^7>Welcome in our server!!" );
privMsg( "^7>Enjoy your stay" );
cmdLFS("/msg ^7>" . GetCurrentPlayerVar("Nickname") . " ^7Is a new Driver in this server");
ENDIF


Fixed
Quote from Gai-Luron :Yes and that's a bug, sorted soon

Already done, as I see.. Super, many thanks!
Quote from Krayy :Here's a starting point for you.

Thanks, will definitely have a look at it!

Event OnConnect() # Player event

UserGroupFromFile( "Drivers" . $userName, "./User/Drivers/" . $userName . ".txt" );

IF( UserInGroup( "Drivers" . $userName , $userName ) == 1 )
THEN
MoveUserToGroup( "Drivers" . $userName,"Joined the server @ ====>>> (" . GetLapperVar("LongDate") . " - " . GetLapperVar("LongTime") . ")" );
SaveGroupToFile( "Drivers" . $userName, "./User/Drivers/" . $userName . ".txt" );
privMsg( "^7>Welcome Back" . GetCurrentPlayerVar( "Nickname" ));
privMsg( "^7>Enjoy your stay!!");
ELSE
MoveUserToGroup( "Drivers" . $userName,"Joined the server for the 1st time @ ====>>> (" . GetLapperVar("LongDate") . " - " . GetLapperVar("LongTime") . ")" );
MoveUserToGroup( "Drivers" . $userName,$userName );
SaveGroupToFile( "Drivers" . $userName, "./User/Drivers/" . $userName . ".txt" );
privMsg( "^7>Welcome in our server!!" );
privMsg( "^7>Enjoy your stay" );
cmdLFS("/msg ^7>" . GetCurrentPlayerVar("Nickname") . " ^7Is a new Driver in this server");
ENDIF

there
Quote from Fire_optikz001 :

Event OnConnect() # Player event

UserGroupFromFile( "Drivers" . $userName, "./User/Drivers/" . $userName . ".txt" );

IF( UserInGroup( "Drivers" . $userName , $userName ) == 1 )
THEN
MoveUserToGroup( "Drivers" . $userName,"Joined the server @ ====>>> (" . GetLapperVar("LongDate") . " - " . GetLapperVar("LongTime") . ")" );
SaveGroupToFile( "Drivers" . $userName, "./User/Drivers/" . $userName . ".txt" );
privMsg( "^7>Welcome Back" . GetCurrentPlayerVar( "Nickname" ));
privMsg( "^7>Enjoy your stay!!");
ELSE
MoveUserToGroup( "Drivers" . $userName,"Joined the server for the 1st time @ ====>>> (" . GetLapperVar("LongDate") . " - " . GetLapperVar("LongTime") . ")" );
MoveUserToGroup( "Drivers" . $userName,$userName );
SaveGroupToFile( "Drivers" . $userName, "./User/Drivers/" . $userName . ".txt" );
privMsg( "^7>Welcome in our server!!" );
privMsg( "^7>Enjoy your stay" );
cmdLFS("/msg ^7>" . GetCurrentPlayerVar("Nickname") . " ^7Is a new Driver in this server");
ENDIF

there

thx it works now

but now i have another lil problem
i have add some of this code to the !report command and that works to but it doesnt save it well

reported by==>> bass-driver (friday 15 january 2010 - 10:41:44 pm)
reported by==>> bass-driver (friday 15 january 2010 - 10:44:40 pm)
reported by==>> bass-driver (friday 15 january 2010 - 10:43:18 pm)
reported by==>> bass-driver (friday 15 january 2010 - 10:41:39 pm)
reported by==>> bass-driver (friday 15 january 2010 - 10:41:48 pm)
how are u
i'm testing lapper
reported by==>> bass-driver (friday 15 january 2010 - 10:41:46 pm)
reported by==>> bass-driver (friday 15 january 2010 - 10:42:54 pm)
reported by==>> bass-driver (friday 15 january 2010 - 10:41:54 pm)
reported by==>> bass-driver (friday 15 january 2010 - 10:41:42 pm)
reported by==>> bass-driver (friday 15 january 2010 - 10:41:38 pm)
hello
reported by==>> bass-driver (friday 15 january 2010 - 10:45:14 pm)
reported by==>> bass-driver (friday 15 january 2010 - 10:41:41 pm)
reported by==>> bass-driver (friday 15 january 2010 - 10:43:06 pm)
reported by==>> bass-driver (friday 15 january 2010 - 10:41:47 pm)


The dates are in the wrong way and it doenst write the reason(!report User Reason) on some points
Quote from Bass-Driver :thx it works now

but now i have another lil problem
i have add some of this code to the !report command and that works to but it doesnt save it well

reported by==>> bass-driver (friday 15 january 2010 - 10:41:44 pm)
reported by==>> bass-driver (friday 15 january 2010 - 10:44:40 pm)
reported by==>> bass-driver (friday 15 january 2010 - 10:43:18 pm)
reported by==>> bass-driver (friday 15 january 2010 - 10:41:39 pm)
reported by==>> bass-driver (friday 15 january 2010 - 10:41:48 pm)
how are u
i'm testing lapper
reported by==>> bass-driver (friday 15 january 2010 - 10:41:46 pm)
reported by==>> bass-driver (friday 15 january 2010 - 10:42:54 pm)
reported by==>> bass-driver (friday 15 january 2010 - 10:41:54 pm)
reported by==>> bass-driver (friday 15 january 2010 - 10:41:42 pm)
reported by==>> bass-driver (friday 15 january 2010 - 10:41:38 pm)
hello
reported by==>> bass-driver (friday 15 january 2010 - 10:45:14 pm)
reported by==>> bass-driver (friday 15 january 2010 - 10:41:41 pm)
reported by==>> bass-driver (friday 15 january 2010 - 10:43:06 pm)
reported by==>> bass-driver (friday 15 january 2010 - 10:41:47 pm)


The dates are in the wrong way and it doenst write the reason(!report User Reason) on some points

u want reason?

if so here is my report code


<?php 
                
CASE "!report":
                                IF( 
$argv != "" THEN
                    $idxSpace 
indexOf$argv" ");
                    IF( 
$idxSpace != -THEN
                        $user 
subStr$argv,0,$idxSpace );
                        
$argv trimsubStr$argv,$idxSpace ) );
   
MoveUserToGroup"report" $user,"Report by " $userName " (" GetLapperVar("ShortDate") . " - " GetLapperVar("LongTime") . ") " $argv );
   
UserGroupToFile"report" $user"./../user/" $TFD "/report/" $user ".txt" );
        
privMsg"Report Has Been Submited" );
         
$RMSG "Reported: " $user " | What For: " $argv;
                    
#Report ("tempadmin");
                    
ELSE
                        
privMsg"Command needs more parameters" );
                    ENDIF
                ENDIF
   BREAK;
?>

EXAMPLE !report TEST TEST


report by fire_optikz001 (15/01 - 4:21:55 pm) test

Quote from Fire_optikz001 :u want reason?

if so here is my report code


<?php 
                
CASE "!report":
                                IF( 
$argv != "" THEN
                    $idxSpace 
indexOf$argv" ");
                    IF( 
$idxSpace != -THEN
                        $user 
subStr$argv,0,$idxSpace );
                        
$argv trimsubStr$argv,$idxSpace ) );
   
MoveUserToGroup"report" $user,"Report by " $userName " (" GetLapperVar("ShortDate") . " - " GetLapperVar("LongTime") . ") " $argv );
   
UserGroupToFile"report" $user"./../user/" $TFD "/report/" $user ".txt" );
        
privMsg"Report Has Been Submited" );
         
$RMSG "Reported: " $user " | What For: " $argv;
                    
#Report ("tempadmin");
                    
ELSE
                        
privMsg"Command needs more parameters" );
                    ENDIF
                ENDIF
   BREAK;
?>

EXAMPLE !report TEST TEST


report by fire_optikz001 (15/01 - 4:21:55 pm) test


k ill see the reasonmessage for eachreport now, but the time is still wrong
btw its create 1 file for each reported user and not for example 10 files for 1 reported user

command !report Bass-Driver vdvv

report by: bass-driver (15/01/2010 - 11:33:12 pm) vdvv
report by: bass-driver (15/01/2010 - 11:33:59 pm) vdvv
report by: bass-driver (15/01/2010 - 11:34:04 pm) vdvv
report by: bass-driver (15/01/2010 - 11:32:57 pm) d
report by: bass-driver (15/01/2010 - 11:34:06 pm) vdvv
report by: bass-driver (15/01/2010 - 11:33:06 pm) fgfg
report by: bass-driver (15/01/2010 - 11:34:02 pm) vdvv
report by: bass-driver (15/01/2010 - 11:34:01 pm) vdvv
Quote from Bass-Driver :k ill see the reasonmessage now but the time is still wrong
btw its create 1 file for each reported user and not for example 10 files for 1 reported user

command !report Bass-Driver vdvv

report by: bass-driver (15/01/2010 - 11:33:12 pm) vdvv
report by: bass-driver (15/01/2010 - 11:33:59 pm) vdvv
report by: bass-driver (15/01/2010 - 11:34:04 pm) vdvv
report by: bass-driver (15/01/2010 - 11:32:57 pm) d
report by: bass-driver (15/01/2010 - 11:34:06 pm) vdvv
report by: bass-driver (15/01/2010 - 11:33:06 pm) fgfg
report by: bass-driver (15/01/2010 - 11:34:02 pm) vdvv
report by: bass-driver (15/01/2010 - 11:34:01 pm) vdvv

how is time wrong?

also why would u want more then 1 file?
Quote from Fire_optikz001 :how is time wrong?

also why would u want more then 1 file?

it normally looks like this and not like the previous post
i dont know how to explane it in english sry

report by: bass-driver (15/01/2010 - 11:32:57 pm) d
report by: bass-driver (15/01/2010 - 11:33:06 pm) fgfg
report by: bass-driver (15/01/2010 - 11:33:12 pm) vdvv
report by: bass-driver (15/01/2010 - 11:33:59 pm) vdvv
report by: bass-driver (15/01/2010 - 11:34:04 pm) vdvv
report by: bass-driver (15/01/2010 - 11:34:02 pm) vdvv
report by: bass-driver (15/01/2010 - 11:34:06 pm) vdvv
report by: bass-driver (15/01/2010 - 11:34:10 pm) vdvv

and about the files that was not a question thats what i made.

if the reported user already exist then write the reportreason in the same file.
if it the reported user not exist then made a new file incl the reportreason.
Quote from Bass-Driver :it normally looks like this and not like the previous post
i dont know how to explane it in english sry

report by: bass-driver (15/01/2010 - 11:32:57 pm) d
report by: bass-driver (15/01/2010 - 11:33:06 pm) fgfg
report by: bass-driver (15/01/2010 - 11:33:12 pm) vdvv
report by: bass-driver (15/01/2010 - 11:33:59 pm) vdvv
report by: bass-driver (15/01/2010 - 11:34:04 pm) vdvv
report by: bass-driver (15/01/2010 - 11:34:02 pm) vdvv
report by: bass-driver (15/01/2010 - 11:34:06 pm) vdvv
report by: bass-driver (15/01/2010 - 11:34:10 pm) vdvv

and about the files that was not a question thats what i made.

if the reported user already exist then write the reportreason in the same file.
if it the reported user not exist then made a new file incl the reportreason.

yes so does mine
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?
Quote from Krayy :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?

i have something like this but this would be alot better ...
how do u (if possible) remove the fisrt X number of letters from a string so like Chat_tatata would be just tatata
This thread is closed

Config help
(1112 posts, closed, started )
FGED GREDG RDFGDR GSFDG