local removeSpeed, storage = {
--[{pctMaxCap, pctMinCap}] = amoutOfPctRemoveSpeed,
[{99, 90}] = 10,
[{89, 80}] = 20,
[{79, 70}] = 30,
[{69, 60}] = 40,
[{59, 50}] = 50,
[{49, 40}] = 60,
[{39, 1}] = 80,
}, 486464 -- set free storage
function onThink(cid, interval)
if isPlayer(cid) then
local speed
for k, v in pairs(removeSpeed) do
local pctCap = math.floor(getPlayerFreeCap(cid) / getPlayerMaxCap(cid) * 100)
if k[1] >= pctCap and pctCap >= k[2] then
speed = v
break
end
end
if speed then
if getCreatureStorage(cid, storage) ~= speed then
local pctSpeed = math.floor(getCreatureBaseSpeed(cid) * speed / 100)
doChangeSpeed(cid, math.max(0, getCreatureStorage(cid, storage)) - pctSpeed)
doCreatureSetStorage(cid, storage, pctSpeed)
end
end
end
return true
end
function getPlayerMaxCap(cid) -- darkhaos function
local query = db.getResult("SELECT `cap` FROM `players` WHERE `id` = " .. getPlayerGUID(cid))
if query:getID() ~= -1 then
return query:getDataInt("cap")
end
query:free()
return false
end