[Solved] [Persitent] Keeping player data across ALL servers

You can talk about ManiaScript for ManiaPlanet here

Moderator: English Moderator

User avatar
Darkminus
Posts: 228
Joined: 05 Jun 2012, 20:54
Location: Dans mon monde.
Contact:

[Solved] [Persitent] Keeping player data across ALL servers

Post 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 :thx:

Law.
Last edited by Darkminus on 17 Jun 2015, 19:45, edited 1 time in total.
Professor Law
ShootMania-addict since June 2012.
Arena Duel, Duel Elite V2, MidAir V2 and SDPro Developer

System Specs:
OS: Windows 10 Professionnal x64
CPU: Intel i5-4670
GPU: MSI TwinFrozr GTX 760 OC
Motherboard: Asus Z87-C
RAM : 10Gb
User avatar
Farcry69
Posts: 127
Joined: 08 Apr 2011, 17:20
Location: Lyon
Contact:

Re: [Persitent Data] Keeping player data across ALL servers

Post by Farcry69 »

Hi !

I have an idea, but I think this is not very optimized and I don't know if it works ! :D
You can probably put all linked variables in a database on your manialink.
And then load these variables from a config on your gamemode. :thumbsup:

I will ask a friend for that, if I have a better answer, I come back here to explain it ^^

Good luck :)
User avatar
Darkminus
Posts: 228
Joined: 05 Jun 2012, 20:54
Location: Dans mon monde.
Contact:

Re: [Persitent Data] Keeping player data across ALL servers

Post 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 ! :D
You can probably put all linked variables in a database on your manialink.
And then load these variables from a config on your gamemode. :thumbsup:

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 ! :thx:

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 ;)
Last edited by Darkminus on 17 Jun 2015, 09:05, edited 1 time in total.
Professor Law
ShootMania-addict since June 2012.
Arena Duel, Duel Elite V2, MidAir V2 and SDPro Developer

System Specs:
OS: Windows 10 Professionnal x64
CPU: Intel i5-4670
GPU: MSI TwinFrozr GTX 760 OC
Motherboard: Asus Z87-C
RAM : 10Gb
User avatar
Eole
Nadeo
Nadeo
Posts: 1265
Joined: 26 Apr 2011, 21:08

Re: [Persitent Data] Keeping player data across ALL servers

Post 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.
Contribute to the ManiaPlanet documentation on GitHub
A question about ManiaScript? Ask it here!
User avatar
Darkminus
Posts: 228
Joined: 05 Jun 2012, 20:54
Location: Dans mon monde.
Contact:

Re: [Persitent Data] Keeping player data across ALL servers

Post 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. :thx:

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?
Professor Law
ShootMania-addict since June 2012.
Arena Duel, Duel Elite V2, MidAir V2 and SDPro Developer

System Specs:
OS: Windows 10 Professionnal x64
CPU: Intel i5-4670
GPU: MSI TwinFrozr GTX 760 OC
Motherboard: Asus Z87-C
RAM : 10Gb
User avatar
Eole
Nadeo
Nadeo
Posts: 1265
Joined: 26 Apr 2011, 21:08

Re: [Persitent Data] Keeping player data across ALL servers

Post 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?
Contribute to the ManiaPlanet documentation on GitHub
A question about ManiaScript? Ask it here!
User avatar
TGYoshi
Posts: 795
Joined: 15 Mar 2011, 16:59

Re: [Persitent Data] Keeping player data across ALL servers

Post 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.
=3
User avatar
Darkminus
Posts: 228
Joined: 05 Jun 2012, 20:54
Location: Dans mon monde.
Contact:

Re: [Persitent Data] Keeping player data across ALL servers

Post 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 :thx: More informations this evening :)
Professor Law
ShootMania-addict since June 2012.
Arena Duel, Duel Elite V2, MidAir V2 and SDPro Developer

System Specs:
OS: Windows 10 Professionnal x64
CPU: Intel i5-4670
GPU: MSI TwinFrozr GTX 760 OC
Motherboard: Asus Z87-C
RAM : 10Gb
User avatar
Darkminus
Posts: 228
Joined: 05 Jun 2012, 20:54
Location: Dans mon monde.
Contact:

Re: [Persitent Data] Keeping player data across ALL servers

Post 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. :thx:

Have fun :yes:

Law.
Last edited by Darkminus on 18 Jun 2015, 10:34, edited 1 time in total.
Professor Law
ShootMania-addict since June 2012.
Arena Duel, Duel Elite V2, MidAir V2 and SDPro Developer

System Specs:
OS: Windows 10 Professionnal x64
CPU: Intel i5-4670
GPU: MSI TwinFrozr GTX 760 OC
Motherboard: Asus Z87-C
RAM : 10Gb
oliverde8
Posts: 1286
Joined: 16 Jun 2010, 07:33
Location: in a Blue Box

Re: [Persitent Data] Keeping player data across ALL servers

Post 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. :thx:

Have fun :yes:

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.
Image
Developper for The next generation, Clean and Powerfull controller eXpansion for your SM & TM server . Working on eXpansion² with full MP4 support and many other awesome features...
Post Reply

Return to “ManiaScript”

Who is online

Users browsing this forum: No registered users and 1 guest