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

Solved Problem with my server pls help

Cristian2387

New Member
Joined
Oct 2, 2014
Messages
34
Reaction score
0
Hi, I added a zombie event to my server everything worked fine the thing is that this one script that i added that came with the zombie event doesn't let monsters attack the players i dont know why its weird xd here is the script thats cousing me problems
Code:
function loseOnZombieArena(cid)
    kickPlayerFromZombiesArea(cid)
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "BOOM! You are dead.")
    local players = getZombiesEventPlayers()
    if(#players <= 1) then
        local winner = players[1]
        if(winner) then
            doPlayerAddItem(winner, 7443, 1, true)
            doPlayerAddItem(winner, 5108, 1, true)
            doPlayerSendTextMessage(winner, MESSAGE_STATUS_CONSOLE_BLUE, "You won zombies arena event.")
            doBroadcastMessage("After " .. os.time() - getPlayerZombiesEventStatus(winner) .. " seconds of fight " .. getCreatureName(winner) .. " won Zombie Arena Event in game versus " .. getStorage(ZE_ZOMBIES_SPAWNED) .. " zombies!")
            kickPlayerFromZombiesArea(winner)
        else
            doBroadcastMessage("Zombie arena event finished! No one win?!?!?! WTF!")
        end
        doSetStorage(ZE_STATUS, 0)
        doSetStorage(ZE_PLAYERS_NUMBER, ZE_DEFAULT_NUMBER_OF_PLAYERS)
        doSetStorage(ZE_ZOMBIES_TO_SPAWN, 0)
        doSetStorage(ZE_ZOMBIES_SPAWNED, 0)
        local width = (math.max(ZE_spawnFromPosition.x, ZE_spawnToPosition.x) - math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)) / 2 + 1
        local height = (math.max(ZE_spawnFromPosition.y, ZE_spawnToPosition.y) - math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)) / 2 + 1
        local centerPos = {x=math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)+width,y=math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)+height,z=ZE_spawnFromPosition.z}
        for z = math.min(ZE_spawnFromPosition.z, ZE_spawnToPosition.z), math.max(ZE_spawnFromPosition.z, ZE_spawnToPosition.z) do
            centerPos.z = z
            for i, uid in pairs(getSpectators(centerPos, width, height, false)) do
                if(isMonster(uid)) then
                    doRemoveCreature(uid)
                end
            end
        end
    end
end
function onStatsChange(target, cid, changetype, combat, value)
    if((cid and isMonster(cid) and getCreatureName(cid) == "Zombie Event") or (isInRange(getThingPosition(target), ZE_spawnFromPosition, ZE_spawnToPosition) and changetype == STATSCHANGE_HEALTHLOSS and math.abs(value) >= getCreatureHealth(target))) then
        doCreatureAddHealth(target, getCreatureMaxHealth(target))
        loseOnZombieArena(target)
        return false
    end
    return true
end
this is the error i get
Code:
[12/10/2014 10:56:50] [Error - CreatureScript Interface]
[12/10/2014 10:56:50] data/creaturescripts/scripts/zombie/onattack.lua:onStatsChange
[12/10/2014 10:56:50] Description:
[12/10/2014 10:56:50] data/lib/032-position.lua:2: attempt to index global 'position' (a nil value)
[12/10/2014 10:56:50] stack traceback:
[12/10/2014 10:56:50]     data/lib/032-position.lua:2: in function 'isInRange'
[12/10/2014 10:56:50]     data/creaturescripts/scripts/zombie/onattack.lua:34: in function <data/creaturescripts/scripts/zombie/onattack.lua:33>
pls help me resolve this problem, thank you
 
Replace function isInRange in data/lib/032-position.lua with this.
Code:
function isInRange(position, fromPosition, toPosition)
     return (position.x >= fromPosition.x and position.y >= fromPosition.y and position.z >= fromPosition.z and position.x <= toPosition.x and position.y <= toPosition.y and position.z <= toPosition.z)
end
 
Replace function isInRange in data/lib/032-position.lua with this.
Code:
function isInRange(position, fromPosition, toPosition)
     return (position.x >= fromPosition.x and position.y >= fromPosition.y and position.z >= fromPosition.z and position.x <= toPosition.x and position.y <= toPosition.y and position.z <= toPosition.z)
end
O: thank you <3
 
Back
Top