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

Treasure Map (Solved)

LucasFerraz

Systems Analyst
Joined
Jun 10, 2010
Messages
2,857
Reaction score
96
Location
Brazil
Why this script do not work?
LUA:
function onUse(cid,item,frompos,item2,topos)

player = getPlayerPosition(cid)
tesoro = {x=32346, y=32947, z=7}

if player.x == tesoro.x and player.y == tesoro.y and player.z == tesoro.z then
doPlayerAddItem(cid,2152,50)
doPlayerRemoveItem(cid,5706,1)
doCreatureSay(cid, "Treasure found yo-ho!", TALKTYPE_ORANGE_1)

elseif player.x < tesoro.x and player.y == tesoro.y and player.z == tesoro.z then
doCreatureSay(cid, "Treasure is to the west.", TALKTYPE_ORANGE_1)

elseif player.y > tesoro.y and player.x == tesoro.y and player.z == tesoro.z then
doCreatureSay(cid, "Treasure is to the north.", TALKTYPE_ORANGE_1)

elseif player.y < tesoro.y and player.x == tesoro.y and player.z == tesoro.z then
doCreatureSay(cid, "Treasure is to the south.", TALKTYPE_ORANGE_1)

elseif player.x > tesoro.x and player.y == tesoro.y and player.z == tesoro.z then
doCreatureSay(cid, "Treasure is to the east.", TALKTYPE_ORANGE_1)

elseif player.x < tesoro.x and player.y > tesoro.y == tesoro.y and player.z == tesoro.z then
doCreatureSay(cid, "Treasure is to the north-east.", TALKTYPE_ORANGE_1)

elseif player.x > tesoro.x and player.y > tesoro.y == tesoro.y and player.z == tesoro.z then
doCreatureSay(cid, "Treasure is to the north-west.", TALKTYPE_ORANGE_1)

elseif player.x < tesoro.x and player.y < tesoro.y == tesoro.y and player.z == tesoro.z then
doCreatureSay(cid, "Treasure is to the south-east.", TALKTYPE_ORANGE_1)

elseif player.x > tesoro.x and player.y < tesoro.y == tesoro.y and player.z == tesoro.z then
doCreatureSay(cid, "Treasure is to the south-west.", TALKTYPE_ORANGE_1)

end
end
 
LUA:
local t, p, storage = {
	[0] = 'north',
	[1] = 'east',
	[2] = 'south',
	[3] = 'west',
	[4] = 'south-west',
	[5] = 'south-east',
	[6] = 'north-west',
	[7] = 'north-east'
},
{x=32346, y=32947, z=7},
101

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getCreatureStorage(cid, storage) == 1 then
		return doCreatureSay(cid, 'You already found the treasure.', TALKTYPE_ORANGE_1, false, cid)
	end

	local k = getThingPos(cid)
	if doComparePositions(k, p) then
		doCreatureSetStorage(cid, storage, 1)
		doPlayerAddItem(cid, 2152, 50)
		doRemoveItem(item.uid)
		doCreatureSay(cid, 'Treasure found yo-ho!', TALKTYPE_ORANGE_1, false, cid)
	else
		doCreatureSay(cid, 'Treasure is to the ' .. t[getDirectionTo(k, p)] .. '.', TALKTYPE_ORANGE_1, false, cid)
	end
	return true
end
 
Back
Top