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

[Request] Lua Script

ond

Veteran OT User
Joined
Mar 24, 2008
Messages
2,775
Solutions
25
Reaction score
483
Location
Sweden
Hi, I'm requesting a lua script. The lua scripts function is when I put an item on a certain tile and stand on another and after that pull a lever, I shall be teleported and the item shall be removed.

I've already got a script but it doesn't quite works. It only tells me:
Sorry, not possible.

Here's my script:
Lua:
function onUse(cid, item, frompos, item2, topos)

player1pos = {x=311, y=1542, z=10, stackpos=253}
player1 = getThingfromPos(player1pos)

piece1pos = {x=310, y=1543, z=10, stackpos=1}
getpiece1 = getThingfromPos(piece1pos)
if item.uid == 6435 and item.itemid == 1945 and getpiece1.itemid == 2363 and player1.itemid > 0 then
doRemoveItem(getpiece1.uid,1)
nplayer1pos = {x=300, y=1536, z=10}
doTeleportThing(player1.uid,nplayer1pos)
doSendMagicEffect(nplayer1pos,10)
doTransformItem(item.uid,item.itemid+1)
elseif item.uid == 6435 and item.itemid == 1946 then
doTransformItem(item.uid,item.itemid-1)
else
doPlayerSendTextMessage(cid,22,"Sorry, not possible.")
end
return 1
end

Would be really thank full if someone helped me out!
 
Lua:
local playerPos = {x=311, y=1542, z=10, stackpos=253} -- Player Position
local newPos = {x=300, y=1536, z=10} -- Player New Position
local piecePos = {x=310, y=1543, z=10, stackpos=1} -- Item Position
local piece = getThingfromPos(piecePos)
local player = getThingfromPos(playerPos)

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if (item.itemid == 1945) and (item.uid == 6435) then
		if (piece.itemid == 2363) then
			if (player == TRUE) then
				doRemoveItem(piece.uid, 1)
				doTeleportThing(cid, newPos)
				doSendMagicEffect(getCreaturePosition(cid) ,10)
			else
				doPlayerSendCancel(cid, "You must stand on the correct spot.")
			end
		else
			doPlayerSendCancel(cid, "You must place the item on the correct spot.")
		end
	elseif (item.itemid == 1946) then
		doTransformItem(item.uid,item.itemid-1)
		doSendMagicEffect(fromPosition, CONST_ME_POFF)
	end
	return TRUE
end
 
Back
Top