• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

DHQ for 1.2

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:
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
 
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 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

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
Don't put functions that you're calling below addEvent.
 
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 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

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
Don't put functions that you're calling below addEvent.

you mean don't use this?
Code:
addEvent(doRemoveTeleport, 1000 * timeToRemove, item, TeleportOutPos)
 
No, I'm saying don't try calling a function that's at the bottom of the script.
But if I don't try to call this function the script will work wrong? anyway I pasted your corrected script and when I pull the lever I have:

error in lua 57, now lua 48

new error:
lua script error main interface
in a timer event called from
unknown scriptfile

lua 36 attempt to index local lever" a number value
stack traceback lua 36/31

what I need to change? can you post solved code? or I need to change something in a other file?
 
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 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, 1945)
respawn()
end
return true
end

function respawn()
for i = 1, #monster do
doSummonCreature(monster.creature, monster.position)
end
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
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.uid, 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
 
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 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, 1945)
respawn()
end
return true
end

function respawn()
for i = 1, #monster do
doSummonCreature(monster.creature, monster.position)
end
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
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.uid, 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

OK now works! thanks ;)
 
Back
Top