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

Help with my script

mikeware

New Member
Joined
Jul 17, 2007
Messages
338
Reaction score
0
Location
Brazil
login.lua:
Code:
local combat =
{
	-- combat Arena:
	{
		fromPosition = {x = 104, y = 501, z = 8},
		toPosition = {x = 112, y = 508, z = 8},
	},

}

function onLogin(cid)
	if isInPosition(getCreaturePosition(cid), combat.fromPosition, combat.toPosition) then
		doTeleportThing(cid, {x = 112, y = 478, z = 7}, TRUE)
	else
	return TRUE
	end
end

Im trying to when somebody are inside the selected position and login, he ill be teleported to another place, but im getting a error on console:

Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/login.lua:eek:nLogin

data/global.lua:412: attempt to index local 'fromPos' (a nil value)

Don't know if im selecting wrong the tiles... Here is how im selecting:
Code:
frompos
\/
 ......................
|.....................|
|.....................|
|.....................|
|.....................|
|.....................|  < topos
 
Code:
function isInPosition(pos, fromPos, toPos)
	if pos.x >= fromPos.x and pos.y >= fromPos.y and pos.z >= fromPos.z and pos.x <= toPos.x and pos.y <= toPos.y and pos.z <= toPos.z then
		return true
	end
	return false
end

thats the line 411 to 416
 
You should know that Lua is CS (case sensitive). This means that 'TRUE' does not equal 'true'
So, try to use 'true' instead of 'TRUE'
 
Code:
local combat =
{
	fromPosition = {x = 104, y = 501, z = 8},
	toPosition = {x = 112, y = 508, z = 8}

}

function onLogin(cid)
	if isInPosition(getCreaturePosition(cid), combat.fromPosition, combat.toPosition) then
		doTeleportThing(cid, {x = 112, y = 478, z = 7}, TRUE)
	else
	return TRUE
	end
end
 
Code:
local combat =
{
	fromPosition = {x = 104, y = 501, z = 8},
	toPosition = {x = 112, y = 508, z = 8}

}

function onLogin(cid)
	if isInPosition(getCreaturePosition(cid), combat.fromPosition, combat.toPosition) then
		doTeleportThing(cid, {x = 112, y = 478, z = 7}, TRUE)
	else
	return TRUE
	end
end

thanks niller, problem solved :)
 
Back
Top