Jump to content

Danixu

Member
  • Posts

    6
  • Joined

  • Last visited

Danixu's Achievements

  1. I'll give a try adding it to a call in the context menu to test it ingame. Thanks!!
  2. Hello, I am trying to migrate a Mod logic to server side to avoid to have several clients doing the same, and to avoid to have clients with old data or new clients with no data it all. My problem is that I am not able to keep the data upon server restarts, and doing tests I have seen that while the SP mode saves the ModData in a table that is visible on debug mode and preserved forever, the MP mode keeps that table only when the server is running and is deleted once is restarted. I have tried the save world command to see if maybe it requires a manual save, but same behaviour. I am using this simple lua test script: -- Testing! if isClient() then return end if ModData.exists("ISA_TEST") == false then print("ISA: No Data... creating new data.") local data = ModData.getOrCreate("ISA_TEST") data.test = "Testing the ModData" else print("ISA: Data Found!!! Finally is working!!") local data = ModData.get("ISA_TEST") print("ISA: " .. data.test) end if ModData.exists("ISA_TEST") == true then local test = ModData.get("ISA_TEST") print("ISA: Type - " .. type(test)) print("ISA: Test Data - " .. ModData.get("ISA_TEST").test) end The first "if" always gives false because there is no data on boot. Then the data is created and the second "if" gives true because the data exists. LOG : General , 1648370405885> 2,530,238> ISA: No Data... creating new data. LOG : General , 1648370405886> 2,530,239> ISA: Type - table LOG : General , 1648370405886> 2,530,239> ISA: Test Data - Testing the ModData I have seen that the 41.68 changelog includes this: Fixed GlobalModData.save() not being called on the server. But even with that. the data is not preserved. Maybe I'm doing something wrong, but there is no data about this topic nowhere so I am just doing a "testing & error" method. Version: 41.68, but also tested on 41.65 with same problem. Multiplayer Hosted on Docker container using linux. I am sure that is not a "volatile" storage problem, because all the server data is preserved and only the ModData is removed. Mods: Just the mod I am testing Reproduction steps: Create a Mod with the above code to run it in server Run the server to start the script Optional because it still failing: Enter into the server as admin and run the /save command Stop the server to restart it Start the server again and see how the data is not there Best regards
  3. I think I have found the problem about the data transfer (my fault), but I am not finding any way to store the data into the server in a permanent way.
  4. Hello, I am starting to create mods in PZ and I am very new in the system, so the first I am trying is to modify a mod that I want to improve. In that mod, all the tasks are done in client side so in a MP environment those tasks are done in every client and may not be in sync. Also I am not sure about how MP works with the items, but an item degradation task is executed every day and I am not sure if happens in every client and can cause an high degradation rate problem. Also when no client is connected, then the data is not updated. This make me wonder some questions: The item data is stored at server side, or is the client who is storing the data? There are server side events like in client?, for example EveryTenMinutes, EveryDay... In te wiki there is no info about which runs in server and which in client, so I suppose that only the events that have "Server" in name are executed in server, right? There is any way to store data in server in a permanent way and allow the users to retreive it?. With this at least I will be able to sync the data and avoid duplicated events. About the latest, I have created some ModData in server side and I am able to use it in server without problem, but after a server restart the data is lost. I have used this simple code in the server to create a test data on startup: function CheckPowerbankData() print("Server started...") -- If there is no powerbanks array in ModData, create it if ModData.exists("Powerbanks2") == false then print("Create data.") ModData.create("Powerbanks2") end ModData.get("Powerbanks2")["test"] = "testeo" print("Server Data: " .. ModData.get("Powerbanks2")["test"]) end Events.OnServerStarted.Add(ISACheckPowerbankData) The event runs in server and creates the data, but If remove all but the print line it fails and looks like data is not preserved. I have seen that in client side is preserved and I want to know if there is any way to do it in server side too. About how to retreive that data, I have tried the documented functions ModData.transmit and ModData.request in several ways, but I was not able to get the data from the server. Those functions exists for a reason, so I am sure that I am doing something wrong. Anyone has tried to do it and knows how it works? Best regards.
×
×
  • Create New...