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

User avatar
linushsao
Member
 
Posts: 331
Joined: Mon Jan 27, 2014 12:56
IRC: linushsao
In-game: linus

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

by linushsao » Thu May 29, 2014 12:17

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?
 

User avatar
sfan5
Member
 
Posts: 3636
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5

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

by sfan5 » Thu May 29, 2014 13:17

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.
Mods: Mesecons | WorldEdit | Nuke
Minetest builds for Windows (32-bit & 64-bit)
 

User avatar
linushsao
Member
 
Posts: 331
Joined: Mon Jan 27, 2014 12:56
IRC: linushsao
In-game: linus

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

by linushsao » Thu May 29, 2014 13:46

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.
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

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

by Krock » Thu May 29, 2014 18:59

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.
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

User avatar
linushsao
Member
 
Posts: 331
Joined: Mon Jan 27, 2014 12:56
IRC: linushsao
In-game: linus

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

by linushsao » Fri May 30, 2014 08:02

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
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

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

by rubenwardy » Fri May 30, 2014 08:53

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/*
 

User avatar
linushsao
Member
 
Posts: 331
Joined: Mon Jan 27, 2014 12:56
IRC: linushsao
In-game: linus

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

by linushsao » Fri May 30, 2014 09:36

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.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

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

by rubenwardy » Fri May 30, 2014 10:06

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)
 

User avatar
BrandonReese
Member
 
Posts: 836
Joined: Wed Sep 12, 2012 00:44
GitHub: bremaweb
IRC: BrandonReese
In-game: BrandonReese

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

by BrandonReese » Fri May 30, 2014 12:57

What if they logged into both servers at the same time?
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

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

by Krock » Fri May 30, 2014 13:50

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.
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

User avatar
linushsao
Member
 
Posts: 331
Joined: Mon Jan 27, 2014 12:56
IRC: linushsao
In-game: linus

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

by linushsao » Fri May 30, 2014 14:17

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.
 

User avatar
linushsao
Member
 
Posts: 331
Joined: Mon Jan 27, 2014 12:56
IRC: linushsao
In-game: linus

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

by linushsao » Fri May 30, 2014 14:29

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?
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

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

by rubenwardy » Fri May 30, 2014 15:30

It was pseudo code. Look at invref in luaapi.txt
 


Return to Minetest General

Who is online

Users browsing this forum: No registered users and 17 guests

cron