Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- ################################################
- ## Smith System ##
- ## Author: Maxwell Denisson(MaXwEllDeN) ##
- ## Version: 1.0 ##
- ################################################
- ]]
- _SMITHY_ = {
- exp_b = 40,
- receitas = {
- --dif = Dificuldade
- [1] = {dif = 5, -- Staff
- re = {{5892, 2},
- },
- ma = {2401, 1}
- },
- [2] = {dif = 10, -- Mercenary Sword
- re = {{2401, 1},
- {9971, 5},
- {5887, 3},
- {5892, 2},
- },
- ma = {7386, 1}
- },
- [3] = {dif = 3, -- Huge chuck of crude iron
- re = {{5880, 20},
- },
- ma = {5892, 1}
- },
- [4] = {dif = 20, -- Piece of Royal Steel
- re = {{5880, 10},
- {2475, 1},
- },
- ma = {5887, 3}
- },
- }
- }
- _SMITHY_.getRevenue = function (pos)
- local recs = {}
- local ipos = {}
- local posi = {}
- local block = {1642, 1643, 1644, 1645, 1617, 1618, 1620, 1621, 2555}
- local IDEx = 0
- for i, v in pairs(_SMITHY_.receitas) do
- recs[i] = {}
- for _, a in pairs(v.re) do
- for b = 1, a[2] do
- table.insert(recs[i], a[1])
- end
- end
- end
- local Zk = {}
- for _, v in pairs(getAllItemsInPos(pos, block)) do
- if not isInArray(Zk, v.uid) then
- table.insert(ipos, v)
- table.insert(Zk, v.uid)
- end
- end
- for _, v in pairs(ipos) do
- local t = (v.type > 0) and v.type or 1
- for te = 1, t do
- table.insert(posi, v.itemid)
- end
- end
- for _, v in pairs(recs) do
- local AE = true
- for x, i in pairs(posi) do
- if (AE) then
- if (not isInArray(v, i)) or (#v ~= #posi) then
- AE = false
- else
- IDEx = _
- end
- end
- end
- end
- if (#recs < 1) then
- return 0, ipos
- else
- return IDEx, ipos
- end
- end
- _SMITHY_.getExp = function (uid)
- if (getPlayerStorageValue(uid, 58913) < 1) then
- setPlayerStorageValue(uid, 58913, 0)
- end
- return getPlayerStorageValue(uid, 58913)
- end
- _SMITHY_.getLevel = function (uid)
- if (getPlayerStorageValue(uid, 58912) < 1) then
- setPlayerStorageValue(uid, 58912, 1)
- end
- return getPlayerStorageValue(uid, 58912)
- end
- _SMITHY_.addLevel = function (uid, ammount)
- local level = _SMITHY_.getLevel(uid)
- return setPlayerStorageValue(uid, 58912, level + ammount)
- end
- _SMITHY_.getExpToNextLevel = function (uid)
- return _SMITHY_.getExpLevel(_SMITHY_.getLevel(uid) + 1)
- end
- _SMITHY_.getExpLevel = function (level)
- return level * (_SMITHY_.exp_b) + (level - 1* (_SMITHY_.exp_b))
- end
- _SMITHY_.setExp = function (uid, ammount)
- return setPlayerStorageValue(uid, 58913, ammount)
- end
- _SMITHY_.addExp = function (uid, ammount)
- local xp = _SMITHY_.getExp(uid)
- return _SMITHY_.setExp(uid, xp + ammount)
- end
- function getAllItemsInPos(pos, block)
- local results = {}
- for _ = 1, 255 do
- local findPos = {x = pos.x, y = pos.y, z = pos.z, stackpos = _}
- local item = getThingFromPos(findPos)
- if (not isInArray(block, item.itemid)) and (item.uid > 1) then
- table.insert(results, item)
- end
- end
- return results
- end
Advertisement
Add Comment
Please, Sign In to add comment