• 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!

Lua Why This Command Cause Lag T_T

Nubaza

LUA Scripter
Joined
Jun 5, 2011
Messages
330
Solutions
1
Reaction score
21
Location
New Zeland
Hello, i've created some function to my OTC and my pokemon server hhaha...


But i've a BIG BIG problem... When i assing this function to a player this cause MUCH lag in all the server:

The function is this:

Code:
function percentsHP(cid)
if not isCreature(cid) then return true end

local balls = getPlayerPokeballs(cid)
local times = 0
local container = getPlayerSlotItem(cid, 3).uid
local pokes = "Mx"
local t = getPlayerSlotItem(cid, 8)

if t.uid ~= 0 then
local maxHp = HPperVITsummon * getVitalityByMaster(cid)
local rd = 1 - (tonumber(getItemAttribute(t.uid, "hp")))
local hp = maxHp -(maxHp * rd)

pokes = pokes.."," .. math.floor((math.floor(hp) / math.floor(maxHp)) * 100) .. ""
end

local pokeballs = getPokeballsInContainer(container)
for i = 1, #pokeballs do

local maxHps = HPperVITsummon * getVitalitiesByMaster(cid)
local rds = 1 - (tonumber(getItemAttribute(pokeballs[i], "hp")))
local hps = maxHps -(maxHps * rds)

pokes = pokes.."," .. math.floor((math.floor(hps) / math.floor(maxHps)) * 100) .. ""
end

doPlayerSendCancel(cid, '' .. pokes .. '')
end

When the player get a sendCancelMessage like this:
Mx,100,200 -- depending the quantity of pokeballs what trainer have.
The otclient get updated in a special bar... Undestood?

But, i need this function each time what the trainer's pokemon losses/gain HP.
For that reason i putted the function function percentsHP(cid) in to a statschange creaturescript.

This is causing my server LAG

WHY? I dont know... Exist one way to reduce this?

Very thank you Otland!
Thanks for reading.
 
Back
Top