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

Create monster item when onpos

Swiff

Member
Joined
Apr 6, 2009
Messages
366
Reaction score
12
Location
Sweden
So I had an idea, but I had to make some restrictions to make use of it. I can't get it to work, I've tried alot, but I guess it's because I don't really know what I am doing :P

LUA:
function onUse(cid, item, frompos, item2, itemEx, topos)
player1pos = getCreaturePosition(cid)
player1 = getThingfromPos(player1pos)
pos = getPlayerPosition(cid)
if
player1pos == {x=165, y=162, z=7} then


player1level = getPlayerLevel(player1.uid)
questlevel = 300
if player1level >= questlevel then
	doSummonCreature("Telarus",player1pos)
	doPlayerSendTextMessage(player1.uid,22,"Telarus!")
	doRemoveItem(item.uid, 1)
		else
			doPlayerSendTextMessage(player1.uid,22,"you need level 300.")
	return true
end
else
doPlayerSendTextMessage(player1.uid,22,"Not correct location.")
end
end

This will send the "not correct location" message, wherever I am. It won't summon when I'm on the position given - that's where I need some help..
 
Last edited:
LUA:
local pos = {x=165, y=162, z=7}
local summonPos = {x=164, y=161, z=7}
local questLevel = 300
local cPos = getCreaturePosition(cid)

function onUse(cid, item, fromPos, itemEx, toPos)
	if(cPos == pos) then
		if getPlayerLevel(cid) >= questlevel then
			doSummonCreature("Telarus", summonPos)
			doPlayerSendTextMessage(cid, 22, "Telarus!")
			doRemoveItem(item.uid, 1)
		else
			doPlayerSendCancel(cid, "You need to be level "..questlevel..".")
		end
	else
		doPlayerSendCancel(cid, "Not correct location.")
	end
return true
end

getCreaturePosition(cid) returns a table, so you can't do it like this, as you cannot compare 2 tables this way.

LUA:
local pos = {x=165, y=162, z=7}
local summonPos = {x=164, y=161, z=7}
local questLevel = 300

function comparePosition(pos1, pos2)
	return pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z and true or false
end

function onUse(cid, item, fromPos, itemEx, toPos)
	if comparePosition(fromPos, pos) then
		if getPlayerLevel(cid) >= questlevel then
			doSummonCreature("Telarus", summonPos)
			doPlayerSendTextMessage(cid, 22, "Telarus!")
			doRemoveItem(item.uid, 1)
		else
			doPlayerSendCancel(cid, "You need to be level "..questlevel..".")
		end
	else
		doPlayerSendCancel(cid, "Not correct location.")
	end
return true
end


kind regards, Evil Hero.
 
Last edited:
Thank you!

However;
LUA:
<luaGetThingPostion> Thing not found
 :lua:7  attempt to index local 'pos1' <a boolean value>
stack traceback: :lua: 7 in function 'comparePosition'
:lua:11 in function :lua:11
 
Thank you for your time. However, it stil lsays "not correct location" when I'm standing on pos, and there's no Telarus summoned.

Let's see, I too ka random item (posthorn) and made it the "summon" item. The idea is to sumon a telarus 1 sqm northwest of the player when the player is standing on a certain spot and right clicks the item in his/her backpack. This to prevet telarus roaming free in the city for example.
Since I made the position requirement I haven't been able to summon a telarus, the only thing happening has been "not correct location". Hum Hum

edit: btw, no console errors this time
 
LUA:
local pos = {x=165, y=162, z=7}
local summonPos = {x=164, y=161, z=7}
local questLevel = 300
 
function comparePosition(pos1, pos2)
	return pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z and true or false
end
 
function onUse(cid, item, fromPos, itemEx, toPos)
print("x = ".. fromPos.x .." | y = ".. fromPos.y .." | z = ".. fromPos.z .."")
	if comparePosition(fromPos, pos) then
		if getPlayerLevel(cid) >= questlevel then
			doSummonCreature("Telarus", summonPos)
			doPlayerSendTextMessage(cid, 22, "Telarus!")
			doRemoveItem(item.uid, 1)
		else
			doPlayerSendCancel(cid, "You need to be level "..questlevel..".")
		end
	else
		doPlayerSendCancel(cid, "Not correct location.")
	end
return true
end

try this code and tell me what is getting shown in your console, it should display the players position now in there where he is standing when he execute it, because the code itself looks fine.
 
what the.

x = 65535 | y = 64 | z = 3 (what does this say, really? O.o)


had to check on GM:

19:24 You see an item of type 9800, please report it to gamemaster.
ItemID: [9800].
Position: [X: 165] [Y: 162] [Z: 7].

What does this mean?!


I have a few anihilator scripts that uses position and summoning, and those positions never failed

SOlved by Evil Hero, Thanks alot!
 
Last edited:
Back
Top