• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Cap system (low cap = move slowly)

Fresh

Quack!
Joined
Oct 21, 2009
Messages
1,855
Solutions
18
Reaction score
671
Hello.
Anyone got that system ?
If player have low cap (capacity) then he moves slowly ?
I saw that system on an forum but i forgot.
Someone have ?
 
LUA:
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



With a lot of people on server it can causing some lags . (there isn't included part which check that player is paralyzed or that player have item which increases/decreases player's movement speed)
 
Last edited:

Similar threads

Back
Top