Jump to content

Search the Community

Showing results for tags 'moddata'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • News & Announcements
    • News
  • Project Zomboid
    • PZ Updates
    • General Discussions
    • Bug Reports
    • PZ Support
    • PZ Multiplayer
    • PZ Community & Creativity
    • PZ Suggestions
  • PZ Modding
    • Tutorials & Resources
    • Mods
    • Items
    • Mapping
    • Mod Ideas and Requests
  • General Games Development
    • Indie Scene
  • Other Discussions
    • General Discussion
    • Forum Games & Activities

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Twitter


Interests

Found 4 results

  1. Hi, im trying to save bank account data as global moddata per player. My problem is that when im withdrawing money every second time data is updated. local function buttonClick(button, args) writeLog(ATM.GetLogName(), "debug0.0 - " .. ATM.Data.Account.money); num = tonumber(ui["amount"]:getValue()) writeLog(ATM.GetLogName(), "debug0.1 - " .. num); if num then ATM.Sync.LoadRemote() writeLog(ATM.GetLogName(), "debug0.2 - " .. ATM.Data.Account.money); if args.action == "withdraw" and ATM.Data.Account.money >= num then ATM.Data.Account.money = ATM.Data.Account.money - num ModData.add(ATM.GetModDataStatsKey(), ATM.Data.Account); ATM.withdrawMoney(getPlayer(), num) --elseif args.action == "deposit" then -- logika depozytu end end updateBalance() end function ATM.withdrawMoney(playerObj, num) writeLog(ATM.GetLogName(), "debug1.0 - " .. ATM.Data.Account.money); while num > 0 do local max = 0 local maxType = "" for itemType, data in pairs(ATM.Money.Values) do if num >= data.v then max = data.v maxType = itemType end end if max == 0 then break end playerObj:getInventory():AddItem(maxType) num = num - max end ATM.Sync.SaveRemote(); end function ATM.Sync.SaveRemote() if not isClient() then return; end ModData.transmit(ATM.GetModDataStatsKey()); end function ATM.Sync.LoadRemote() if not isClient() then return; end writeLog(ATM.GetLogName(), "load remote"); ModData.request(ATM.GetModDataStatsKey()); end local function OnClientInitGlobalModData() if not isClient() then return; end ATM.Sync.LoadRemote(); end local function OnServerReceiveModData(key, modData) if isClient() or not String:StartsWith(key, ATM.Id) or not modData then return; end writeLog(ATM.GetLogName(), "debug3 - ".. modData.money); writeLog(ATM.GetLogName(), "saving mod data."); ModData.add(key, modData); end local function OnClientReceiveStatsModData(key, modData) if not isClient() or key ~= ATM.GetModDataStatsKey() then return; end if not modData then ATM.Data.Account = {money = 1000, transactions = {}} ModData.add(key, ATM.Data.Account); ATM.Sync.SaveRemote() else ATM.Data.Account = modData; ModData.add(key, ATM.Data.Account); end writeLog(ATM.GetLogName(), "saving player bank account"); end Events.OnInitGlobalModData.Add(OnClientInitGlobalModData); Events.OnReceiveGlobalModData.Add(OnServerReceiveModData); Events.OnReceiveGlobalModData.Add(OnClientReceiveStatsModData); here im pasting the logs of first two tries. ---- CLIENT LOGS ---- [25-01-24 21:25:56.787] debug0.0 - 400. [25-01-24 21:25:56.788] debug0.1 - 100. [25-01-24 21:25:56.788] load remote. [25-01-24 21:25:56.788] debug0.2 - 400. [25-01-24 21:25:56.788] debug1.0 - 300. <- this value should be in next debug0.0 [25-01-24 21:25:56.812] saving player bank account. [25-01-24 21:26:17.379] debug0.0 - 400. <- should be 300 [25-01-24 21:26:17.380] debug0.1 - 100. [25-01-24 21:26:17.380] load remote. [25-01-24 21:26:17.380] debug0.2 - 400. [25-01-24 21:26:17.380] debug1.0 - 300. [25-01-24 21:26:17.396] saving player bank account. ---- SERVER LOGS ---- [25-01-24 21:25:56.797] debug3 - 300. [25-01-24 21:25:56.797] saving mod data.. [25-01-24 21:26:17.388] debug3 - 300. [25-01-24 21:26:17.388] saving mod data.. someone have an idea what is going wrong ? I dont know what could be a problem cause its only happening every second time i press the withdraw button.
  2. I'd like to optimize my mod, to make it faster. So I wonder how the game deals with networked mod data. What is better: true/false or 1/0? If the data is transfered in JSON format, 1/0 will be better. Won't it?
  3. after setting modData on a player via their own client. This modData does not sync to other players clients. How can I make it so? I tried player:transmitModData(); but no good
  4. hi, I recently began again with some modprojects I'm working on and have some things I'm a bit stuck with. first of all: I've learned/found that the current modData (2.9.9.10) only takes data from type "number" and type "table". But I also read on a topic(forgot which) that there would be support to save data from type "table" in the future. so my question is: is this true that there will be table save support for the ModData object? and if so can someone say me if it's already in a testbuild or if it still is on a to implement list? thanks in advance
×
×
  • Create New...