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

Linux Which scripts can eat the cpu?

This is too broad of a question. It all depends on how you script and what exactly you have, nobody is going to be able to magically tell you what you need to look for. Scripts shouldn't even be the problem anyways, if you're having issues with cpu usage you should probably upgrade your host. If anything, parts of the source code are to blame for most of the cpu usage, getSpectators and path matching take the most resources out of anything else in the sources.
 
This is a good way to check it out
 
This is too broad of a question. It all depends on how you script and what exactly you have, nobody is going to be able to magically tell you what you need to look for. Scripts shouldn't even be the problem anyways, if you're having issues with cpu usage you should probably upgrade your host. If anything, parts of the source code are to blame for most of the cpu usage, getSpectators and path matching take the most resources out of anything else in the sources.
I know it is depending on how i script, and ofc no one can magically tell me which script causes the lags. I just wanted to do more focus on which scripts maybe can make lags ( global events or creature events ).
And host info that i am using ( Linux from ovh, 1 core, 4 gb ram , ssd ) what should i upgrade to ?


Typically you will want to look at any scripts that contain loops.
Can you explain more ?


Maybe backtracking in what you have added lately and when did this start to happen?
I tried to disable what i have added lately but the cpu usage still high.


This is a good way to check it out
I saw this solution before and inside the post delusion saying add it to any lib.
Just add it to any lib or new lib file ?
Only this step?
I am using tfs 0.3.7
Post automatically merged:

This is a good way to check it out
Well i added a new lib with this code.
I found in the startup of the server this
Code:
possible infinite loop in file @data/npc/scripts/upgrading man.lua near line 6

this is my NPC.lua

Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
function onCreatureAppear(cid)                npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)            npcHandler:onCreatureDisappear(cid)            end
function onCreatureSay(cid, type, msg)            npcHandler:onCreatureSay(cid, type, msg)        end
function onThink()                                     npcHandler:onThink() end
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    
        if msgcontains(msg, 'offer') then
        selfSay('{Equipments Upgrading Gem} for 25 uber tokens and {Weapons Upgrading Gem} for 30 uber tokens.', cid)

            elseif msgcontains(msg, 'Equipments Upgrading Gem') then
            if getPlayerItemCount(cid,302) >= 25 then
                selfSay('Did you bring me the {25} uber tokens ?', cid)
                talk_state = 1
            else
                selfSay('I need {25} uber tokens, to give you the {Equipments Upgrading Gem}. Come back when you have them.', cid)
                talk_state = 0
            end

            elseif msgcontains(msg, 'yes') and talk_state == 1 then
            talk_state = 0
            if getPlayerItemCount(cid,302) >= 25 then
            if doPlayerRemoveItem(cid,302, 25) == TRUE then
                    selfSay('Take your {Equipments Upgrading Gem}.', cid)
            doPlayerAddItem(cid, 7761, 1)
            end
            else
                selfSay(item, cid)
            end

            elseif msgcontains(msg, 'Weapons Upgrading Gem') then
            if getPlayerItemCount(cid,302) >= 30 then
                selfSay('Did you bring me the {30} uber tokens ?', cid)
                talk_state = 2
            else
                selfSay('I need {30} uber tokens, to give you the {Weapons Upgrading Gem}. Come back when you have them.', cid)
                talk_state = 0
            end

            elseif msgcontains(msg, 'yes') and talk_state == 2 then
            talk_state = 0
            if getPlayerItemCount(cid,302) >= 30 then
            if doPlayerRemoveItem(cid,302, 30) == TRUE then
                    selfSay('Take your {Weapons Upgrading Gem}.', cid)
            doPlayerAddItem(cid, 7760, 1)
            end
            else
                selfSay(item, cid)
            end
            
            elseif msgcontains(msg, 'weapons upgrading gem') then
            if getPlayerItemCount(cid,302) >= 30 then
                selfSay('Did you bring me the {30} uber tokens ?', cid)
                talk_state = 3
            else
                selfSay('I need {30} uber tokens, to give you the {Weapons Upgrading Gem}. Come back when you have them.', cid)
                talk_state = 0
            end

            elseif msgcontains(msg, 'yes') and talk_state == 3 then
            talk_state = 0
            if getPlayerItemCount(cid,302) >= 30 then
            if doPlayerRemoveItem(cid,302, 30) == TRUE then
                    selfSay('Take your {Weapons Upgrading Gem}.', cid)
            doPlayerAddItem(cid, 7760, 1)
            end
            else
                selfSay(item, cid)
            end       

            elseif msgcontains(msg, 'equipments upgrading gem') then
            if getPlayerItemCount(cid,302) >= 25 then
                selfSay('Did you bring me the {25} uber tokens ?', cid)
                talk_state = 4
            else
                selfSay('I need {25} uber tokens, to give you the {Equipments Upgrading Gem}. Come back when you have them.', cid)
                talk_state = 0
            end

            elseif msgcontains(msg, 'yes') and talk_state == 4 then
            talk_state = 0
            if getPlayerItemCount(cid,302) >= 25 then
            if doPlayerRemoveItem(cid,302, 25) == TRUE then
                    selfSay('Take your {Equipments Upgrading Gem}.', cid)
            doPlayerAddItem(cid, 7761, 1)
            end
            else
                selfSay(item, cid)
            end           
            
            




        elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 4) then
            selfSay('Ok then.', cid)
            talk_state = 0
        end

    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

what is the problem? i didn't get it.
 
Last edited:
Back
Top