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

TFS 0.X Zombie event crashes my server somtimes

MaZooRi

Yamo OTS
Joined
Sep 10, 2012
Messages
13
Solutions
1
Reaction score
2
Location
Egypt
Hello all,

I have something weird, my server crashes sometimes during zombie event.
It shows no console errors.
I am using tfs 0.3.7 rev 5969

This is the mod
XML:
<?xml version="1.0" encoding="ISO-8859-1"?>
<mod name="Perfect Zombie System" version="8.6" author="Vodkart" contact="###.com" enabled="yes">
<config name="zombie_config"><![CDATA[
zombie_config = {
    storages = {172100, 172101, 172102},
    players = {min = 2, max = 15},
    rewards = {items ={{12661,1}}, trophy = 5805},
    timeToStartEvent = 30,
    CheckTime = 5,
    teleport = {{x=1506, y=2611, z=7}, {x=1463 , y=2238, z=7}},
    arena = {{x=1440,y=2215,z=7},{x=1489,y=2255,z=7}},
    monster_name = "Zombie Event",
    timeBetweenSpawns = 20,
    min_Level = 100
}
zombie_days = {
    ["Monday"] = {"16:00","23:00"},
    ["Tuesday"] = {"16:00","23:00"},
    ["Wednesday"] = {"16:00","23:00"},
    ["Thursday"] = {"16:00","23:00"},
    ["Friday"] = {"16:00","23:00"},
    ["Saturday"] = {"16:00","23:00"},
    ["Sunday"] = {"16:00","23:00"}
}
function removeZombieTp()
    local t = getTileItemById(zombie_config.teleport[1], 1387).uid
    return t > 0 and doRemoveItem(t) and doSendMagicEffect(zombie_config.teleport[1], CONST_ME_POFF)
end
function ZerarStoragesZombie()
    for _, stor in pairs(zombie_config.storages) do
        setGlobalStorageValue(stor, 0)
    end
end
function getPlayersInZombieEvent()
    local t = {}
    for _, pid in pairs(getPlayersOnline()) do
        if isInRange(getPlayerPosition(pid), zombie_config.arena[1], zombie_config.arena[2]) and getPlayerAccess(pid) < 3 then
            t[#t+1] = pid
        end
    end
    return t
end
function getZombieRewards(cid, items)
    local backpack = doPlayerAddItem(cid, 1999, 1) -- backpackID
    for _, i_i in ipairs(items) do
        local item, amount = i_i[1],i_i[2]
        if isItemStackable(item) or amount == 1 then
            doAddContainerItem(backpack, item, amount)
        else
            for i = 1, amount do
                doAddContainerItem(backpack, item, 1)
            end
        end
    end
end
function isWalkable(pos, creature, proj, pz)-- by Nord
    if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
    if getTopCreature(pos).uid > 0 and creature then return false end
    if getTileInfo(pos).protection and pz then return false, true end
    local n = not proj and 3 or 2
    for i = 0, 255 do
        pos.stackpos = i
        local tile = getTileThingByPos(pos)
        if tile.itemid ~= 0 and not isCreature(tile.uid) then
            if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
                return false
            end
        end
    end
    return true
end
function HaveCreatureZombie(area, remove)
    for x = area[1].x - 1, area[2].x + 1 do
        for y = area[1].y - 1, area[2].y + 1 do
            local pos = {x=x, y=y, z=area[1].z}
            local m = getTopCreature(pos).uid
            if remove ~= false and m ~= 0 and isMonster(m) then doRemoveCreature(m) end
        end
    end
end
function spawnZombie()
    if #getPlayersInZombieEvent() > 1 then
        local pos = {x=math.random(zombie_config.arena[1].x, zombie_config.arena[2].x), y=math.random(zombie_config.arena[1].y,zombie_config.arena[2].y), z=zombie_config.arena[1].z}
        if not isWalkable(pos, false, false, false) then
            spawnZombie()
        else
            doSummonCreature(zombie_config.monster_name, pos)
            doSendDistanceShoot({x = pos.x - math.random(4, 6), y = pos.y - 5, z = pos.z}, pos, CONST_ANI_FIRE)
            addEvent(doSendMagicEffect, 150, pos, CONST_ME_HITBYFIRE)
            addEvent(doSendMagicEffect, 150, pos, CONST_ME_FIREAREA)
            doSendMagicEffect(pos, CONST_ME_MORTAREA)
            setGlobalStorageValue(zombie_config.storages[2], getGlobalStorageValue(zombie_config.storages[2]) <= 0 and 1 or getGlobalStorageValue(zombie_config.storages[2])+1)
            doBroadcastMessage("[Zombie Event] A zombie has spawned! There are currently " .. getGlobalStorageValue(zombie_config.storages[2]) .. " zombies in the zombie event!", MESSAGE_STATUS_CONSOLE_RED)
            addEvent(spawnZombie, zombie_config.timeBetweenSpawns *1000)
        end
    end
end
function CheckZombieEvent(delay)
    if getGlobalStorageValue(zombie_config.storages[1]) ~= (zombie_config.players.max+1) then
        if delay > 0 and getGlobalStorageValue(zombie_config.storages[1]) < zombie_config.players.max then
            doBroadcastMessage("[Zombie Event] Zombie event starting in " .. delay .. " minutes! The teleport will be closed when the event start!", MESSAGE_STATUS_WARNING)
        elseif delay == 0 and getGlobalStorageValue(zombie_config.storages[1]) < zombie_config.players.min then
            for _, cid in pairs(getPlayersInZombieEvent()) do
                doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
                doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
            end
            removeZombieTp()
            doBroadcastMessage("[Zombie Event] The Zombie event could not start because of too few players participating.\n At least " .. zombie_config.players.min .. " players is needed!", MESSAGE_STATUS_WARNING)
            ZerarStoragesZombie()
        elseif delay == 0 and getGlobalStorageValue(zombie_config.storages[1]) >= zombie_config.players.min then
            removeZombieTp()
            doBroadcastMessage("[Zombie Event] The Zombie event has " .. getGlobalStorageValue(zombie_config.storages[1]) .. " players! The event will start soon.")
            for _, var in pairs(getPlayersInZombieEvent()) do
                doPlayerSendTextMessage(var, MESSAGE_EVENT_ADVANCE, "[Zombie Event] The first zombie will spawn in " .. zombie_config.timeToStartEvent .. " seconds! Good luck!")
            end
            addEvent(spawnZombie, zombie_config.timeToStartEvent*1000)
        end
        addEvent(CheckZombieEvent, 60000, delay-1)
    end
end]]></config>
<event type="statschange" name="ZombieStats" event="script"><![CDATA[
domodlib('zombie_config')
if isPlayer(cid) and isMonster(attacker) and getCreatureName(attacker) == zombie_config.monster_name then
    if isInRange(getPlayerPosition(cid), zombie_config.arena[1], zombie_config.arena[2]) then
        if #getPlayersInZombieEvent() > 1 then
            doBroadcastMessage("[Zombie Event] " .. getPlayerName(cid) .. " has been eated by Zombies!", MESSAGE_STATUS_CONSOLE_RED)
            local corpse = doCreateItem(getPlayerSex(cid) == 1 and 3058 or 6081, 1, getPlayerPosition(cid))
            doItemSetAttribute(corpse, "description", "You recognize " .. getCreatureName(cid) .. ". He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".")
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
            doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), false)
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
            if #getPlayersInZombieEvent() == 1 then
                local winner = getPlayersInZombieEvent()[1]
                doBroadcastMessage("[Zombie Event] " .. getCreatureName(winner) .. " has survived at zombie event!")
                local goblet = doPlayerAddItem(winner, zombie_config.rewards.trophy, 1)
                doItemSetAttribute(goblet, "description", "Awarded to " .. getPlayerName(winner) .. " for winning the Zombie event.")
                getZombieRewards(winner, zombie_config.rewards.items)
                doTeleportThing(winner, getTownTemplePosition(getPlayerTown(winner)), false)
                doSendMagicEffect(getPlayerPosition(winner), CONST_ME_TELEPORT)
                doBroadcastMessage("[Zombie Event] " .. getPlayerName(winner) .. " won the Zombie event! Congratulations!")
                HaveCreatureZombie(zombie_config.arena, true)
                ZerarStoragesZombie()
            end
        else
            doBroadcastMessage("[Zombie Event] No one survived in the Zombie Event.", MESSAGE_EVENT_ADVANCE)
            HaveCreatureZombie(zombie_config.arena, true)
            ZerarStoragesZombie()
        end
        return false
    end
end
return true]]></event>
<globalevent name="Zombie_Start" interval="60000" event="script"><![CDATA[
domodlib('zombie_config')
function onThink(interval, lastExecution)
    if zombie_days[os.date("%A")] then
        local hrs = tostring(os.date("%X")):sub(1, 5)
        if isInArray(zombie_days[os.date("%A")], hrs) and getGlobalStorageValue(zombie_config.storages[3]) <= 0 then
            local tp = doCreateItem(1387, 1, zombie_config.teleport[1])
            doItemSetAttribute(tp, "aid", 45110)
            CheckZombieEvent(zombie_config.CheckTime)
            setGlobalStorageValue(zombie_config.storages[1], 0)
            setGlobalStorageValue(zombie_config.storages[2], 0)
            HaveCreatureZombie(zombie_config.arena, true)
        end
    end
    return true
end]]></globalevent>
<event type="login" name="Zombie_Login" event="script"><![CDATA[
domodlib('zombie_config')
function onLogin(cid)
    registerCreatureEvent(cid, "ZombieBattle")
    registerCreatureEvent(cid, "ZombieStats")
    if isInRange(getPlayerPosition(cid), zombie_config.arena[1], zombie_config.arena[2]) then
        doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
    end
    return true
end]]></event>
<event type="combat" name="ZombieBattle" event="script"><![CDATA[
domodlib('zombie_config')
if isPlayer(cid) and isPlayer(target) and isInRange(getPlayerPosition(cid), zombie_config.arena[1], zombie_config.arena[2]) then
    doPlayerSendCancel(cid, "You may not attack this player.") return false
end
return true
]]></event>
<movevent type="StepIn" actionid ="45110" event="script"><![CDATA[
domodlib('zombie_config')
function onStepIn(cid, item, position, fromPosition)
    if not isPlayer(cid) then return true end
    if getPlayerAccess(cid) > 3 then return doTeleportThing(cid, zombie_config.teleport[2]) end
    if getPlayerLevel(cid) < zombie_config.min_Level then
        doTeleportThing(cid, fromPosition, true)
        doPlayerSendCancel(cid, "You need to be at least level " .. zombie_config.min_Level .. ".")
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
        return true
    end
    if getGlobalStorageValue(zombie_config.storages[1]) <= zombie_config.players.max then
        doTeleportThing(cid, zombie_config.teleport[2])
        setGlobalStorageValue(zombie_config.storages[1], getGlobalStorageValue(zombie_config.storages[1])+1)
        doBroadcastMessage("[Zombie Event] " .. getPlayerName(cid) .. " entered the Zombie event! Currently " .. getGlobalStorageValue(zombie_config.storages[1]) .. " players have joined!", MESSAGE_STATUS_CONSOLE_RED)
        if getGlobalStorageValue(zombie_config.storages[1]) == zombie_config.players.max then
            setGlobalStorageValue(zombie_config.storages[1], getGlobalStorageValue(zombie_config.storages[1])+1)
            removeZombieTp()
            doBroadcastMessage("[Zombie Event] The Zombie event has " .. getGlobalStorageValue(zombie_config.storages[1])-1 .. " players! The event will start soon.")
            for _, var in pairs(getPlayersInZombieEvent()) do
                doPlayerSendTextMessage(var, MESSAGE_EVENT_ADVANCE, "[Zombie Event] The first zombie will spawn in " .. zombie_config.timeToStartEvent .. " seconds! Good luck!")
            end
            addEvent(spawnZombie, zombie_config.timeToStartEvent*1000)
        end
    end
    return true
end]]></movevent>
<talkaction words="/zombiestart;!zombiestart" access="5" event="buffer"><![CDATA[
domodlib('zombie_config')
    if getGlobalStorageValue(zombie_config.storages[3]) > 0 then
        doPlayerSendCancel(cid, "The event is already starting.") return true
    elseif not param or not tonumber(param) then
        doPlayerSendCancel(cid, "Use only numbers.") return true
    end
    local param = tonumber(param) <= 0 and 1 or tonumber(param)
    local tp = doCreateItem(1387, 1, zombie_config.teleport[1])
        doItemSetAttribute(tp, "aid", 45110)
        CheckZombieEvent(tonumber(param))
        ZerarStoragesZombie()
        setGlobalStorageValue(zombie_config.storages[3], 1)
        HaveCreatureZombie(zombie_config.arena, true)
]]></talkaction>
<globalevent name="ZombieDebug-Start" type="start" event="buffer"><![CDATA[
domodlib('zombie_config')
ZerarStoragesZombie()
return true]]></globalevent>
</mod>

