Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local me = nil
- local pim = nil
- --------------------------------------------------------
- --> Key Names <--
- --------------------------------------------------------
- key_name = string.char(194) .. string.char(167) .. string.char(108) .. "Vote Crate Key"
- function setup(pimP, meP)
- pim = pimP
- me = meP
- end
- function priceToKeys(price)
- local keys_qty = math.floor((price/100)+0.5)
- if keys_qty < 1 then
- keys_qty = 1
- end
- return keys_qty
- end
- function withdraw(price)
- local keys_qty = priceToKeys(price)
- local ok, err = moveKeysToSystem(keys_qty)
- return ok, err
- end
- function getKeysInInventory()
- local id = 131
- local name = key_name
- local qty = 0
- for i,item in pairs(pim.getAllStacks()) do
- if item["id"] == 131 then
- if item["name"] == name then
- if item["ench"] ~= nil then
- if item["ench"][1] ~= nil and item["ench"][1] == "Unbreaking I" then
- qty = qty + item["qty"]
- end
- end
- end
- end
- end
- return qty
- end
- function moveKeysToSystem(amount)
- local name = key_name
- if amount > getKeysInInventory() then
- return false, "Not enough keys!"
- end
- local qty = 0
- for i,item in pairs(pim.getAllStacks()) do
- if item["id"] == 131 then
- if item["name"] == name then
- if item["ench"] ~= nil then
- if item["ench"][1] ~= nil and item["ench"][1] == "Unbreaking I" then
- local keysMoved = me.insertItem(i, amount, "up")
- qty = qty + keysMoved
- amount = amount - keysMoved
- end
- end
- end
- end
- end
- return qty
- end
Add Comment
Please, Sign In to add comment