The online racing simulator
[Solved]LFSLapper Auto Save
Hello LFS Community!

After almost "long" development of my cruise addon, I decided to release my "private" server to public and test how it would perform.

So far, 5 people got into the server and the auto-save was working perfectly fine; but after 5-6 players the auto-save refuses to save and gives an error saying:

".\default\.\includes\.\cruise.lpr" at line #1622
Time Out in Event or Sub 8000 ms
Function 'c_save' script aborted"


Yes, I changed the timeOutScript to timeOutScript=8000; But that seems doesn't help at all. My server reached 20 players and the stats just seem to fade away like nothing happened.

Not only that...

I have another big issue. "Of what i think"

#+-------------------------------+
#|On disconnect |
#+-------------------------------+

CatchEvent OnDisConnect( $userName, $reason )
#This is an example code of how the stats reset.
SetUserStoredValue("Cash", GetCurrentPlayerVar( "Cash" ) );
EndCatchEvent


When a player disconnects; this happens.

"You can't use GetCurrentPlayerVar in this context, not a player event
Function 'ondisconnect.\default\.\includes\.\cruise.lpr-430' script aborted"


Well... My auto-save saves the stats every 5 mins and 8 seconds because of the timeOutScript. But what about on disconnect ... ? :/

Any help is appreciated!

P.S: If you want screenshots of my cruise-addon just type down below!
I believe in SetUserStoredValue you missed a parameter.

I can't remember been 6 years since I used LFSLapper, but I think it should be SetUserStoredValue(User, Key, Value);

I'm assuming you're using code from my old Cruise plugin(function names line up, you're having the same issue as my old system had in the last release i made).
The reason you can't use "GetCurrentPlayerVar" in de OnDisConnect event is that as soon as the event is fired, the player has already left the server.
So Lapper isn't able to retrieve the value of that player anymore.
It would be better to make a "Logout" button in the HUD which is linked to a sub-routine that saves the value(s) and then disconnects the player.
Quote from T3charmy :I believe in SetUserStoredValue you missed a parameter.

I can't remember been 6 years since I used LFSLapper, but I think it should be SetUserStoredValue(User, Key, Value);

I'm assuming you're using code from my old Cruise plugin(function names line up, you're having the same issue as my old system had in the last release i made).

Exactly!! I wouldn't have done anything without your old cruise plugin! Big grin
Anyways, about the parameter, i'll give it a shot, thanks!
Quote from Yisc[NL] :The reason you can't use "GetCurrentPlayerVar" in de OnDisConnect event is that as soon as the event is fired, the player has already left the server.
So Lapper isn't able to retrieve the value of that player anymore.
It would be better to make a "Logout" button in the HUD which is linked to a sub-routine that saves the value(s) and then disconnects the player.

Ah yea, I do vaguely remember that being an issue now... I think that was one of the reasons I moved away from LFSLapper... that and the lack of updates at the time.

Quote from AymanHilal :Exactly!! I wouldn't have done anything without your old cruise plugin! Big grin
Anyways, about the parameter, i'll give it a shot, thanks!

As Yisc said, I don't think it will work, but you can try.
Easy fix!! Who said i need a button to save stats, it turns out that c_save function needed some adjustment, and there's no need for auto-save! Come on, Big grin LFSLapper can hold a lot of stuff and I already almost squeezed in a full cruise in a lapper without performance issues thanks to @Bass-Driver with his little help of Lapper modification. Big grin

I will hopefully release some screenshots of my cruise addon.
This thread is closed

FGED GREDG RDFGDR GSFDG