1. Hi,

    Does anyone know what would be the right way to spawn a box at a player's location?
    Also is there any script which could be used to fill the box with specific items?

    Thanks in advance!
     
  2. not sure any dev will create a plugin for that as it's a very personnal plugin.
    but yeah it would be possible.
     
  3. @Reneb that's why they pay you to make it for them :p
     
  4. I know but i dont do personnal plugins :p
     
  5. Well then..there are others on the forum who do myself included lol.
     
  6. Hi I'm not asking for a dev to create a plugin for that, I'm asking for hints and documentation to do that myself.
    I'm trying to get steered in the right direction as I'm having a hard time to find a good documentation on API calls.
    I used to develop addons for World of Warcraft in Lua, but the documentation provided was probably more accessible than the one i managed to find for rust :)
     
  7. Well spawing à box you can look in: view inventory, Someone posted how to create à box.
    You can also look in : build on how to spawn stuff
    And give on how to create items.
     
  8. Something like this:
    Code:
    local function CreateEntity( prefab, pos, rot)
        local CreateEntityMethod = global.GameManager._type:GetMethod("CreateEntity")
        return CreateEntityMethod:Invoke( global.GameManager.server, util.TableToArray({ prefab, pos, rot }) )
    endlocal function SpawnBox(player)
        local box = CreateEntity("items/woodbox_deployed", player.transform.position, player.transform.rotation)
        box:InitializeHealth(100, 100)
        -- Thanks to Reneb (build plugin) --
        box:SendMessage("SetDeployedBy", player, UnityEngine.SendMessageOptions.DontRequireReceiver )
        ------------------------------------
        box:Spawn(true)
        return box
    end-- From CopyPaste with some additions
    local function FillContainer( pref, itemlist )
        for i,item in pairs(itemlist) do
            local giveitem = global.ItemManager.CreateByItemID(item.ID,item.amount)
            if(giveitem) then
                if item.Key then
                    giveitem.instanceData = new(ProtoBuf.InstanceData._type, nil)
                    giveitem.instanceData.dataInt = item.Key
                end
                giveitem:MoveToContainer( pref )
                if(item.container) then
                    FillContainer( giveitem.contents, item.container )
                end
            end
        end
    end-- Main
    local function Main()
        local box = SpawnBox(player)
        FillContainer(box:GetComponent("StorageContainer").inventory, itemlist)
    end
    
     
  9. Thank you Bombardir, that's really helpful :)
    I have a question on the use of "items/woodbox_deployed"
    I see this is part of the items list at: http://pastebin.com/bzwew18R
    But that doesn't define whether it is a small box or a large box.
    Would something like the following more viable?

    "14286": {
    "displayname": "Large Wood Box",
    "shortname": "box_wooden_large",
    "category": "Items",
    "description": "Keep your things in this wooden storage box. Store up to 24 things",
    "itemid": "14286",
    "worldprefab": "items/generic_world",
    "icon_main": "4235",
    "stackable": "1",
    "canBeHeld": "True"

    Would this work?
    local box = CreateEntity("items/box_wooden_large", player.transform.position, player.transform.rotation)
     
  10. "worldprefab": "items/generic_world",
    [DOUBLEPOST=1422982884][/DOUBLEPOST]oh wait, in my plugin it's "items/large_woodbox_deployed" (buy it may be wrong)