And this is the monster file

XML:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="Zombie Event" nameDescription="a zombie event" race="undead" experience="280" speed="100" manacost="0">   
<health now="500" max="500"/>   
<look type="311" corpse="9875"/>   
<targetchange interval="5000" chance="50"/>   
<strategy attack="100" defense="0"/>   
<flags>       
<flag summonable="0"/>       
<flag attackable="0"/>       
<flag hostile="1"/>       
<flag illusionable="0"/>       
<flag convinceable="0"/>       
<flag pushable="0"/>       
<flag canpushitems="1"/>       
<flag canpushcreatures="1"/>       
<flag targetdistance="1"/>       
<flag staticattack="90"/>       
<flag runonhealth="0"/>   
</flags>   
<attacks>       
<attack name="melee" interval="2000" min="-350000" max="-350000"/>   
</attacks>   
<defenses armor="15" defense="10"/>   
<immunities>       
<immunity paralyze="1"/>
<immunity invisible="1"/>   
</immunities>   
<voices interval="5000" chance="10">       
<voice sentence="You wont last long!"/>       
<voice sentence="Mmmmh.. braains!"/>   
</voices>   
<loot>       
<item id="2148" countmax="1" chance="100000"/><!-- gold coin -->   
</loot>
</monster>

Will be great if someone help me with that.

