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

Lua Script

otlandacc

New Member
Joined
Mar 24, 2012
Messages
5
Reaction score
0
Hello Otland people, i would like to know how to do something with a script. I want to do that by pressing a lever, first check if there is a "scarab coin" in a place on the map, and if so, teleport you to another location on the map. When you

teleport, also want the scarab coin removed.

I have this script:

local pos = {x = 3245, y = 2305, z = 10}
local teleport = {x = 3260, y = 2305, z = 10}

function onUse(cid, item, fromPosition, itemEx, toPosition)

if (Here the command to check if the scarab coin is in the position of "post") then
doTeleportThing (cid, teleport)
doSendMagicEffect (teleport, CONST_ME_TELEPORT)
(Here the command to delete the scarab coin)
else
doPlayerSendTextMessage (cid, 24, "You must place a scarab coin and press the lever.")
end
end


This is the script that would have the lever.

I want to know how to check if the scarab coin and also want to know how to remove that scarab coin.

Greetings!
 
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local donation_coin = 6527
	local need_to_pay = 200
	local add_item = {[1] = {2472, 1}}
	if(doPlayerRemoveItem(cid, donation_coin, need_to_pay)) then
		doPlayerAddItem(cid, add_item[1][1], add_item[1][2])
		doPlayerSendCancel(cid, "You just bought ".. add_item[1][2] .."x of ".. getItemArticleById(add_item[1][1]) .." ".. getItemNameById(add_item[1][1]) ..".")
	else
		doPlayerSendCancel(cid, "You don't have enough tokens.")
	end
	return true
end
actions.xml
LUA:
 <action itemid="8047" event="script" value="custom/buyitem.lua"/>
Credits to WarOfTheTitans
 
LUA:
        local coinpos = {x = 3245, y = 2305, z = 10, stackpos = 1}
	local coinid = 6527
	local teleportDestinationPos = {x = 3260, y = 2305, z = 10}
 
	local exhaustionEnable = true
	local exhaustionStorage = 9988
	local exhaustionDelay = 10 -- seconds
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(exhaustionEnable == true) then
		if(exhaustion.check(cid, exhaustionStorage) == false) then
			if(item.itemid == 1945) then
				if(doRemoveItem(getThingfromPos(coinpos).uid, 1)) then
					doTransformItem(item.uid, item.itemid + 1)
					doTeleportThing(cid, teleportDestinationPos, true)
					exhaustion.set(cid, exhaustionStorage, exhaustionDelay)
				else
					doPlayerSendCancel(cid, "There is no coin the right position")
					return true
				end
			else
				doTransformItem(item.uid, item.itemid -1)
			end
		else
			doPlayerSendCancel(cid, "You are exhausted.")
			return true
		end
	end
	return true
end

This will remove the coin, and if there is no coin in the position, nothing will happen.
 
Last edited:
Hello, i added some things to the script so that if you put a scarab coin, transport you in the same place as before, but if you put a gold ingot, transport you to a different site, and if you put a gold nugget, to a different site.

And the problem is that i dont know which is the command to check if theres an item, other, or if there isnt a scarab coin, gold ingot or gold nugget.

Thanks!

If you need it, this is the script, without the commands:

local pos = {x = 3245, y = 2305, z = 10}
local teleport = {x = 3260, y = 2305, z = 10}
local teleport2 = {x = 3245, y = 2320, z = 10}
local teleport3 = {x = 3230, y = 2305, z = 10}

function onUse(cid, item, fromPosition, itemEx, toPosition)

if (Here the command to check if the scarab coin is in the position of "pos") then
doTeleportThing (cid, teleport)
doSendMagicEffect (teleport, CONST_ME_TELEPORT)
(Here the command to delete the scarab coin)
elseif (Here the command to check if a gold ingot is in the position of "pos")
doTeleportThing (cid, teleport2)
doSendMagicEffect (teleport2, CONST_ME_TELEPORT)
(Here the command to delete the gold ingot)
elseif (Here the command to check if a gold nugget is in the position of "pos")
doTeleportThing (cid, teleport3)
doSendMagicEffect (teleport3, CONST_ME_TELEPORT)
(Here the command to delete the gold nugget)
elseif (Here the command to check if in the position of "pos" there are no scarab coin, a gold ingot, a gold nugget)
doPlayerSendTextMessage (cid, 24, "You must place a scarab coin, a gold ingot or a gold nugget and press the lever.")
end
end
 
LUA:
	--CFG--
	local coinpos = {x = 1001, y = 1002, z = 7, stackpos = 1}
		
	local tokenid = 6527
	local scarabid = 2159
	local goldingotid = 9971
	local goldnuggetid = 2157
	
	local teleportToken = {x = 1000, y = 1000, z = 7}	
	local teleportScarab = {x = 1000, y = 1000, z = 7}
	local teleportIngot = {x = 1002, y = 1002, z = 7}
	local teleportNugget = {x = 1003, y = 1003, z = 7}
 
	local exhaustionEnable = true
	local exhaustionStorage = 9988
	local exhaustionDelay = 10 -- seconds
	--/CFG--
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(exhaustionEnable == true) then
		if(exhaustion.check(cid, exhaustionStorage) == false) then
			if(item.itemid == 1945) then
				if(getTileItemById(coinpos, scarabid).uid ~= 0) then
					doRemoveItem(getThingfromPos(coinpos).uid, 1)
					doTransformItem(item.uid, item.itemid + 1)
					doTeleportThing(cid, teleportScarab, true)
					exhaustion.set(cid, exhaustionStorage, exhaustionDelay)
				elseif(getTileItemById(coinpos, goldingotid).uid ~= 0) then
					doRemoveItem(getThingfromPos(coinpos).uid, 1)
					doTeleportThing(cid, teleportIngot, true)
					exhaustion.set(cid, exhaustionStorage, exhaustionDelay)
				elseif(getTileItemById(coinpos, goldnuggetid).uid ~= 0) then
					doRemoveItem(getThingfromPos(coinpos).uid, 1)
					doTeleportThing(cid, teleportNugget, true)
					exhaustion.set(cid, exhaustionStorage, exhaustionDelay)
				elseif(getTileItemById(coinpos, tokenid).uid ~= 0) then
					doRemoveItem(getThingfromPos(coinpos).uid, 1)
					doTransformItem(item.uid, item.itemid + 1)
					doTeleportThing(cid, teleportToken, true)
					exhaustion.set(cid, exhaustionStorage, exhaustionDelay)
				else
					doPlayerSendCancel(cid, "There is no coin the right position")
					return true
				end
			else
				doTransformItem(item.uid, item.itemid -1)
			end
		else
			doPlayerSendCancel(cid, "You are exhausted.")
			return true
		end
	end
	return true
end
 
Back
Top