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

getting error when using isInArea

Dridia

New Member
Joined
Jan 17, 2012
Messages
49
Reaction score
1
Location
Sweden
I got a problem, im trying to make a script that creates a bridge when pulling the lever and that works perfect. It's like a hidde quest, so it creates a bridge over to an island and i want if you are on that island when the "lever function" resets i want the player/players to teleport out of it.

Here is my code:
Lua:
local addpos = {x=1040, y=1016, z=8, stackpos=1}
local lavaone = 4809
local lavatwo = 4811
local lavathree = 598
local tele = {
		a = {x =1039, z =1016, y =8},
		b = {x =1039, z =1015, y =8},
		c = {x =1041, z =1016, y =8}
	}

function onUse(cid, item, fromPos, item2, toPos)
	if item.itemid == 1945 then
		doCreateItem(1284,1,{x=1040, y=1016, z=8})
		doRemoveItem(getThingfromPos(stonepos).uid, 1)
		doRemoveItem(getThingfromPos(stonepos).uid, 1)		
		doPlayerSendTextMessage(cid,22,"You heard a noise to the north-west")
		doTransformItem(item.uid,1946)
		addEvent(onTimer5, 10*1000)
	end
return true
end
 
function onTimer5()
	doTransformItem(getThingFromPos({x=1049, y=1023, z=8, stackpos=1}).uid, 1945)
	doRemoveItem(getThingfromPos(stonepos).uid, 1)
	doCreateItem(lavaone,1,{x=1040, y=1016, z=8})
	doCreateItem(lavatwo,1,{x=1040, y=1016, z=8})
	doCreateItem(lavathree,1,{x=1040, y=1016, z=8})
	if isInArea(getPlayerPosition(cid), tele.a, tele.b) then
		doTeleportThing(cid,tele.c)
	end
end

I'm getting these two errors:

Code:
[Error - Action Interface]
In a timer event called from:
data/actions/scripts/custom/hiddenquest.lua:onUse
Description:
data/lib/032-position.lua:2: attempt to index local 'position' <a boolean value>
-------------
stack traceback:
data/lib/032-position.lua:2: in function 'isInArea'
..ta/actions/scripts/custom/hiddenquest.lua:29: in function <...ta/actions/scripts/custom/hiddenquest.lua:23:
 
Because there:
PHP:
if isInArea(getPlayerPosition(cid), tele.a, tele.b) then
function getPlayerPosition return false.


Fixed
PHP:
local addpos = {x=1040, y=1016, z=8, stackpos=1}
local lavaone = 4809
local lavatwo = 4811
local lavathree = 598
local tele = {
		a = {x =1039, z =1016, y =8},
		b = {x =1039, z =1015, y =8},
		c = {x =1041, z =1016, y =8}
	}
 
function onUse(cid, item, fromPos, item2, toPos)
	if item.itemid == 1945 then
		doCreateItem(1284,1,{x=1040, y=1016, z=8})
		doRemoveItem(getThingfromPos(stonepos).uid, 1)
		doRemoveItem(getThingfromPos(stonepos).uid, 1)		
		doPlayerSendTextMessage(cid,22,"You heard a noise to the north-west")
		doTransformItem(item.uid,1946)
		addEvent(onTimer5, 10*1000, cid)
	end
return true
end
 
function onTimer5(cid)
	doTransformItem(getThingFromPos({x=1049, y=1023, z=8, stackpos=1}).uid, 1945)
	doRemoveItem(getThingfromPos(stonepos).uid, 1)
	doCreateItem(lavaone,1,{x=1040, y=1016, z=8})
	doCreateItem(lavatwo,1,{x=1040, y=1016, z=8})
	doCreateItem(lavathree,1,{x=1040, y=1016, z=8})
	if isInArea(getPlayerPosition(cid), tele.a, tele.b) then
		doTeleportThing(cid,tele.c)
	end
end
 
Because there:
PHP:
if isInArea(getPlayerPosition(cid), tele.a, tele.b) then
function getPlayerPosition return false.


Fixed
PHP:
local addpos = {x=1040, y=1016, z=8, stackpos=1}
local lavaone = 4809
local lavatwo = 4811
local lavathree = 598
local tele = {
		a = {x =1039, z =1016, y =8},
		b = {x =1039, z =1015, y =8},
		c = {x =1041, z =1016, y =8}
	}
 
function onUse(cid, item, fromPos, item2, toPos)
	if item.itemid == 1945 then
		doCreateItem(1284,1,{x=1040, y=1016, z=8})
		doRemoveItem(getThingfromPos(stonepos).uid, 1)
		doRemoveItem(getThingfromPos(stonepos).uid, 1)		
		doPlayerSendTextMessage(cid,22,"You heard a noise to the north-west")
		doTransformItem(item.uid,1946)
		addEvent(onTimer5, 10*1000, cid)
	end
return true
end
 
function onTimer5(cid)
	doTransformItem(getThingFromPos({x=1049, y=1023, z=8, stackpos=1}).uid, 1945)
	doRemoveItem(getThingfromPos(stonepos).uid, 1)
	doCreateItem(lavaone,1,{x=1040, y=1016, z=8})
	doCreateItem(lavatwo,1,{x=1040, y=1016, z=8})
	doCreateItem(lavathree,1,{x=1040, y=1016, z=8})
	if isInArea(getPlayerPosition(cid), tele.a, tele.b) then
		doTeleportThing(cid,tele.c)
	end
end

Sorry, but now it's more fucked x)

Code:
data/actions/scripts/custom/hiddenquest.lua:onuse Description:
attempt to index a nil value 
stack traceback: 
 [C]: in funtion 'getThingfromPos'
...ta/actions/scipts/custom/hiddenquest.lua:14: in function <...ta/actions/scripts/custom/hiddenquest.lua:11:
 

Similar threads

Back
Top