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

[Actions] Annihilator Problem

Rala Knighta

StCarlo! :]
Joined
Mar 25, 2008
Messages
629
Reaction score
2
Location
Germany
Hi,
I got a Problem with my Annihilator Script...
If i use the Switch... these Errors comes

Code:
[01/06/2009 20:13:19] Lua Script Error: [Action Interface] 
[01/06/2009 20:13:19] data/actions/scripts/quests/annihilator.lua:onUse

[01/06/2009 20:13:19] luaDoCreateMonster(). Cannot create monster: Demon

[01/06/2009 20:13:19] Lua Script Error: [Action Interface] 
[01/06/2009 20:13:19] data/actions/scripts/quests/annihilator.lua:onUse

[01/06/2009 20:13:19] luaDoCreateMonster(). Cannot create monster: Demon

[01/06/2009 20:13:19] Lua Script Error: [Action Interface] 
[01/06/2009 20:13:19] data/actions/scripts/quests/annihilator.lua:onUse

[01/06/2009 20:13:19] luaDoCreateMonster(). Cannot create monster: Demon

[01/06/2009 20:13:19] Lua Script Error: [Action Interface] 
[01/06/2009 20:13:19] data/actions/scripts/quests/annihilator.lua:onUse

[01/06/2009 20:13:19] luaDoCreateMonster(). Cannot create monster: Demon

I got this Script


PHP:
-- Credits to GrizZm0 for most of the script
-- Credits to Tworn for the cleanArea(), a bit modified by Ispiro
-- Credits to Ispiro for a more easier script to configurate and easier to read.

local starting= {x = 452, y = 1125, z = 8} -- edit this to the top left sqm of ur annhilator room
local ending= {x = 498, y = 1126, z = 8} -- edit this to the bottom right sqm of ur annhilator room

local playerPos = { -- oldPositions; positions of players before they get teleported.
    {x = 461, y = 1131, z = 8},
    {x = 462, y = 1131, z = 8},
    {x = 463, y = 1131, z = 8},
    {x = 464, y = 1131, z = 8}
}

local newPlayerPos = { -- Positions for where players should be teleported, make sure it's in the same order as oldPositions
    {x = 485, y = 1126, z = 8},
    {x = 486, y = 1126, z = 8},
    {x = 487, y = 1126, z = 8},
    {x = 488, y = 1126, z = 8}
}
       
local creaturePos = { -- Name and position of monsters to summon.
    {"Demon", {x = 485, y = 1124, z = 8}},
    {"Demon", {x = 487, y = 1124, z = 8}},
    {"Demon", {x = 486, y = 1128, z = 8}},
    {"Demon", {x = 488, y = 1128, z = 8}},
    {"Demon", {x = 489, y = 1126, z = 8}},
    {"Demon", {x = 490, y = 1126, z = 8}}
}

