Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- addEventHandler("onPlayerJoin", root,
- function ()
- Backpack:create(source)
- end
- )
- addCommandHandler("put",
- function (player, cmd, itemname, amount)
- if not itemname or itemname:len() == 0 then
- outputChatBox(("Syntax: /put <item> (optional: <amount>)"):format(itemname), player, 255, 100, 100)
- elseif not Item.exists(itemname) then
- outputChatBox(("* The item %q does not exist"):format(itemname), player, 255, 100, 100)
- else
- local backpack = Backpack(player)
- amount = amount and tonumber(amount) or 1
- if backpack:addItem(Item(itemname), amount) then
- outputChatBox(("* Added %d %s to your backpack [Weight: %d]"):format(amount, itemname, backpack:getWeight()), player, 0, 255, 0)
- else
- outputChatBox(("* Could not add %d %s to your backpack"):format(amount, itemname), player, 255, 100, 100)
- end
- end
- end
- )
- addCommandHandler("items",
- function (player)
- local items = Backpack(player):getItems(true)
- if #items == 0 then
- outputChatBox("* You have no items in your backpack", player, 255, 100, 100)
- else
- outputChatBox("* Your backpack items:", player, 0, 255, 0)
- for index, slot in pairs(items) do
- outputChatBox((" %dx %s (%s)"):format(slot.amount, slot.item:getName(), slot.item:getCategory()), player, 130, 130, 130)
- end
- end
- end
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement