Nubaza
LUA Scripter
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:
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.
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.