• 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 Server crashing when login/logout

katumblo

Member
Joined
Oct 20, 2010
Messages
60
Reaction score
7
I opened a server on my computer and then on a virtual instance of amazon, 15gb of RAM, SSD, and 1.2gb/s internet (yes, gb, not mb) of download and upload, there was just me and one more friend online on it, and whenever he or I do login or logout, the server ALWAYS crash for about 2 to 3 seconds.

In all the rest it doesn't crash at all, 0 lag to level up, perform pvp, none of that crashes , but if you login and logout it always crashes.

Lua:
local config = {
    loginMessage = getConfigValue('loginMessage'),
    useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}

function onLogin(cid)
    local loss = getConfigValue('deathLostPercent')
    if(loss ~= nil) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
    end

    local accountManager = getPlayerAccountManager(cid)
    if(accountManager == MANAGER_NONE) then
        local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
        if(lastLogin > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
            str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
        else
            str = str .. " Please choose your outfit."
            doPlayerSendOutfitWindow(cid)
        end

        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
    elseif(accountManager == MANAGER_NAMELOCK) then
        addEvent(valid(doCreatureSay), 500, cid, "Hello, it appears that your character has been locked for name violating rules, what new name would you like to have?", TALKTYPE_PRIVATE_NP, true, cid)
    elseif(accountManager == MANAGER_ACCOUNT) then
        addEvent(valid(doCreatureSay), 500, cid, "Hello, type {account} to manage your account. If you would like to start over, type {cancel} anywhere.", TALKTYPE_PRIVATE_NP, true, cid)
    else
        addEvent(valid(doCreatureSay), 500, cid, "Hello, type {account} to create an account or {recover} to recover an account.", TALKTYPE_PRIVATE_NP, true, cid)
    end

    if(not isPlayerGhost(cid)) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    end

    registerCreatureEvent(cid, "Idle")
    registerCreatureEvent(cid, "Mail")

    registerCreatureEvent(cid, "ReportBug")
    if(config.useFragHandler) then
        registerCreatureEvent(cid, "SkullCheck")
    end

    registerCreatureEvent(cid, "GuildEvents")
    registerCreatureEvent(cid, "AdvanceSave")
    registerCreatureEvent(cid, "recordIp")
    registerCreatureEvent(cid, "partyAndGuildProtection")
    registerCreatureEvent(cid, "PushPlayerThere")
    registerCreatureEvent(cid, "savePlayer")
    registerCreatureEvent(cid, "savePlayer_L")
 
    -- News
    registerCreatureEvent(cid, "advancedMSG")
    registerCreatureEvent(cid, "critical")
    registerCreatureEvent(cid, "Inicio")
    registerCreatureEvent(cid, "apt")
    registerCreatureEvent(cid, "bpt")
    registerCreatureEvent(cid, "cpt")
    registerCreatureEvent(cid, "dpt")
    registerCreatureEvent(cid, "FragReward")
    registerCreatureEvent(cid, "PlayerAntKillSummon")
    registerCreatureEvent(cid, "SummonAntKillPlayer")
    --Boss
    registerCreatureEvent(cid, "IndraKill")
    registerCreatureEvent(cid, "AshuraKill")
    registerCreatureEvent(cid, "MizukiKill")
    registerCreatureEvent(cid, "ZabuzaKill")
    registerCreatureEvent(cid, "JiroboKill")
    registerCreatureEvent(cid, "OrochimaruKill")
    registerCreatureEvent(cid, "KimimaruKill")
    registerCreatureEvent(cid, "KisameKill")
    registerCreatureEvent(cid, "DeidaraKill")
    registerCreatureEvent(cid, "HidanKill")
    registerCreatureEvent(cid, "KakuzoKill")
    registerCreatureEvent(cid, "KabutoKill")
    registerCreatureEvent(cid, "SasoriKill")
    registerCreatureEvent(cid, "TobiKill")
    registerCreatureEvent(cid, "NagatoKill")
    registerCreatureEvent(cid, "KonanKill")
    registerCreatureEvent(cid, "DanzouKill")
    registerCreatureEvent(cid, "ObitoKill")
    registerCreatureEvent(cid, "ItachiKill")
    registerCreatureEvent(cid, "MadaraKill")
    registerCreatureEvent(cid, "KaguyaKill")
    registerCreatureEvent(cid, "HagoromoKill")
    registerCreatureEvent(cid, "corpse")
    --Storage
    registerCreatureEvent(cid, "firstmessage")
    registerCreatureEvent(cid, "StorageKilla")
    registerCreatureEvent(cid, "teleportmonster")
    registerCreatureEvent(cid, "HeartDrop")
    registerCreatureEvent(cid, "HatDrop")
    registerCreatureEvent(cid, "autoBless")
    registerCreatureEvent(cid, "targetCreature")
    registerCreatureEvent(cid, "invencible")
    registerCreatureEvent(cid, "kaiten")
    registerCreatureEvent(cid, "sunadefense")
    if getPlayerStorageValue(cid, 3433301) ~= 0 then
        setPlayerStorageValue(cid, 3433301, 0)
    end
    if getPlayerStorageValue(cid, 3424675) ~= 0 then
        setPlayerStorageValue(cid, 3424675, 0)
    end
    if getPlayerStorageValue(cid, 3727678) ~= 0 then
        setPlayerStorageValue(cid, 3727678, 0)
    end
    registerCreatureEvent(cid, "reflectrob")
    registerCreatureEvent(cid, "checkBless")
    registerCreatureEvent(cid, "showKD")
    doPlayerOpenChannel(cid, 9)
    doPlayerOpenChannel(cid, 8)
    doPlayerOpenChannel(cid, 10)
 
    if getCreatureName(cid) == "Account Manager" then
    return false
    end
    registerCreatureEvent(cid, "reborn")
    if getPlayerStorageValue(cid, 19332) == -1 then
        setPlayerStorageValue(cid, 19332, 0)
    end
    registerCreatureEvent(cid, "PushPlayerThere")
    ---------- PlayerPort---------------
    if getPlayerStorageValue(cid, 49708) ~= 0 then
        setPlayerStorageValue(cid, 49708, 0)
    end
    -- doPlayerPopupFYI(cid, "[ APROVEITE ] Double POINTS + Double EXP + Double SKILL !")
 
    return true
end

XML:
<?xml version="1.0" encoding="UTF-8"?>
<creaturescripts>
    <!-- News -->
    <event type="kill" name="StorageKilla" script="kill/kimimaru.lua"/>
    <event type="statschange" name="critical" event="script" value="critical.lua"/>
    <event type="advance" name="advancedMSG" event="script" value="msglevel.lua"/>
    <event type="death" name="teleportmonster" script="tpmonster.lua"/>
    <event type="death" name="redSkullAmulet" event="script" value="redamulet.lua"/>
    <event type="login" name="firstmessage" script="firstmessage.lua"/>
    <event type="statschange" name="reflectrob" event="script" value="reflectrob.lua"/>
    <creaturescript type = "push" name = "PushPlayerThere" event = "script" value = "antipush.lua"/>
    <event type="death" name="corpse" event="script" value="corpse.lua"/>
    <!-- <event type="kill" name="FragReward" event="script" value="exp kill.lua"/> -->
    <event type="login" name="Anti Mc" event="script" value="antimc.lua"/>
  
    <event type="death" name="HeartDrop" event="script" value="heart.lua"/>
    <event type="death" name="stordeath" event="script" value="stordeath.lua"/>
    <event type="attack" name="targetCreature" script="target.lua"/>
    <!-- <event type="look" name="showKD" event="script" value="KillsandDeath.lua"/> -->
    <event type="statschange" name="critical" event="script" value="critical.lua"/>
    <event type="login" name="autoBless" event="script" value="autoBless.lua"/>
    <event type="login" name="BattleLogin" event="script" value="BattleCreatureScript.lua"/>
    <event type="PrepareDeath" name="BattleDeath" event="script" value="BattleCreatureScript.lua"/>
    <event type="combat" name="BattleTeam" event="script" value="BattleCreatureScript.lua"/>
    <!-- Player Login -->
  
    <event type="login" name="PlayerLogin" event="script" value="login.lua"/>
    <event type="statschange" name="invencible" event="script" value="kawarimi.lua"/>
    <event type="statschange" name="kaiten" event="script" value="kaiten.lua"/>
    <event type="statschange" name="sunadefense" event="script" value="suna defense.lua"/>
    <!-- Jutsus
    <event type="statschange" name="invencible" event="script" value="invencible.lua"/>
    <event type="statschange" name="reflectrob" event="script" value="reflectrob.lua"/>-->
  
    <!-- Ban System -->
  
    <event type="channelrequest" name="Ban_Type" event="script" value="ban/type.lua"/>
    <event type="channelrequest" name="Ban_Action" event="script" value="ban/action.lua"/>
    <event type="textedit" name="Ban_Finish" event="script" value="ban/finish.lua"/>
    <event type="target" name="Target_Lost" event="script" value="target lost.lua"/>
    <!--<event type="login" name="savePlayer" event="script" value="savePlayer.lua" />-->
    <!--<event type="logout" name="savePlayer_L" event="script" value="savePlayer.lua" />-->
    <event type="combat" name="SummonAntKillPlayer" event="script" value="SummonAntKillPlayer.lua"/>
    <event type="combat" name="PlayerAntKillSummon" event="script" value="PlayerAntKillSummon.lua"/>
  
    <event type="attack" name="apt" event="script" value="apt.lua"/>
    <event type="cast" name="bpt" event="script" value="bpt.lua"/>
    <event type="areacombat" name="cpt" event="script" value="cpt.lua"/>
    <event type="combat" name="dpt" event="script" value="dpt.lua"/>
    <!-- Server Events -->
    <event type="channeljoin" name="GuildEvents" event="script" value="guild.lua"/>
    <event type="mailreceive" name="Mail" event="script" value="mail.lua"/>
    <event type="reportbug" name="ReportBug" script="reportbug.lua"/>
    <event type="advance" name="AdvanceSave" event="script" value="advancesave.lua"/>
    <event type="think" name="SkullCheck" event="script" value="skullcheck.lua"/>
    <!--<event type="login" name="recordIp" event="script" value="recordIp.lua"/>-->
    <event type="kill" name="SummonKill" event="script" value="obsidianknife.lua"/>
    <!--<event type="login" name="obs_login" event="script" value="obsidianknife.lua"/>-->
    <event type="extendedopcode" name="ExtendedOpcode" event="script" value="extendedopcode.lua"/>
  
    <!-- Edit New -->
    <event type="login" name="Inicio" event="script" value="inicio.lua"/>
    <event type="statschange" name="reborn" script="reborn.lua"/>
    <!-- Boss -->
    <event type="death" name="IndraKill" event="script" value="boss/indraotsutsuki.lua"/>
    <event type="death" name="AshuraKill" event="script" value="boss/ashuraotsutsuki.lua"/>
    <event type="death" name="MizukiKill" event="script" value="boss/mizuki.lua"/>
    <event type="death" name="ZabuzaKill" event="script" value="boss/zabuza.lua"/>
    <event type="death" name="JiroboKill" event="script" value="boss/jirobo.lua"/>
    <event type="death" name="OrochimaruKill" event="script" value="boss/orochimaru.lua"/>
    <event type="death" name="KimimaruKill" event="script" value="boss/kimimaru.lua"/>
    <event type="death" name="KisameKill" event="script" value="boss/kisame.lua"/>
    <event type="death" name="DeidaraKill" event="script" value="boss/deidara.lua"/>
    <event type="death" name="HidanKill" event="script" value="boss/hidan.lua"/>
    <event type="death" name="KakuzoKill" event="script" value="boss/kakuzo.lua"/>
    <event type="death" name="KabutoKill" event="script" value="boss/kabuto.lua"/>
    <event type="death" name="SasoriKill" event="script" value="boss/sasori.lua"/>
    <event type="death" name="TobiKill" event="script" value="boss/tobi.lua"/>
    <event type="death" name="NagatoKill" event="script" value="boss/nagato.lua"/>
    <event type="death" name="KonanKill" event="script" value="boss/konan.lua"/>
    <event type="death" name="DanzouKill" event="script" value="boss/danzou.lua"/>
    <event type="death" name="ObitoKill" event="script" value="boss/obito.lua"/>
    <event type="death" name="ItachiKill" event="script" value="boss/itachi.lua"/>
    <event type="death" name="MadaraKill" event="script" value="boss/madara.lua"/>
</creaturescripts>

Please I would greatly appreciate if someone help me, because basically this is missing to get the server online
 
I noticed a small detail, when I log out, I kind of don't log out and it seems that the server kicks me, because of that, this message ALWAYS appears after logout:

Your connection has been lost.
Either your network or the server went down. (ERROR 10054)

*The server doesn't crash, it's a bug that's happening, but I have no idea where it could be
 
I think not :( that's my config.lua:

Lua:
-- Combat settings
-- NOTE: valid values for worldType are: "pvp", "no-pvp" and "pvp-enforced"
stairhopDelay = 1 * 1000
blessingOnlyPremium = false

fragsLimit = 24 * 60 * 60
fragsSecondLimit = 1 * 24 * 60 * 60
fragsThirdLimit = 1 * 24 * 60 * 60

fragsToRedSkull = 10
fragsSecondToRedSkull = 60
fragsThirdToRedSkull = 90
redSkullLength = 1 * 24 * 60 * 60


fragsToBlackSkull = 15
fragsSecondToBlackSkull = 65
fragsThirdToBlackSkull = 95
blackSkulledDeathHealth = 40
blackSkulledDeathMana = 0
blackSkullLength = 2 * 24 * 60 * 60
useBlackSkull = true

notationsToBan = 3
warningsToFinalBan = 4
warningsToDeletion = 5
banLength = 7 * 24 * 60 * 60
killsBanLength = 7 * 24 * 60 * 60
finalBanLength = 30 * 24 * 60 * 60
ipBanLength = 1 * 24 * 60 * 60
fragsToBanishment = 25
fragsSecondToBanishment = 70
fragsThirdToBanishment = 99

worldId = 0
worldType = "open"
hotkeyAimbotEnabled = true
protectionLevel = 30

killsToRedSkull = 10
killsToBlackSkull = 15

pzLocked = 30 * 1000
removeChargesFromRunes = true
removeChargesFromPotions = true
removeWeaponAmmunition = true
removeWeaponCharges = true
timeToDecreaseFrags = 24 * 60 * 60 * 1000
whiteSkullTime = 10 * 60 * 1000
stairJumpExhaustion = 1 * 1000
experienceByKillingPlayers = true
rateExperienceFromPlayers = 50
expFromPlayersLevelRange = 40
skipItemsVersionCheck = true
accountManager = false
pushCreatureDelay = 1 * 1500
ingameGuildManagement = false
elfProtectionTarget = true
useFragHandler = true
advancedFragList = false

-- Connection Config
-- NOTE: maxPlayers set to 0 means no limit
ip = "127.0.0.1"
bindOnlyGlobalAddress = false
loginProtocolPort = 7171
gameProtocolPort = 7172
statusProtocolPort = 7171
maxPlayers = 200
motd = "Bem-vindo ao NTO Tarads Online !"
onePlayerOnlinePerAccount = false
allowClones = false
serverName = "Tarads"
statusTimeout = 5 * 1000
replaceKickOnLogin = true
maxPacketsPerSecond = 50


-- Version Manual
clientVersionMin = 860
clientVersionMax = 860
clientVersionStr = "Only clients with protocol 8.60 allowed!"

-- Deaths
-- NOTE: Leave deathLosePercent as -1 if you want to use the default
-- death penalty formula. For the old formula, set it to 10. For
-- no skill/experience loss, set it to 0.
deathLosePercent = -1


-- Houses
-- NOTE: set housePriceEachSQM to -1 to disable the ingame buy house functionality
housePriceEachSquare = 7500
houseRentPeriod = "monthly"

-- Item Usage
timeBetweenActions = 1000
timeBetweenExActions = 1000

-- Map
-- NOTE: set mapName WITHOUT .otbm at the end
mapName = "forgotten.otbm"
mapAuthor = "Eros"

-- MySQL
sqlType = ".censured."
mysqlHost = ".censured."
mysqlUser = ".censured."
mysqlPass = ".censured."
mysqlDatabase = ".censured."
mysqlPort = 00
mysqlSock = ""
passwordType = ".censured."

sqlHost = ".censured."
sqlPort = 00
sqlUser = ".censured."
sqlPass = ".censured."
sqlDatabase =".censured."
sqlFile = ".censured."
sqlKeepAlive = 0
mysqlReadTimeout = 0
mysqlWriteTimeout = 0
mysqlReconnectionAttempts = 3
encryptionType = "sha1"

-- Misc.
allowChangeOutfit = false
freePremium = false
kickIdlePlayerAfterMinutes = 15
maxMessageBuffer = 5
emoteSpells = true
classicEquipmentSlots = false
allowWalkthrough = true
classicAttackSpeed = false

-- Rates
-- NOTE: rateExp is not used if you have enabled stages in data/XML/stages.xml
experienceStages = true
rateExp = 1
rateSkill = 4
rateLoot = 1
rateMagic = 4
rateSpawn = 1
formulaLevel = 3.5
formulaMagic = 3.5

-- Monster rates
rateMonsterHealth = 1.0
rateMonsterAttack = 1.0
rateMonsterDefense = 1.0

-- Monsters
deSpawnRange = 2
deSpawnRadius = 50

-- Stamina
staminaSystem = true

-- Scripts
warnUnsafeScripts = true
convertUnsafeScripts = true

-- Startup
-- NOTE: defaultPriority only works on Windows and sets process
-- priority, valid values are: "normal", "above-normal", "high"
defaultPriority = "high"
startupDatabaseOptimization = true

-- Global save
    globalSaveEnabled = true
    globalSaveHour = 5
    globalSaveMinute = 5
    shutdownAtGlobalSave = true
    cleanMapAtGlobalSave = false
    closeInstanceOnShutdown = true
    
-- Houses
    buyableAndSellableHouses = true
    houseNeedPremium = true
    bedsRequirePremium = true
    levelToBuyHouse = 100
    housesPerAccount = 1
    houseRentAsPrice = true
    housePriceAsRent = true
    housePriceEachSquare = 45000
    houseRentPeriod = "monthly"
    houseCleanOld = 0
    guildHalls = true
    houseSkipInitialRent = true
    houseProtection = true
 
if it's always after 2-3s, i will target some onThing scripts (globalscripts and creaturescripts)
I delete all scripts in creaturescrpits and the error continue :s

actually, the creaturescripts is like this:

XML:
<?xml version="1.0" encoding="UTF-8"?>
<creaturescripts>
   
</creaturescripts>

I tryed delet the globalevents.xml after, put like this:

XML:
<?xml version="1.0" encoding="UTF-8"?>
<globalevents>

</globalevents>

but the erro continues
 
Last edited:
In all the rest it doesn't crash at all, 0 lag to level up, perform pvp, none of that crashes , but if you login and logout it always crashes.
Crash [server restarts] or freez [stop movement for few seconds]?
According to my statistics:
Oracle ARM - CLOUD - has pretty slow disk (low IOPS - input/output operations per second). It may lag MySQL and make login/logout take few seconds. It can be same on Amazon, which is 100% CLOUD (not tested yet).

You should not use 'cloud' for OTS hosting. Some are fine for test server, but some of them lags all the time. VPSes are often better and of course dedicated server are the best.

You can run all tests on your machine, if it's Ubuntu 20+:
 
Crash [server restarts] or freez [stop movement for few seconds]?
According to my statistics:
Oracle ARM - CLOUD - has pretty slow disk (low IOPS - input/output operations per second). It may lag MySQL and make login/logout take few seconds. It can be same on Amazon, which is 100% CLOUD (not tested yet).

You should not use 'cloud' for OTS hosting. Some are fine for test server, but some of them lags all the time. VPSes are often better and of course dedicated server are the best.

You can run all tests on your machine, if it's Ubuntu 20+:

First: thank u and wow, your tutorials are amazing!

So..
The server only stop movement for few seconds, and my disk have 30gb (only 9.79 used)
I'm using windows in the machine
My database doesn't in the amazon, i pay one plan in (CloudClusters (https://www.cloudclusters.io))

Do you think it's impossible to run the server in these settings? Remembering that the server is 8.60 and the map dimension is 2449x65000

Another observation that the speed of the database is very good, I have an a.i. (in python) that makes several connections to it in a VERY fast time, (+/- 0.01 seconds) but while I am running all the tests of the tibia, i'm not using it a.i
 
Crash [server restarts] or freez [stop movement for few seconds]?
According to my statistics:
Oracle ARM - CLOUD - has pretty slow disk (low IOPS - input/output operations per second). It may lag MySQL and make login/logout take few seconds. It can be same on Amazon, which is 100% CLOUD (not tested yet).

You should not use 'cloud' for OTS hosting. Some are fine for test server, but some of them lags all the time. VPSes are often better and of course dedicated server are the best.

You can run all tests on your machine, if it's Ubuntu 20+:
about it, did u tested the oracle with High Performace Disk? its free too, but not standard, u need to put the disk in high iops
 
My database doesn't in the amazon, i pay one plan in (CloudClusters (https://www.cloudclusters.io))
OTS is not ready for CLOUD and will never work fine with cloud. 'real tibia' designers (tibia.com), designed it to work with RAM storage, or at least database on server 'next to' server (with 0ms ping).
It loads data directly from database, using multiple SQL queries - it sends 10-15 queries every login/logout. Sequentially - it sends 2nd query after first finish. If single SQL query executes for 0.01 sec, 15 queries executes for at least 0.15 sec, but it can also take 1 or 3 seconds (queries that save are much slower than queries that just load data). It gives 0.15 or 1-3 seconds lag for all players on server.
If you host MySQL in other company, it also adds 'ping' (between hosts) to each query, which kills MySQL performace. MySQL works best on dedicated server with SSD or VPS with SSD - for OTS: same host as on which you host OTS.

EDIT:
There are 2 kinds of 'cloud':
  • operating system and temporary data [ex. you get XX GB SSD in hetzner.com] - including MySQL - on same server = they are fast, MySQL gets direct access to SSD disk on same machine as CPU/RAM
  • full 'cloud' = operating system on same 'PC' [server], rest of data on separated 'network storage', from system [Linux] points of view, it's same, but it's hosted on other hardward... or multiple hardwares in multiple datacenters - that's what 'cloud' is about, it copies data around and in case of hardward failure, it works like nothing happend - it's fine for many applications, but not OTS
 
Last edited:
about it, did u tested the oracle with High Performace Disk? its free too, but not standard, u need to put the disk in high iops

Me ? Or the @Gesior.pl ?

OTS is not ready for CLOUD and will never work fine with cloud. 'real tibia' designers (tibia.com), designed it to work with RAM storage, or at least database on server 'next to' server (with 0ms ping).
It loads data directly from database, using multiple SQL queries - it sends 10-15 queries every login/logout. Sequentially - it sends 2nd query after first finish. If single SQL query executes for 0.01 sec, 15 queries executes for at least 0.15 sec, but it can also take 1 or 3 seconds (queries that save are much slower than queries that just load data). It gives 0.15 or 1-3 seconds lag for all players on server.
If you host MySQL in other company, it also adds 'ping' (between hosts) to each query, which kills MySQL performace. MySQL works best on dedicated server with SSD or VPS with SSD - for OTS: same host as on which you host OTS.

EDIT:
There are 2 kinds of 'cloud':
  • operating system and temporary data [ex. you get XX GB SSD in hetzner.com] - including MySQL - on same server = they are fast, MySQL gets direct access to SSD disk on same machine as CPU/RAM
  • full 'cloud' = operating system on same 'PC' [server], rest of data on separated 'network storage', from system [Linux] points of view, it's same, but it's hosted on other hardward... or multiple hardwares in multiple datacenters - that's what 'cloud' is about, it copies data around and in case of hardward failure, it works like nothing happend - it's fine for many applications, but not OTS

Ohhhh understand :(

Thank u for this bro, problably i will pay one dedicated/semi-dedicated .... But the prices is soo hard :x
Btw, thank you very much!
 
Back
Top