zxzxzx
New Member
- Joined
- Mar 12, 2011
- Messages
- 334
- Reaction score
- 3
Hello! I have errors when using this dhq on tfs 1.2+ how to solve it?
errors:
Argument #3 is unsafe
function addevent (lua 27, lua 18)
main interface (lua 57, lua 52) (attempt to index local "lever" (a number value)
the code:
errors:
Argument #3 is unsafe
function addevent (lua 27, lua 18)
main interface (lua 57, lua 52) (attempt to index local "lever" (a number value)
the code:
Code:
local pinkstonepos1 = {x=32670, y=32806, z=8, stackpos=1} -- Blocking stone position.
local TeleportToPos = { x = 988, y = 997, z = 12, stackpos=2} -- Position the player will be ported to when leaving the DHQ, like the Temple...
local TeleportOutPos = { x = 32676, y = 32806, z = 8, stackpos=1} -- where tp is created
local timeToRemove = 5 -- Time before quest reset
local starting= {x = 32673, y = 32802, z = 8} -- edit this to the top left sqm of ur annhilator room
local ending= {x = 32678, y = 32810, z = 8} -- edit this to the bottom right sqm of ur annhilator room
local monster = {
{position = {x=1032, y=1095, z=8}, creature = "demon"},
{position = {x=1032, y=1098, z=8}, creature = "demon"},
{position = {x=1034, y=1096, z=8}, creature = "demon"},
{position = {x=1037, y=1095, z=8}, creature = "demon"},
{position = {x=1037, y=1098, z=8}, creature = "demon"},
{position = {x=1036, y=1092, z=8}, creature = "banshee"},
{position = {x=1036, y=1100, z=8}, creature = "banshee"},
{position = {x=1039, y=1097, z=8}, creature = "banshee"}
}
function onUse(cid, item, fromPos, item2, toPos)
local hi = false
if (cleanArea(starting, ending)) then
if item.itemid == 1945 then
doRemoveItem(getThingfromPos(pinkstonepos1).uid, 1)
doCreateTeleport(1387, TeleportToPos, TeleportOutPos)
doSendMagicEffect(TeleportOutPos, CONST_ME_TELEPORT)
doCreatureSay(cid, "You have " .. timeToRemove .. " seconds to go into de teleport!", TALKTYPE_ORANGE_1)
doTransformItem(item.uid,1946)
addEvent(doRemoveTeleport, 1000 * timeToRemove, item, TeleportOutPos)
elseif item.itemid == 1946 then
doPlayerSendCancel(cid,"Sorry, not possible.") -- message if the lever is pulled again.
end
else
doPlayerSendCancel(cid,"You have to kill all the monsters before you can pull it!")
end
return true
end
function cleanArea(a,b)
for ix = a.x, b.x do
for iy = a.y, b.y do
local CheckTile = getThingfromPos({x = ix, y = iy, z = a.z, stackpos = 255})
if isCreature(CheckTile.uid) == TRUE and isPlayer(CheckTile.uid) ~= TRUE then
return false
end
end
end
return true
end
function doRemoveTeleport(lever, teleporter)
if getThingfromPos(teleporter).itemid == 1387 then
doCreateItem(1355, 1, pinkstonepos1)
doRemoveItem(getThingfromPos(teleporter).uid,1)
doSendMagicEffect(teleporter, CONST_ME_POFF)
doTransformItem(lever.uid, 1945)
respawn()
end
return true
end
function respawn()
for i = 1, #monster do
doSummonCreature(monster.creature, monster.position)
end
end