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

Help with elevator script, easy quick rep+

rcb chief

New Member
Joined
Dec 23, 2008
Messages
53
Reaction score
0
so im making a simple elevator script, though im new at this and need help
one more thing the error im havind is simple when i click the lever with the unique id nothing happens, doesnt even say cannot use this object

function onUse(cid, item, fromPosition, itemEx, toPosition)
local floor1 = {x=90, y=67, z=7}
local floor2 = {x=90, y=67, z=6}
local floor3 = {x=90, y=67, z=5}
local floor4 = {x=90, y=67, z=4}
local floor5 = {x=90, y=67, z=3}
local floor6 = {x=90, y=67, z=2}
local floor7 = {x=90, y=67, z=1}

if itemuid == 6001 then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Floor 2.')
doTeleportThing(cid, floor2)
elseif itemuid == 6002 then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Floor 3.')
doTeleportThing(cid, floor3)
elseif itemuid == 6003 then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Floor 4.')
doTeleportThing(cid, floor4)
elseif itemuid == 6004 then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Floor 5.')
doTeleportThing(cid, floor5)
elseif itemuid == 6005 then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Floor 6.')
doTeleportThing(cid, floor6)
elseif itemuid == 6006 then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Floor 7.')
doTeleportThing(cid, floor7)
elseif itemuid == 6007 then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Floor 6.')
doTeleportThing(cid, floor6)
elseif itemuid == 6008 then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Floor 5.')
doTeleportThing(cid, floor5)
elseif itemuid == 6009 then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Floor 4.')
doTeleportThing(cid, floor4)
elseif itemuid == 6010 then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Floor 3.')
doTeleportThing(cid, floor3)
elseif itemuid == 6011 then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Floor 2.')
doTeleportThing(cid, floor2)
elseif itemuid == 6012 then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Floor 1.')
doTeleportThing(cid, floor1)
end
return true
end
 
right now I'm busy, but if you msg me tomorrow i can help you out with this script.
Edit:
ok look this script goes in data/actions/scripts :
LUA:
local t = {
	[0] = {id = 6001, fl = "1flr"},
	[6001] = {id = 6002, fl = "2flr"},
	[6002] = {id = 6003, fl = "3flr"},
	[6003] = {id = 6004, fl = "4flr"},
	[6004] = {id = 6005, fl = "5flr"},
	[6005] = {id = 6006, fl = "6flr"},
	[6006] = {id = 0, fl = "Baseflr"}
	}
function onUse(cid, item, toPosition, itemEx, fromPosition)
	if item.actionid == 6000 then
		for aid, a in pairs(t) do	
			local elevatorTile = getThingfromPos({x = toPosition.x, y = toPosition.y, z = toPosition.z, stackpos = 0})
			if elevatorTile.actionid == aid then
				doSetItemActionId(elevatorTile.uid, a.id)
				doSendAnimatedText(getCreaturePosition(cid), math.random(1,225), a.fl)
			end
		end
	end
return true
end
and in actions.xml:
PHP:
<action actionid="6000" event="script" value="elevatorswitch.lua"/>
Now this one goes in data/movements/scripts :
LUA:
function onStepIn(cid, item, toPosition)
local t = {
	[6001] = {floor = {x = toPosition.x, y = toPosition.y, z = toPosition.z-1}},
	[6002] = {floor = {x = toPosition.x, y = toPosition.y, z = toPosition.z-2}},
	[6003] = {floor = {x = toPosition.x, y = toPosition.y, z = toPosition.z-3}},
	[6004] = {floor = {x = toPosition.x, y = toPosition.y, z = toPosition.z-4}},
	[6005] = {floor = {x = toPosition.x, y = toPosition.y, z = toPosition.z-5}},
	[6006] = {floor = {x = toPosition.x, y = toPosition.y, z = toPosition.z-6}}
	}
	for aid, fl in pairs(t) do
		if item.actionid == 0 then
			doPlayerSendTextMessage(cid, 25, "You can't go up, please set the floor that you want by using the lever to the left.")
		elseif item.actionid == aid then
			doTeleportThing(cid, fl.floor, false)
			doPlayerSendTextMessage(cid, 25, "You have arrived to your desired floor.")
			doSetItemActionId(item.uid, 0)
			doSendAnimatedText(toPosition, math.random(1,225), "Baseflr")
		end	
	end
return true
end
and in movements.xml:
PHP:
<movevent type="StepIn" actionid="6001-6006" event="script" value="elevatortile.lua"/>
I'll post tomorrow pics on how you need to lay this out so it will work.
Edit2:
Here is an example of how it can be done:
elevatorexample.png

remember to set the action id of the lever in the map editor and that the elevator tile always
goes to the right side of the lever, also you can put the switch and tile inside the building
and have the player teleport from the inside.
How It Works:
you need to be outside the elevator tile(not on it), use the switch until you get your desirable
floor that you wish to go, then step on the tile and you will be teleported there.
 
Last edited:
Back
Top