Page 1 of 2
[Solved] [Persitent] Keeping player data across ALL servers
Posted: 16 Jun 2015, 14:35
by Darkminus
Hi!
I've got a little problem.
I'm trying to keep one (or more) variable(s) linked to the player profile to make it available everywhere (<=> all servers running my gamemode), so I can re-use it to get the right parameter (In my case, a boolean to enable or not my custom HUD).
declaring a persistent variable in manialink work in local but doesn't work online as the value is resetted after a Maniaplanet reboot.
Anyone have a good way to do that kind of thing?
I hope I'm clear.. Thank you in advance
Law.
Re: [Persitent Data] Keeping player data across ALL servers
Posted: 16 Jun 2015, 14:58
by Farcry69
Hi !
I have an idea, but I think this is not very optimized and I don't know if it works !
You can probably put all linked variables in a database on your manialink.
And then load these variables from a config on your gamemode.
I will ask a friend for that, if I have a better answer, I come back here to explain it ^^
Good luck

Re: [Persitent Data] Keeping player data across ALL servers
Posted: 17 Jun 2015, 06:48
by Darkminus
Farcry69 wrote:Hi !
I have an idea, but I think this is not very optimized and I don't know if it works !
You can probably put all linked variables in a database on your manialink.
And then load these variables from a config on your gamemode.
I will ask a friend for that, if I have a better answer, I come back here to explain it ^^
Good luck

Hello
First of all, thank you for your answer !
However I'm not sure to understand it ^^" Did you mean that I should store those informations on a distant server, on an SQL database ? I suppose I'd need a servercontroller to bring them back to client, right?
I also tried to look at CustomUI.Script.txt which keeps settings for modes "modules" visibilities. It works online : for example if you hide chat or any module in Elite, your chat will be hidden on all Elite servers. But I couldn't find the "secret" ^^'
Have a nice day

Re: [Persitent Data] Keeping player data across ALL servers
Posted: 17 Jun 2015, 08:47
by Eole
The secret behind the CustomUI library are
persistent variables. Any persistent variable declared inside a manialink script will be saved and loaded on the client side.
Re: [Persitent Data] Keeping player data across ALL servers
Posted: 17 Jun 2015, 09:04
by Darkminus
Eole wrote:The secret behind the CustomUI library are
persistent variables. Any persistent variable declared inside a manialink script will be saved and loaded on the client side.
Hey,
Thanks for your answer.
That's what I tried to do yea, but it doesn't work when script runs from the dedicated server...
If I remember well, Manialinks runs on the client side. If persistent variables are saved/loaded on the clientside too, I don't understand why I don't get the right value only when I play on a dedicated server...
However, declaring persistent variables like in CustomUI.Script.txt works perfectly on a
local ingame server. Variable is saved and loads.
That's what I don't understand: What is the difference between ingame-servers and dedicated servers to load a persistent variable?
Re: [Persitent Data] Keeping player data across ALL servers
Posted: 17 Jun 2015, 09:38
by Eole
Does the CustomUI library work on dedicated servers? If yes then we're missing something.
Are you sure you declare your variables as persistent every time you want to access it? Always with the same exact name?
Re: [Persitent Data] Keeping player data across ALL servers
Posted: 17 Jun 2015, 10:02
by TGYoshi
Last time I checked, persistent data got lost/didn't save or something if you shut down through alt+f4 (much faster than going through 1000s of menus). Quitting the game the proper way made it all save, though. May be related.
Re: [Persitent Data] Keeping player data across ALL servers
Posted: 17 Jun 2015, 12:07
by Darkminus
Eole wrote:Does the CustomUI library work on dedicated servers? If yes then we're missing something.
Are you sure you declare your variables as persistent every time you want to access it? Always with the same exact name?
Yes, yes, and yes. I'm 100% sure of this.
TGYoshi wrote:Last time I checked, persistent data got lost/didn't save or something if you shut down through alt+f4 (much faster than going through 1000s of menus). Quitting the game the proper way made it all save, though. May be related.
Indeed I often use alt+F4 to leave. I'll try leaving the "correct" way to check if this could cause the problem.
Thank you guys

More informations this evening

Re: [Persitent Data] Keeping player data across ALL servers
Posted: 17 Jun 2015, 19:44
by Darkminus
Hello again!
I finally got it working ! That was a timing error. If I declare the variable in the Ml while loop instead of the beginning of the MlScript, it works as expected.
I suppose it worked in local because I'm on the server just when it starts.
Thanks for your help guys.
Have fun
Law.
Re: [Persitent Data] Keeping player data across ALL servers
Posted: 17 Jun 2015, 21:26
by oliverde8
Darkminus wrote:Hello again!
I finally got it working ! That was a timing error. If I declare the variable in the while loop instead of the beginning of the script, it works as expected.
I suppose it worked in local because I'm on the server just when it starts.
Thanks for your help guys.
Have fun
Law.
Hi, it should work even if you declare the variable in the beginning of the script.
Here is a slighty over complicated usecase:
https://github.com/eXpansionPluginPack/ ... cript.txtm
This is the declaration part just before the while, and here is the content of the while :
https://github.com/eXpansionPluginPack/ ... cript.txtm
I would like to point out that accessing value of a persistent variable is slow compared to other variables. When we started using them at least it was the case, therefore try and use a intermediate variable and update the value in that variable only every 10 loops or so depending on the usage you have of it of course.