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

high cpu usage

calldeer

New Member
Joined
Apr 9, 2019
Messages
6
Reaction score
0
my server [otx2] is consuming a lot of cpu, i suspect it may be the spells. I did a test with a room full of monsters and executed this spell:
Code:
local config = {
adjusteffect = {x = 2, y = 0},
adjusteffect1 = {x = 1, y = 1},
velocidade = 500, -- intervalo entre os giros (quanto menor, mais rapido)
hits = 1, -- quantos hits vai dar
msg = "aaaaaaahhh", -- msg ao soltar a spell
effect1 = 99, -- efeito de distancia que vai ficar rodando
effect2 = 134, -- efeito no sqm do item
effect3 = 134, -- efeito ao castar a spell
effect4 = 526, -- efeito ao acertar a roda no player
effect5 = 553
}
--[[Note que a velocidade multiplicada pelo numero de hits deve dar algo proximo de 8550 pra que a magia nao fique ruim ou um efeito acabe antes do outro.
Nos valores que eu utilizei eles dao 8400, oque ja eh considerado perto pois temos 200 milisegundos iniciais,
8550 eh o tempo que o item sera removido e coincide com o tempo de duracao do efeito 56 (config.effect2)]]

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, 255)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -135.2, 1, -135.2, 1)
function onTargetCreature(cid, target)
    local pos = getCreaturePosition(target)
    local effpos = {x = pos.x + config.adjusteffect.x, y = pos.y + config.adjusteffect.y, z = pos.z}
   doSendMagicEffect(effpos, config.effect4)
   local effpos1 = {x = pos.x + config.adjusteffect1.x, y = pos.y + config.adjusteffect1.y, z = pos.z}
   doSendMagicEffect(effpos1, config.effect5)
end
setCombatCallback(combat, 4, "onTargetCreature")

local arr = {
{1, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 3, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 1}
}

local area = createCombatArea(arr)
setCombatArea(combat, area)

local function initEffect(position)
    for i = 0, 3 do
        local pos = {x = position.x, y = position.y, z = position.z}
        local dir = getPosByDir(pos, i)
        doSendDistanceShoot(position, dir, config.effect1)
    end
addEvent(doSendMagicEffect, 300, position, config.effect2)
return true
end

local function middleEffect(cid, param, position, lim, count)
n = count or 0
    if isCreature(cid) and n < lim then
        for i = 0, 6 do
            local pos = {x = position.x, y = position.y, z = position.z}
            local pos2 = {x = position.x, y = position.y, z = position.z}
            local dir = getPosByDir(pos, i)
            local dir2 = getPosByDir(pos2, i + 1 <= 6 and i + 1 or 0)
            doSendDistanceShoot(dir, dir2, config.effect1)
        end
        doCombat(cid, combat, param)
        addEvent(middleEffect, config.velocidade, cid, param, position, lim, n + 1)
    end
return true
end

local function endEffect(position)
    for i = 0, 6 do
        local pos = {x = position.x, y = position.y, z = position.z}
        local dir = getPosByDir(pos, i)
        doSendDistanceShoot(dir, position, config.effect1)
    end
return true
end

function onCastSpell(cid, var)
if isPlayer(cid) and exhaustion.check(cid, 59899) then
doPlayerSendCancel(cid, "You are exhausted.")
doSendMagicEffect(getCreaturePosition(cid), 2)
return FALSE
end
local position = getCreaturePosition(cid)
    doCreatureSay(cid, config.msg, 20)
    addEvent(endEffect, 1.55 * 1000, position)
    doSendMagicEffect(position, config.effect3)
    initEffect(position)
    addEvent(middleEffect, 200, cid, var, position, config.hits)
    exhaustion.set(cid, 59899, 1)
return true
end
Basically every vocation on my server has this spell, so I would like to ask for help from a scripter who can point out to me what may be causing the cpu's self consumption.
I like this spell because it only releases when a monster hits, I really didn't want to stop using it.
 
Back
Top Bottom