Thanks.
 
Without a crash report, it's very hard to know what could be causing the crash.

However, i had this same issue some time ago (cuz im using 0.3.7 aswell) and it was an issue with doCreatureAddHealth() on statsChange but i can see you're not using this function on your mod but still i recommend you to change statsChange to prepareDeath instead.

Or you can make a crash report
Linux - Windows
 
Last edited:
Without a crash report, it's very hard to know what could be causing the crash.

However, i had this same issue some time ago (cuz im using 0.3.7 aswell) and it was an issue with doCreatureAddHealth() on statsChange but i can see you're not using this function on your mod but still i recommend you to change statsChange to prepareDeath instead.

Or you can make a crash report
Linux - Windows

Just in case someone still have problems with doCreatureAddHealth on statsChange, I recommend taking a look at this fix I put on otx2.

The fix itself is just this: FIX1

It was latter optimized to only call the 'getSpectators' function when the creature has been moved.It can be found here: Begin Optimization and Finishing Optimization.

With this, there shouldn't be any more issues related to doCreatureAddHealth() on statsChange.
 
Without a crash report, it's very hard to know what could be causing the crash.

However, i had this same issue some time ago (cuz im using 0.3.7 aswell) and it was an issue with doCreatureAddHealth() on statsChange but i can see you're not using this function on your mod but still i recommend you to change statsChange to prepareDeath instead.

