[04/12/2009 17:35:50] Lua Script Error: [Action Interface]
[04/12/2009 17:35:50] data/actions/scripts/lever.lua:onUse
[04/12/2009 17:35:50] data/actions/scripts/lever.lua:54: attempt to compare table with number
[04/12/2009 17:35:50] stack traceback:
[04/12/2009 17:35:50] data/actions/scripts/lever.lua:54: in function <data/actions/scripts/lever.lua:41>
local config = {
-- level needed to make the quest
level = 20,
-- if players should be able to do the quest unlimited amount of times (not conflicting quest rewards)
redo = {
status = true, -- true = unlimited, false = once
storageValue = 4535 -- only if status is false this will be used
},
-- vocation requirement, positions and item configuration
{
vocations = {1, 5},
itemId = 2175,
playerPos = {x=32677, y=32089, z=8},
newPos = {x=32671, y=32069, z=8},
itemPos = {x=32679, y=32089, z=8}
},
{
vocations = {2, 6},
itemId = 2674,
playerPos = {x=32669, y=32089, z=8},
newPos = {x=32672, y=32069, z=8},
itemPos = {x=32667, y=32089, z=8}
},
{
vocations = {3, 7},
itemId = 2455,
playerPos = {x=32673, y=32085, z=8},
newPos = {x=32671, y=32070, z=8},
itemPos = {x=32673, y=32083, z=8}
},
{
vocations = {4, 8},
itemId = 2376,
playerPos = {x=32673, y=32093, z=8},
newPos = {x=32672, y=32070, z=8},
itemPos = {x=32673, y=32094, z=8}
}
}
function onUse(cid)
local players = {}
for _, v in ipairs(config) do
local player = getTopCreature(v.playerPos).uid
if isPlayer(player) == FALSE then
return doPlayerSendCancel(cid, "There are not enough players.")
elseif getPlayerLevel(player) < config.level then
players.level = true
elseif isInArray(v.vocations, getPlayerVocation(player)) == FALSE then
players.vocation = true
elseif config.redo.status and getPlayerStorageValue(cid, config.redo.storageValue) ~= TRUE then
players.done = false
else
if getTileItemById(v.itemPos, v.itemId) < 1 then
players.item = true
else
table.insert(players, player)
end
end
end
if players.level then
doPlayerSendCancel(cid, "All players need to be level " .. config.level .. " or above.")
elseif players.vocation then
doPlayerSendCancel(cid, "All players must stand on the correct tiles.")
elseif players.done then
doPlayerSendCancel(cid, "A player in your team has already done this quest.")
elseif players.item then
doPlayerSendCancel(cid, "All items must be on the correct positions.")
else
for k, player in ipairs(players) do
doSendMagicEffect(getCreaturePosition(player), CONST_ME_POFF)
doTeleportThing(player, config[k].newPos)
doSendMagicEffect(getCreaturePosition(player), CONST_ME_TELEPORT)
end
end
return TRUE
end
Code:local config = { -- level needed to make the quest level = 20, -- if players should be able to do the quest unlimited amount of times (not conflicting quest rewards) redo = { status = true, -- true = unlimited, false = once storageValue = 4535 -- only if status is false this will be used }, -- vocation requirement, positions and item configuration { vocations = {1, 5}, itemId = 2175, playerPos = {x=32677, y=32089, z=8}, newPos = {x=32671, y=32069, z=8}, itemPos = {x=32679, y=32089, z=8} }, { vocations = {2, 6}, itemId = 2674, playerPos = {x=32669, y=32089, z=8}, newPos = {x=32672, y=32069, z=8}, itemPos = {x=32667, y=32089, z=8} }, { vocations = {3, 7}, itemId = 2455, playerPos = {x=32673, y=32085, z=8}, newPos = {x=32671, y=32070, z=8}, itemPos = {x=32673, y=32083, z=8} }, { vocations = {4, 8}, itemId = 2376, playerPos = {x=32673, y=32093, z=8}, newPos = {x=32672, y=32070, z=8}, itemPos = {x=32673, y=32094, z=8} } } function onUse(cid) local players = {} for _, v in ipairs(config) do local player = getTopCreature(v.playerPos).uid if isPlayer(player) == FALSE then return doPlayerSendCancel(cid, "There are not enough players.") elseif getPlayerLevel(player) < config.level then players.level = true elseif isInArray(v.vocations, getPlayerVocation(player)) == FALSE then players.vocation = true elseif config.redo.status and getPlayerStorageValue(cid, config.redo.storageValue) ~= TRUE then players.done = false else if getTileItemById(v.itemPos, v.itemId) < 1 then players.item = true else table.insert(players, player) end end end if players.level then doPlayerSendCancel(cid, "All players need to be level " .. config.level .. " or above.") elseif players.vocation then doPlayerSendCancel(cid, "All players must stand on the correct tiles.") elseif players.done then doPlayerSendCancel(cid, "A player in your team has already done this quest.") elseif players.item then doPlayerSendCancel(cid, "All items must be on the correct positions.") else for k, player in ipairs(players) do doSendMagicEffect(getCreaturePosition(player), CONST_ME_POFF) doTeleportThing(player, config[k].newPos) doSendMagicEffect(getCreaturePosition(player), CONST_ME_TELEPORT) end end return TRUE end
function onUse(cid)
local players = {}
for _, v in ipairs(config) do
local player = getTopCreature(v.playerPos).uid
if isPlayer(player) == FALSE then
return doPlayerSendCancel(cid, "There are not enough players.")
elseif getPlayerLevel(player) < config.level then
players.level = true
elseif isInArray(v.vocations, getPlayerVocation(player)) == FALSE then
players.vocation = true
elseif config.redo.status and getPlayerStorageValue(cid, config.redo.storageValue) == FALSE then
players.done = true
else
if getTileItemById(v.itemPos, v.itemId) < 1 then
players.item = true
else
table.insert(players, player)
end
end
end
if players.level then
doPlayerSendCancel(cid, "All players need to be level " .. config.level .. " or above.")
elseif players.vocation then
doPlayerSendCancel(cid, "All players must stand on the correct tiles.")
elseif players.done then
doPlayerSendCancel(cid, "A player in your team has already done this quest.")
elseif players.item then
doPlayerSendCancel(cid, "All items must be on the correct positions.")
else
for k, player in ipairs(players) do
doSendMagicEffect(getCreaturePosition(player), CONST_ME_POFF)
doTeleportThing(player, config[k].newPos)
doSendMagicEffect(getCreaturePosition(player), CONST_ME_TELEPORT)
end
end
return TRUE
end
[05/12/2009 17:38:26] Lua Script Error: [Action Interface]
[05/12/2009 17:38:26] data/actions/scripts/lever.lua:onUse
[05/12/2009 17:38:27] data/actions/scripts/lever.lua:52: attempt to compare table with number
[05/12/2009 17:38:27] stack traceback:
[05/12/2009 17:38:27] data/actions/scripts/lever.lua:52: in function <data/actions/scripts/lever.lua:39>
plz place config-related things before the function and use getTileItemById instead of getThingfromPos (you can drop stackpos)Change local switchUID to the correct unique id your lever uses.
Code:function onUse(cid, item, fromPosition, itemEx, toPosition) local switchUID = 6000 -- Unique ID of the Switch local positions = { players = { {x = 100, y = 100, z = 7, stackpos = 253}, -- Sorc {x = 100, y = 100, z = 7, stackpos = 253}, -- Druid {x = 100, y = 100, z = 7, stackpos = 253}, -- Paladin {x = 100, y = 100, z = 7, stackpos = 253} -- Knight } items = { {x = 100, y = 100, z = 7, stackpos = 2}, -- Spellbook {x = 100, y = 100, z = 7, stackpos = 2}, -- Apple {x = 100, y = 100, z = 7, stackpos = 2}, -- Crossbow {x = 100, y = 100, z = 7, stackpos = 2} -- Sword } new = { {x = 100, y = 100, z = 7}, -- New Sorc Spot {x = 100, y = 100, z = 7}, -- New Druid Spot {x = 100, y = 100, z = 7}, -- New Paladin Spot {x = 100, y = 100, z = 7} -- New Knight Spot } } local vocations = { 1, 2, 3, 4 } local questItems = { {2175},{2674},{2455},{2376} } if (item.itemid == 1945) and (item.uid == switchUID) then if (isPlayer(getThingfromPos(positions.players[i]))) then if (getPlayerVocation(getThingfromPos(positions.players[i])) == vocations[i]) then if (getThingFromPos(positions.items[i]).itemid == questItems[i]) then for i = 1, 4 do doTeleportThing(getThingfromPos(positions.players[i]), positions.new[i]) doRemoveItem(getThingfromPos(positions.items[i]), questItems[i].uid) doSendMagicEffect(positions.players[i], CONST_ME_POFF) doSendMagicEffect(positions.items[i], CONST_ME_POFF) doSendMagicEffect(positions.new[i], CONST_ME_TELEPORT) end else doPlayerSendCancel(cid, "The items are not on the correct spots.") end else doPlayerSendCancel(cid, "All players must be on the correct spots.") end else doPlayerSendCancel(cid, "You need four players to do this quest.") end elseif (item.itemid == 1946) then doTransformItem(item.uid, item.itemid - 1) end return TRUE end
function onUse(cid, item, fromPosition, itemEx, toPosition)
local switchUID = 6000 -- Unique ID of the Switch
local positions = {
players = {
{x = 100, y = 100, z = 7, stackpos = 253}, -- Sorc
{x = 100, y = 100, z = 7, stackpos = 253}, -- Druid
{x = 100, y = 100, z = 7, stackpos = 253}, -- Paladin
{x = 100, y = 100, z = 7, stackpos = 253} -- Knight
},
items = {
{x = 100, y = 100, z = 7, stackpos = 2}, -- Spellbook
{x = 100, y = 100, z = 7, stackpos = 2}, -- Apple
{x = 100, y = 100, z = 7, stackpos = 2}, -- Crossbow
{x = 100, y = 100, z = 7, stackpos = 2} -- Sword
},
new = {
{x = 100, y = 100, z = 7}, -- New Sorc Spot
{x = 100, y = 100, z = 7}, -- New Druid Spot
{x = 100, y = 100, z = 7}, -- New Paladin Spot
{x = 100, y = 100, z = 7} -- New Knight Spot
}
}
local vocations = { 1, 2, 3, 4 }
local questItems = { {2175},{2674},{2455},{2376} }
if (item.itemid == 1945) and (item.uid == switchUID) then
if (isPlayer(getThingfromPos(positions.players[i]))) == true then
if (getPlayerVocation(getThingfromPos(positions.players[i])) == vocations[i]) then
if (getThingfromPos(positions.items[i]).itemid == questItems[i]) then
for i = 1, 4 do
doTeleportThing(getThingfromPos(positions.players[i]), positions.new[i])
doRemoveItem(getThingfromPos(positions.items[i]), questItems[i].uid)
doSendMagicEffect(positions.players[i], CONST_ME_POFF)
doSendMagicEffect(positions.items[i], CONST_ME_POFF)
doSendMagicEffect(positions.new[i], CONST_ME_TELEPORT)
end
else
doPlayerSendCancel(cid, "The items are not on the correct spots.")
end
else
doPlayerSendCancel(cid, "All players must be on the correct spots.")
end
else
doPlayerSendCancel(cid, "You need four players to do this quest.")
end
elseif (item.itemid == 1946) then
doTransformItem(item.uid, item.itemid - 1)
end
return TRUE
end
plz place config-related things before the function and use getTileItemById instead of getThingfromPos (you can drop stackpos)
[08/12/2009 16:12:36] Lua Script Error: [Action Interface]
[08/12/2009 16:12:37] data/actions/scripts/lever.lua:onUse
[08/12/2009 16:12:37] attempt to index a nil value
[08/12/2009 16:12:37] stack traceback:
[08/12/2009 16:12:37] [C]: in function 'getThingfromPos'
[08/12/2009 16:12:37] data/actions/scripts/lever.lua:28: in function <data/actions/scripts/lever.lua:1
function onUse(cid, item, fromPosition, itemEx, toPosition)
local switchUID = 6000 -- Unique ID of the Switch
local positions = {
players = {
{x = 100, y = 100, z = 7, stackpos = 253}, -- Sorc
{x = 100, y = 100, z = 7, stackpos = 253}, -- Druid
{x = 100, y = 100, z = 7, stackpos = 253}, -- Paladin
{x = 100, y = 100, z = 7, stackpos = 253} -- Knight
},
items = {
{x = 100, y = 100, z = 7, stackpos = 2}, -- Spellbook
{x = 100, y = 100, z = 7, stackpos = 2}, -- Apple
{x = 100, y = 100, z = 7, stackpos = 2}, -- Crossbow
{x = 100, y = 100, z = 7, stackpos = 2} -- Sword
},
new = {
{x = 100, y = 100, z = 7}, -- New Sorc Spot
{x = 100, y = 100, z = 7}, -- New Druid Spot
{x = 100, y = 100, z = 7}, -- New Paladin Spot
{x = 100, y = 100, z = 7} -- New Knight Spot
}
}
local vocations = { 1, 2, 3, 4 }
local questItems = { {2175},{2674},{2455},{2376} }
if (item.itemid == 1945) and (item.uid == switchUID) then
for i = 1,4 do
if (isPlayer(getThingfromPos(positions.players[i]))) == TRUE then
if (getPlayerVocation(getThingfromPos(positions.players[i])) == vocations[i]) then
if (getThingfromPos(positions.items[i]).itemid == questItems[i]) then
doTeleportThing(getThingfromPos(positions.players[i]), positions.new[i])
doRemoveItem(getThingfromPos(positions.items[i]), questItems[i].uid)
doSendMagicEffect(positions.players[i], CONST_ME_POFF)
doSendMagicEffect(positions.items[i], CONST_ME_POFF)
doSendMagicEffect(positions.new[i], CONST_ME_TELEPORT)
else
doPlayerSendCancel(cid, "The items are not on the correct spots.")
end
else
doPlayerSendCancel(cid, "All players must be on the correct spots.")
end
else
doPlayerSendCancel(cid, "You need four players to do this quest.")
end
end
elseif (item.itemid == 1946) then
doTransformItem(item.uid, item.itemid - 1)
end
return TRUE
end