if(#playerPos ~= #newPlayerPos) then
    error("Annhilator has not been properly configured.")
end
--- Preferably, do not edit anything below this line unless you know exactly what you are doing.
local player = {}

function onUse(cid, item, frompos, item2, topos)
    if(item.uid == 5000) then --- change to different item.uid according to ur mapeditor
        if(item.itemid == 1946) then
            for i, pos in ipairs(playerPos) do -- add player id's to table
                player[i] = getTopCreature(pos).uid or getTopCreature(pos)
            end
            local ret, players = checkPlayers(cid)
            if(ret) then
                local ret, player = checkLevel(100)
                if(ret) then
                    local ret, player = checkStorage(100)
                    if(ret) then
                        summonCreatures(creaturePos)
                        teleportPlayers(2, 10) -- 2 stands for the effect on old pos, 10 for the effect on new pos.
                        doTransformItem(item.uid, 1946)
                    else
                        sendPlayersText(players, getPlayerName(player) .. " has already done this quest.")
                    end
                else
                    sendPlayersText(players, getPlayerName(player) .. " is too low.")
                end
            else
                sendPlayersText(players, "You need " .. #playerPos .. " players to do this quest.")
            end
        elseif(item.itemid == 1946) then -- preferably, to be the id of the lever added by mapeditor.
            if(cleanArea()) then
                doTransformItem(item.uid, 1945)
            else
                return FALSE
            end
        end
        return TRUE
    --- Chests.
    elseif(item.uid == 5001) then -- demon armor
        return questChestPrize(cid, 2494, 100)
    elseif(item.uid == 5002) then -- magic sword
        return questChestPrize(cid, 2400, 100)
    elseif(item.uid == 5003) then -- stonecutter's axe
        return questChestPrize(cid, 2431, 100)
    elseif(item.uid == 5004) then -- golden helmet
        return questChestPrize(cid, 2471, 100)             
    end
end

function sendPlayersText(players, text)
    for _, player in ipairs(players) do
        doPlayerSendCancel(player, text)
    end
end

function questChestPrize(cid, itemid, storage)
    if(getPlayerStorageValue(cid, storage) < TRUE) then
        doPlayerAddItem(cid, itemid, 1)
        setPlayerStorageValue(cid, storage, TRUE)
        local item = getItemDescriptions(itemid)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found " .. item.article .. " " .. item.name .. "")
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.")
    end
    return TRUE
end

function checkLevel(minLevel)
    for _, player in ipairs(player) do
        if(getPlayerLevel(player) < minLevel) then
            return false, player
        end
    end
    return true
end

function checkStorage(storageValue)
    for _, player in ipairs(player) do
        if(getPlayerStorageValue(player, storageValue) ~= TRUE) then
            return false, player
        end
    end
    return true
end

function cleanArea()
    local checking= {x = starting.x, y = starting.y, z = starting.z, stackpos = 253}
    local monster = {}
    while(checking.y <= ending.y) do
        local creature = getTopCreature(checking)
        if(isCreature(creature) == TRUE) then
            if(isPlayer(creature) == TRUE) then
                return false
            else
                table.insert(monster, creature)
            end
        end
        if(checking.x == ending.x) then
            checking.x = starting.x
            checking.y = checking.y + 1
        end
        checking.x = checking.x + 1
    end
    for i, c in ipairs(monster) do
        doRemoveCreature(c)
    end
    return true
end

function summonCreatures(parameters)
    for _, monster in ipairs(parameters) do
        doSummonCreature(monster[1], monster[2])
    end
end

function teleportPlayers(effect1, effect2)
    for currentPlayer = 1, table.getn(player) do
        doTeleportThing(player[currentPlayer], newPlayerPos[currentPlayer])
        doSendMagicEffect(playerPos[currentPlayer], effect1) -- send animation after teleport, players teleported won't see it anyways
        doSendMagicEffect(newPlayerPos[currentPlayer], effect2)
    end
end

function checkPlayers(cid)
    local ret = {}
    table.insert(ret, cid)
    for _, curPlayer in ipairs(player) do
        if(isPlayer(curPlayer) == TRUE) then
            if(curPlayer ~= cid) then
                table.insert(ret, curPlayer)
            end
        else   
            return false, ret
        end
    end
    return true, ret
end

Also get Quest Error!
PHP:
[01/06/2009 20:30:20] data/actions/scripts/quests/annihilator.lua:88: attempt to compare number with boolean
[01/06/2009 20:30:20] stack traceback:
[01/06/2009 20:30:20] 	data/actions/scripts/quests/annihilator.lua:88: in function <data/actions/scripts/quests/annihilator.lua:87>
[01/06/2009 20:30:20] 	(tail call): ?


And the Switch dont Switch..LoL
I Did the Switch with the action id 5000.
Ofc i did that all on Actions.xml.
PLs Help!

I'll Repp++you :(
 
Last edited:
Actions.xml
[QUOTE<action uniqueid="3030" event="script" value="quests/annihilator.lua"/>[/QUOTE]

annihilator.lua:
-- Annihilator by Shawak v2.1

-- CONFIG --

local room = { -- room with demons
fromX = 958,
fromY = 919,
fromZ = 7,
--------------
toX = 976,
toY = 934,
toZ = 7
}

local monster_pos = {
[1] = {pos = {960, 929, 7}, monster = "Demon"},
[2] = {pos = {959, 933, 7}, monster = "Demon"},
[3] = {pos = {962, 929, 7}, monster = "Demon"},
[4] = {pos = {961, 933, 7}, monster = "Demon"},
[5] = {pos = {963, 931, 7}, monster = "Demon"},
[6] = {pos = {964, 931, 7}, monster = "Demon"}
}

local players_pos = {
{x = 1049, y =1012, z = 7, stackpos = 253},
{x = 1048, y =1012, z = 7, stackpos = 253},
{x = 1047, y =1012, z = 7, stackpos = 253},
{x = 1046, y =1012, z = 7, stackpos = 253}
}

local new_player_pos = {
{x = 962, y = 931, z = 7},
{x = 961, y = 931, z = 7},
{x = 960, y = 931, z = 7},
{x = 959, y = 931, z = 7}
}

local playersOnly = "yes"
local questLevel = 100

------------------------------------------------------
--- CONFIG END ---------------------------------------
------------------------------------------------------

function onUse(cid, item, fromPosition, itemEx, toPosition)
local all_ready, monsters, player, level = 0, 0, {}, 0
if item.itemid == 1945 then
for i = 1, #players_pos do
table.insert(player, 0)
end
for i = 1, #players_pos do
player = getThingfromPos(players_pos)
if player.itemid > 0 then
if string.lower(playersOnly) == "yes" then
if isPlayer(player.uid) == TRUE then
all_ready = all_ready+1
else
monsters = monsters+1
end
else
all_ready = all_ready+1
end
end
end
if all_ready == #players_pos then
for i = 1, #players_pos do
player = getThingfromPos(players_pos)
if isPlayer(player.uid) == TRUE then
if getPlayerLevel(player.uid) >= questLevel then
level = level+1
end
else
level = level+1
end
end
if level == #players_pos then
if string.lower(playersOnly) == "yes" and monsters == 0 or string.lower(playersOnly) == "no" then
for _, area in pairs(monster_pos) do
doSummonCreature(area.monster,{x=area.pos[1],y=area.pos[2],z=area.pos[3]})
end
for i = 1, #players_pos do
doSendMagicEffect(players_pos, CONST_ME_POFF)
doTeleportThing(player.uid, new_player_pos, FALSE)
doSendMagicEffect(new_player_pos, CONST_ME_ENERGYAREA)
doTransformItem(item.uid,1946)
end
else
doPlayerSendTextMessage(cid,19,"Only players can do this quest.")
end
else
doPlayerSendTextMessage(cid,19,"All Players have to be level "..questLevel.." to do this quest.")
end
else
doPlayerSendTextMessage(cid,19,"You need "..table.getn(players_pos).." players to do this quest.")
end
elseif item.itemid == 1946 then
local player_room = 0
for x = room.fromX, room.toX do
for y = room.fromY, room.toY do
for z = room.fromZ, room.toZ do
local pos = {x=x, y=y, z=z,stackpos = 253}
local thing = getThingfromPos(pos)
if thing.itemid > 0 then
if isPlayer(thing.uid) == TRUE then
player_room = player_room+1
end
end
end
end
end
if player_room >= 1 then
doPlayerSendTextMessage(cid,19,"There is already a team in the quest room.")
elseif player_room == 0 then
for x = room.fromX, room.toX do
for y = room.fromY, room.toY do
for z = room.fromZ, room.toZ do
local pos = {x=x, y=y, z=z,stackpos = 253}
local thing = getThingfromPos(pos)
if thing.itemid > 0 then
doRemoveCreature(thing.uid)
end
end
end
end
doTransformItem(item.uid,1945)
end
end
return TRUE
end


Works for me. dont forget to change cordinates.
 
Back
Top