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

teleporting lever

kimokimo

Kimo
Joined
Jan 25, 2011
Messages
821
Solutions
6
Reaction score
156
GitHub
karimadnan
can anyone help me i want lever that when you press it say you need "item name" to teleport to "place name"..


+REP :(
 
Code:
local config = {
	itemName = 'demon helmet',
	place = {x = 100, y = 100, z = 7 }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local id = getItemIdByName(config.itemName)
	if id ~= 0 then
		doTeleportThing(cid, config.place)
	end
	return true
end

This should work just fine.
 
Lua:
local config = {
	itemName = 'demon helmet',
	place = {x = 100, y = 100, z = 7 }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local id = getItemIdByName(config.itemName)
	if id ~= 0 then
		doTeleportThing(cid, config.place)
        else
                doCreatureSay( cid , 'You need an Demon Helmet to pass!' , TALKTYPE_MONSTER_SAY )
	end
	return true
end
This maybe?
 
Last edited:
Lua:
local config = {
	itemName = 'demon helmet',
	place = {x = 100, y = 100, z = 7 }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local id = getItemIdByName(config.itemName)
	if id ~= 0 then
		doTeleportThing(cid, config.place)
        else
                doCreatureSay( cid , 'You need an Demon Helmet to pass!' , TALKTYPE_ORANGE_1 
	end
	return true
end
This maybe?



Not Working :(
 
Lua:
local config = {
	itemId = xxx,
	place = {x = 100, y = 100, z = 7 }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
        local item = getPlayerItemById(cid, true, config.itemId)
	if item ~= 0 then
		doTeleportThing(cid, config.place)
        else
                doCreatureSay( cid , 'You need a ' .. getItemNameById(config.itemId) .. ' to pass!' , TALKTYPE_ORANGE_1 )
	end
	return true
end

Try this

ofc change xxx to the itemid you want

Edit: Updated diaths ")" bug. talktype he can decide himself.. might not even want to use doCreatureSay.
 
Last edited:
You said check for item.. not remove/take item.. But this will work


Lua:
local config = {
	itemId = xxx, --change to whatever
	place = {x = 100, y = 100, z = 7 } --change to a position...
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if doPlayerRemoveItem(cid, config.itemId, 1) then
		doTeleportThing(cid, config.place)
        else
                doCreatureSay( cid , 'You need a ' .. getItemNameById(config.itemId) .. ' to pass!' , TALKTYPE_ORANGE_1 )
	end
	return true
end
 
Lol i didn't read page 2 so i made a script too.. kinda useless now but w/e here u go xDD
Lua:
local config = {
	itemN = "spike sword",-- Name of the item - NOT ID! [Name MUST be exact!]
	tpPlace = {x = 100, y = 100, z = 7}--Place to teleport to!
}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local itemId = getItemIdByName(itemN)
		if(getPlayerItemCount(cid, itemId) => 1) then
			doTeleportThing(cid, config.tpPlace)
			doPlayerRemoveItem(cid, itemId, 1)
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have been teleported and 1x " .. config.itemN .. " has been removed from your inventory.")
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need a " .. config.itemN .. " to be teleported!")
		end
	return true
end
 
Back
Top