Or you can make a crash report
Linux - Windows
This is the crash dump report when server crashed
in txt

Code:
Dump Summary
------------
Dump File:    theforgottenserver_23-10-2019_09-46-09.mdmp : C:\Users\moham\Desktop\theforgottenserver_23-10-2019_09-46-09.mdmp
Last Write Time:    10/23/2019 11:46:09 AM
Process Name:    tfs.exe : C:\ot\tfs.exe
Process Architecture:    x64
Exception Code:    0xC0000005
Exception Information:    The thread tried to read from or write to a virtual address for which it does not have the appropriate access.
Heap Information:    Not Present

System Information
------------------
OS Version:    10.0.14393
CLR Version(s):  

Modules
-------
Module Name    Module Path    Module Version
-----------    -----------    --------------
tfs.exe    C:\ot\tfs.exe    0.0.0.0
ntdll.dll    C:\Windows\System32\ntdll.dll    6.2.14393.3241
kernel32.dll    C:\Windows\System32\kernel32.dll    6.2.14393.2969
KERNELBASE.dll    C:\Windows\System32\KERNELBASE.dll    6.2.14393.3269
ws2_32.dll    C:\Windows\System32\ws2_32.dll    6.2.14393.3241
sechost.dll    C:\Windows\System32\sechost.dll    6.2.14393.2515
rpcrt4.dll    C:\Windows\System32\rpcrt4.dll    6.2.14393.3115
user32.dll    C:\Windows\System32\user32.dll    6.2.14393.3269
win32u.dll    C:\Windows\System32\win32u.dll    6.2.14393.51
gdi32.dll    C:\Windows\System32\gdi32.dll    6.2.14393.2969
gdi32full.dll    C:\Windows\System32\gdi32full.dll    6.2.14393.3241
lua51.dll    C:\ot\lua51.dll    0.0.0.0
libxml2.dll    C:\ot\libxml2.dll    0.0.0.0
sqlite.dll    C:\ot\sqlite.dll    0.0.0.0
libmysql.dll    C:\ot\libmysql.dll    6.1.1.0
libeay32.dll    C:\ot\libeay32.dll    0.0.0.0
dbghelp.dll    C:\Windows\System32\dbghelp.dll    6.2.14321.1024
ucrtbase.dll    C:\Windows\System32\ucrtbase.dll    6.2.14393.2999
msvcp110.dll    C:\Windows\System32\msvcp110.dll    11.0.51106.1
mswsock.dll    C:\Windows\System32\mswsock.dll    6.2.14393.0
msvcr110.dll    C:\Windows\System32\msvcr110.dll    11.0.51106.1
advapi32.dll    C:\Windows\System32\advapi32.dll    6.2.14393.2969
msvcrt.dll    C:\Windows\System32\msvcrt.dll    7.0.14393.2457
msvcr100.dll    C:\Windows\System32\msvcr100.dll    10.0.30319.1
wsock32.dll    C:\Windows\System32\wsock32.dll    6.2.14393.0
zlib1.dll    C:\ot\zlib1.dll    1.2.5.0
secur32.dll    C:\Windows\System32\secur32.dll    6.2.14393.2273
dbgcore.dll    C:\Windows\System32\dbgcore.dll    6.2.14321.1024
sspicli.dll    C:\Windows\System32\sspicli.dll    6.2.14393.2580
imm32.dll    C:\Windows\System32\imm32.dll    6.2.14393.0
bcrypt.dll    C:\Windows\System32\bcrypt.dll    6.2.14393.2969
cryptsp.dll    C:\Windows\System32\cryptsp.dll    6.2.14393.2969
rsaenh.dll    C:\Windows\System32\rsaenh.dll    6.2.14393.2969
CRYPTBASE.dll    C:\Windows\System32\CRYPTBASE.dll    6.2.14393.0
bcryptPrimitives.dll    C:\Windows\System32\bcryptPrimitives.dll    6.2.14393.2969
NapiNSP.dll    C:\Windows\System32\NapiNSP.dll    6.2.14393.0
dnsapi.dll    C:\Windows\System32\dnsapi.dll    6.2.14393.2999
nsi.dll    C:\Windows\System32\nsi.dll    6.2.14393.2969
IPHLPAPI.DLL    C:\Windows\System32\IPHLPAPI.DLL    6.2.14393.2339
winrnr.dll    C:\Windows\System32\winrnr.dll    6.2.14393.0
nlaapi.dll    C:\Windows\System32\nlaapi.dll    6.2.14393.3143
rasadhlp.dll    C:\Windows\System32\rasadhlp.dll    6.2.14393.0
FWPUCLNT.DLL    C:\Windows\System32\FWPUCLNT.DLL    6.2.14393.0

and you can find file.mdmp at attached files.

Just in case someone still have problems with doCreatureAddHealth on statsChange, I recommend taking a look at this fix I put on otx2.

The fix itself is just this: FIX1

It was latter optimized to only call the 'getSpectators' function when the creature has been moved.It can be found here: Begin Optimization and Finishing Optimization.

With this, there shouldn't be any more issues related to doCreatureAddHealth() on statsChange.
i will check if i have this fix or no, thanks for it.

@Deatthraz and what do you mean with this ( but still i recommend you to change statsChange to prepareDeath instead. ) ?
 

Attachments

  • theforgottenserver_23-10-2019_09-46-09.rar
    45.7 KB · Views: 3 · VirusTotal
Last edited:
How did you create this crash dump? I don't think it has any helpful info about the exact crash reason.
Follow this to create a crash dump on Windows

and I would suggest you moving your server from C: to different partition or run as Administrator and allow User account settings to access/read/write server files and folders.
 
How did you create this crash dump? I don't think it has any helpful info about the exact crash reason.
Follow this to create a crash dump on Windows

and I would suggest you moving your server from C: to different partition or run as Administrator and allow User account settings to access/read/write server files and folders.
I added it long time ago from this post
 
Back
Top