Jump to content

fixed loot

Recommended Posts

I'm new to mod creation and I need help with my mod, which should spawn chests with fixed loot near players on command, but I don't understand how to make the loot fixed. I will be glad for any help)

local _G = GLOBAL
local AllPlayers = _G.AllPlayers
    if not _G.TheWorld.ismastersim then
    if _G.TheWorld.state.cycles == 1 then
            for i, v in ipairs(AllPlayers) do
        local x, y, z = v.Transform:GetWorldPosition()
                    local gift = _G.SpawnPrefab("treasurechest")
                            gift.Transform:SetPosition(x, y, z)
                            local items = {}
                            local item = _G.SpawnPrefab("pigskin")
                            table.insert(items, item)
                            item = _G.SpawnPrefab("cutgrass")
                            table.insert(items, item)
                            item = _G.SpawnPrefab("twigs")
                            table.insert(items, item)
                            item = _G.SpawnPrefab("lubricant")
                            table.insert(items, item)
                            for i, v in ipairs(items) do


Link to comment
Share on other sites

Does nothing happen?

I think the problem is that you give a table to the function GiveItem, but it can't use tables.

Do something like :

for i,v in ipairs(items) do 


Edited by Monti18
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...