Page 1 of 1

How could i force MTserver reload one player's invetory data

PostPosted: Thu May 29, 2014 12:17
by linushsao
As title,i mean when player A login,server will reload player A's inventorydata from folder .minetest/PLAYER/playerA. i had check Category:Methods, but seems no method could do this,or i miss?

Re: How could i force MTserver reload one player's invetory

PostPosted: Thu May 29, 2014 13:17
by sfan5
linushsao wrote:As title,i mean when player A login,server will reload player A's inventorydata from folder .minetest/PLAYER/playerA. i had check Category:Methods, but seems no method could do this,or i miss?

Restarting the server is currently the only way to reload the data from the player file.

Re: How could i force MTserver reload one player's invetory

PostPosted: Thu May 29, 2014 13:46
by linushsao
tks, actually i try to sync player's inventory stuffs (folder "PLAYER")between two worlds .

"mount --bind" can link two folder,but server load player's data and keep in RAM when starting, till player is logout,server save data from RAM to physical disk.

the problem is,for example two servers are running:

1.when player A login SERVER-A,craft something and logout.in Server-A,data of player A has change and save to disk.
2.but Server-B still keep old data in RAM,when player A login Server-B,he/she has old stuffs before crafting in Server-A

that's why i try to figure out this issue, if some method could help me to force server reload player's data when player login,player's data could reflash in RAM,so i can sync player's data between two worlds,no need to restart server again and again.

Re: How could i force MTserver reload one player's invetory

PostPosted: Thu May 29, 2014 18:59
by Krock
Why the hell do you use 2 servers on 1 player folder?
That's never a good idea.
Btw: player data also saves all <map_save_interval> seconds.

Re: How could i force MTserver reload one player's invetory

PostPosted: Fri May 30, 2014 08:02
by linushsao
Krock wrote:Why the hell do you use 2 servers on 1 player folder?
That's never a good idea.
Btw: player data also saves all <map_save_interval> seconds.


Just think about that,we live in the earth,we practice our skill,and we can go to other planets(not peaceful) for adventure by star gate or something.ServerA is peaceful like earth,ServerB is the other planet.when you leave earth to other planet for adventure,you will need to bring some tools and weapons .

Now my ServerB is the game Lord of the Ring...XD

Re: How could i force MTserver reload one player's invetory

PostPosted: Fri May 30, 2014 08:53
by rubenwardy
You could make a mod to change the player's inventory when they log in, syncing it. The mod could read from a shared file or daemon somewhere.

No need to edit players/*

Re: How could i force MTserver reload one player's invetory

PostPosted: Fri May 30, 2014 09:36
by linushsao
rubenwardy wrote:You could make a mod to change the player's inventory when they log in, syncing it. The mod could read from a shared file or daemon somewhere.

No need to edit players/*


tkx, rubenwardy. i do'nt know if my point is correct or not.but i think it's the same by my way to sync folder or by mod to sync inventory. Because the running server keep player's inventory data in ram while starting. we can make a mod to change the player's inventory data when they login,but server will ignore this,because server will not re-read inventory while player login.

i think that's why sfan5 said "Restarting the server is currently the only way to reload the data from the player file.",because after restarting the server,player's inventory data will re-read and keep in ram.

if minetest offers method to re-read (single)player's data,we could register"minetest.register on joinplayer" to force server to re-read (single) player's data.

Re: How could i force MTserver reload one player's invetory

PostPosted: Fri May 30, 2014 10:06
by rubenwardy
The mod would change the inventory of the player on the server (in its RAM). It would work.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local inv = player:get_inventory()
inv:set("askdnas")


or something (I have never used inventories)

Re: How could i force MTserver reload one player's invetory

PostPosted: Fri May 30, 2014 12:57
by BrandonReese
What if they logged into both servers at the same time?

Re: How could i force MTserver reload one player's invetory

PostPosted: Fri May 30, 2014 13:50
by Krock
BrandonReese wrote:What if they logged into both servers at the same time?

Yeah. That was one of my thoughts, too. It will get very buggy and possibly laggy because of the endless data exchange.

Better use the nether or moon mod to get a 2nd platform in one world.

Re: How could i force MTserver reload one player's invetory

PostPosted: Fri May 30, 2014 14:17
by linushsao
BrandonReese wrote:What if they logged into both servers at the same time?


oh no,in my plan,player will NOT login both worlds.

he will login SINGLE world at the same time,for example,

1.player1 login world A,he logout from world A.
2.than,player1 login world B.and he will keep his tools & weapons from world A.

Re: How could i force MTserver reload one player's invetory

PostPosted: Fri May 30, 2014 14:29
by linushsao
rubenwardy wrote:The mod would change the inventory of the player on the server (in its RAM). It would work.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local inv = player:get_inventory()
inv:set("askdnas")


or something (I have never used inventories)


i make a mod,init.lua is:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_on_joinplayer(function(player)
local inv = player:get_inventory()
inv:set("askdnas")
end)


and messages is:

22:23:30: ERROR[main]: ServerError: /home/linus/.minetest/mods/linus_added/init.lua:4: attempt to call method 'set' (a nil value)
22:23:30: ERROR[main]: stack traceback:

i think i will study LUA for minetest...>_<,any suggesstion to study LUA for minetest?

Re: How could i force MTserver reload one player's invetory

PostPosted: Fri May 30, 2014 15:30
by rubenwardy
It was pseudo code. Look at invref in luaapi.txt