Jump to content

smajt

Member
  • Posts

    12
  • Joined

  • Last visited

Everything posted by smajt

  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. Someone got a new tilesets to worlded,buildinged,tiled ? i want to use ATM's from the game etc.
  3. Hi... again... so after a long hours of trying to make corpse removal i got to the point that i remove corpses but only on server side (after i respawn i dont see corpses, but everyone else sees it) For testing purpouses I make that OnPlayerDeath event on server side and it worked then, but thats not what i need. I need it strict client -> server. Here im sending player object to the server function PlayerDataCollector.OnPlayerDeath(player) if PlayerDataCollector.isReviving then debugPrint("OnPlayerDeath - Player died while reviving. Skipping.") sendClientCommand("RevivingClient", "isReviving", { true }) return end sendClientCommand("RevivingClient", "isReviving", { false }) PlayerDataCollector.isReviving = true end Here im receiving it on the server and im putting player square to the array function commandModule.RevivingClient.isReviving(player, args) if player ~= nil then if args[1] == true then debugPrint("RemovePlayersServer - OnPlayerDeath - Putting square to the alt list.") altDeathSquares[#altDeathSquares+1] = player:getSquare() elseif args[1] == false then debugPrint("RemovePlayersServer - OnPlayerDeath - Putting square to the list.") deathSquares[#deathSquares+1] = player:getSquare() end else debugPrint("RemovePlayersServer - isReviving - Player object is null.") end end Here im executing checks on the squares to see if there is a body function OnTick(ticks) checkDeathSquares(deathSquares, bodyIds) checkDeathSquares(altDeathSquares, altBodyIds) clearDeadCorpses(bodyIds, false) clearDeadCorpses(altBodyIds, true) end function checkDeathSquares(squares, bodyids) for key, square in pairs(squares) do local bodies = square:getDeadBodys() if bodies == nil or bodies:size() == 0 then return end for i=0, bodies:size() - 1 do local body = bodies:get(i) bodyids[body:getObjectID()] = body end squares[key] = nil end end Here im deleting corpses and dropping player items on the ground function clearDeadCorpses(bodyids, fullclear) for objectId, body in pairs(bodyids) do local bodysquare = body:getSquare() if not fullclear then local bodyinv = body:getContainer() local items = bodyinv:getItems() local itemsarray = {} if items then for i=1, items:size() do local item = items:get(i-1) table.insert(itemsarray, item) end end for i=1,#itemsarray do bodysquare:AddWorldInventoryItem(itemsarray[i], ZombRandFloat(0, 0.99), ZombRandFloat(0, 0.99), 0); bodyinv:Remove(itemsarray[i]) end end bodysquare:removeCorpse(body, false) bodyids[objectId] = nil end end Unfortunately the lack of modding documentation with examples makes it more difficult to understand the problem maybe someone more experienced with project zomboid modding could help me
  4. Hi, im trying to delete player corpses after they die. i tried many ways to delete player corpses but it only disappeared to the time i respawned. now im trying something like this function RemovePlayers(_object) local corpse = _object if corpse and instanceof(corpse, "IsoDeadBody") then local corpseinv=corpse:getContainer() local items=corpseinv:getItems() local corsquare=corpse:getSquare() local itemsarrey={} if items then for i=1,items:size() do local item = items:get(i-1) table.insert(itemsarrey,item) end end for i=1,#itemsarrey do corsquare:AddWorldInventoryItem(itemsarrey[i], ZombRandFloat(0, 0.99), ZombRandFloat(0, 0.99), 0); corpseinv:Remove(itemsarrey[i]) end corsquare:removeCorpse(corpse, false) end end Events.OnContainerUpdate.Add(RemovePlayers) before i was trying to do it in onPlayerDeath event but then it didnt find player body.
  5. Hi again, is there any way i can cancel player death? now im trying to heal player when event starts but its not working,
  6. Hi, im trying to get clickedPlayer from OnFillWorldObjectContextMenu. function CCCAdminMenu.CurrentTargets(worldobjects, subMenuObject) local NoPlayer local clickedPlayer = worldobjects.clickedPlayer if instanceof(clickedPlayer, "IsoPlayer") then local clickedPlayer = obj local clickedPlayerName = clickedPlayer.Forname .. " " .. clickedPlayer.Surname TargetName = subMenuObject:addOption(getText("UI_3CRP_Target_Name", clickedPlayerName), worldobjects, nil) TargetName.notAvailable = true NoPlayer = 0 else NoPlayer = 1 end end Now im trying something like this but before that i was trying to use for loop to check if in worldobjects is any instanceof isoplayer is anyone have an idea how i can get that to work ?
  7. in your map.info set lots=name_of_your_map or just remove lots=muldraugh, ky
  8. require "Items/ItemPicker" require "Items/SuburbsDistributions" require "Items/ProceduralDistributions" require "Vehicles/VehicleDistributions" local function RemoveLoot (name) local cache = {} local function patch(t) for i=#t,1,-1 do if t[i] == name then table.remove(t,i) table.remove(t,i) end end end for room,r in ipairs(SuburbsDistributions) do for container,c in pairs(r) do if c.items and not cache[c.items] then cache[c.items] = true patch(c.items) end end end for proc,p in ipairs(ProceduralDistributions.list) do if p.items and not cache[p.items] then cache[p.items] = true patch(p.items) end if p.junk and not cache[p.junk] then cache[p.junk] = true patch(p.junk) end end for vehicle,p in pairs(VehicleDistributions) do if p.items and not cache[p.items] then cache[p.items] = true patch(p.items) end if p.junk and not cache[p.junk] then cache[p.junk] = true patch(p.junk) end end end RemoveLoot('LouisvilleMap1') RemoveLoot('LouisvilleMap2') RemoveLoot('LouisvilleMap3') RemoveLoot('LouisvilleMap4') RemoveLoot('LouisvilleMap5') RemoveLoot('LouisvilleMap6') RemoveLoot('LouisvilleMap7') RemoveLoot('LouisvilleMap8') RemoveLoot('LouisvilleMap9') RemoveLoot('MuldraughMap') RemoveLoot('WestpointMap') RemoveLoot('MarchRidgeMap') RemoveLoot('RosewoodMap') RemoveLoot('RiversideMap') still not working
  9. require "Items/ProceduralDistributions" require "Items/SuburbsDistributions" for key, x in pairs(ProceduralDistributions.list) do if x == nil then return end for index, y in ipairs(x.items) do if y == nil then return end if y == "LouisvilleMap1" or y == "LouisvilleMap2" or y == "LouisvilleMap3" or y == "LouisvilleMap4" or y == "LouisvilleMap5" or y == "LouisvilleMap6" or y == "LouisvilleMap7" or y == "LouisvilleMap8" or y == "LouisvilleMap9" or y == "MuldraughMap" or y == "WestpointMap" or y == "MarchRidgeMap" or y == "RosewoodMap" or y == "RiversideMap" then table.remove(ProceduralDistributions.list[x].items, index) table.remove(ProceduralDistributions.list[x].items, + 1) end end end for index, x in ipairs(SuburbsDistributions["all"]["inventoryfemale"].items) do if y == nil then return end if y == "LouisvilleMap1" or y == "LouisvilleMap2" or y == "LouisvilleMap3" or y == "LouisvilleMap4" or y == "LouisvilleMap5" or y == "LouisvilleMap6" or y == "LouisvilleMap7" or y == "LouisvilleMap8" or y == "LouisvilleMap9" or y == "MuldraughMap" or y == "WestpointMap" or y == "MarchRidgeMap" or y == "RosewoodMap" or y == "RiversideMap" then table.remove(x.items, index) table.remove(x.items, index + 1) end end for index, x in ipairs(SuburbsDistributions["Bag_SurvivorBag"].items) do if y == nil then return end if y == "LouisvilleMap1" or y == "LouisvilleMap2" or y == "LouisvilleMap3" or y == "LouisvilleMap4" or y == "LouisvilleMap5" or y == "LouisvilleMap6" or y == "LouisvilleMap7" or y == "LouisvilleMap8" or y == "LouisvilleMap9" or y == "MuldraughMap" or y == "WestpointMap" or y == "MarchRidgeMap" or y == "RosewoodMap" or y == "RiversideMap" then table.remove(x.items, index) table.remove(x.items, index + 1) end end So im trying to remove all maps from loot tables. code that i shared is not working. if someone could write me an example or give me some links to forum posts or docs about it.
  10. Solution to my problem: if someone have the same problem as I and your doing ur map cell by cell i recommend to make checkerboard with the size of ur map mine is 12x12 and im compiling all the cell zombiemaps into one i think its the easiest way to solve my problem. remember that u need to put black background before the checkerboard layer
  11. ok i know this but is there a method to make zombie spawn only for one cell? edit: i mean to make zombie spawns cell by cell
  12. Hi, im creating map and i want to add zombies to it. i created a white scale map for zombies spawns and i tried to insert it into one cell. (map is 12x12 cells) as u already know from the title its not working. (image is 300x300 px cause when i tried to do 30x30px, worlded responds with an error) i used: file -> Generate Lots -> Selected Cells Only
×
×
  • Create New...