--[[
################################################
## Smith System ##
## Author: Maxwell Denisson(MaXwEllDeN) ##
## Version: 1.0 ##
################################################
]]
_SMITHY_ = {
exp_b = 13,
receitas = {
--dif = Dificuldade
[1] = {dif = 5, -- Staff
lvl = 0,
re = {{5892, 1},
},
ma = {2401, 1}
},
[2] = {dif = 100.0, -- staff
lvl = 0,
re = {{5901, 5},
{5880, 1},
},
ma = {2401, 1}
},
}
}
_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) * 2)
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