Action Elevator System

Shynzo

Banned User
Joined
Jun 15, 2008
Messages
142
Best answers
0
Reaction score
0
Location
Brazil
Elevator System​


This is an elevator system developed by Colex, there in the versions of OTServ when he was 7x.
I decided to take the script and give it a reorganized and upgrade to 8.2+
I have not tested the script that I'm no server here at the moment, but who want to test there and post the result here is the will.
This script is divided into 2 parts so come.

First part:
Goto in folder data/actions/scripts and create a file called elevatorSystem.lua
Paste the code below into it and save.

PHP:
--[[
	Script by: Colex
	Part: 1/2
	Script Name: Elevator System
	Modified by: Tryller/Shynzo
]]--

local STORAGE = 5080
local MSGTYPE = MESSAGE_INFO_DESCR -- It's green text


function onUse(cid, item, fromPosition, itemEx, toPosition)
	if (getPlayerStorageValue(cid, STORAGE) == -1) then
		doPlayerSendTextMessage(cid, MSGTYPE, "1st floor".)
		setPlayerStorageValue(cid, STORAGE,1)

	elseif (getPlayerStorageValue(cid, STORAGE) == 1) then
		doPlayerSendTextMessage(cid, MSGTYPE, "2nd floor".)
		setPlayerStorageValue(cid, STORAGE,2)

	elseif (getPlayerStorageValue(cid, STORAGE) == 2) then
		doPlayerSendTextMessage(cid, MSGTYPE, "3rd floor".)
		setPlayerStorageValue(cid, STORAGE,-1)
		end
	return 1
end
Second part:
Goto folder data/actions/scripts and create a new file called elevatorSystem2.lua
Paste the code below into it and save.

PHP:
--[[
	Script by: Colex
	Part: 2/2
	Script Name: Elevator System
	Modified by: Tryller/Shynzo
]]--

local STORAGE = 5080

function onUse(cid, item, fromPosition, itemEx, toPosition)
local floor1 = {x=512, y=509, z=7}
local floor2 = {x=512, y=509, z=6}
local floor3 = {x=512, y=509, z=5}

local player1pos = getPlayerPosition(cid)
local player1 = getThingfromPos(player1pos)

	if player1.itemid == cid and (getPlayerStorageValue(cid, STORAGE) == 1) then
		doTeleportThing(player1.uid,floor1)
		doSendMagicEffect(fromPosition, CONST_ME_POFF)

	elseif player1.itemid == cid and (getPlayerStorageValue(cid, STORAGE) == 2) then
		doTeleportThing(player1.uid,floor2)
		doSendMagicEffect(fromPosition, CONST_ME_POFF)

	elseif player1.itemid == cid and (getPlayerStorageValue(cid, STORAGE) == -1) then
		doTeleportThing(player1.uid,floor3)
		doSendMagicEffect(fromPosition, CONST_ME_POFF)
		end
	return 1
end
Now go data/actions/actions.xml and add this tags:
To TFS 0.3

PHP:
	<!-- Elevator System by Colex, Modified by Tryller/Shynzo -->
	<action uniqueid="1945" event="script" value="others/elevatorSystem2.lua"/>
	<action uniqueid="1946" event="script" value="others/elevatorSystem2.lua"/>
	<action uniqueid="1947" event="script" value="others/elevatorSystem2.lua"/>
	<action uniqueid="1948" event="script" value="others/elevatorSystem.lua"/>
	<action uniqueid="1949" event="script" value="others/elevatorSystem.lua"/>
	<action uniqueid="1950" event="script" value="others/elevatorSystem.lua"/>
To TFS 0.2

PHP:
	<!-- Elevator System by Colex, Modified by Tryller/Shynzo -->
	<action uniqueid="1945" script="elevatorSystem2.lua" />
	<action uniqueid="1946" script="elevatorSystem2.lua" />
	<action uniqueid="1947" script="elevatorSystem2.lua" />
	<action uniqueid="1948" script="elevatorSystem.lua" />
	<action uniqueid="1949" script="elevatorSystem.lua" />
	<action uniqueid="1950" script="elevator.Systemlua" />
explaining
1945 | 1946 | 1947 - these are the uniqueids of "panels" that are used to choose the floor where it goes (must have one on each floor)
1948 | 1949 | 1950 - these are the unique id of "levers" (may be another item) that you use after you choose the floor panel, (you will choose to walk on the panel)

Look the ScreenSoot SS to better understand


red square - this here is the "panel" that will be used to choose the floor (you can use another item)
blue square - this lever is where you use the following to choose the floor in the "panel" (You can also use another item)

Crédits:
Colex
Tryller/Shynzo

like the script? I helped you? give me reputation
 

cbrm

Top Class brunet scripter
Staff member
Global Moderator
Joined
Jan 6, 2009
Messages
6,585
Best answers
3
Reaction score
852
Location
Caribbean Sea
and the tile is teleported too? like rl evelators?
 

Cykotitan

Experienced G'
Joined
Nov 4, 2008
Messages
16,894
Best answers
4
Reaction score
817
Code:
--[[
Script by: Colex
Part: 1/2
Script Name: Elevator System
Modified by: Tryller/Shynzo, Cykotitan
]]--

local STORAGE = 5080

local function ordinal(str)
	if not(type(str) == "string") then str = tostring(str) end
	local str = str:sub(-1)
	return str == "1" and "st" or str == "2" and "nd" or str == "3" and "rd" or "th"
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local s = getPlayerStorageValue(cid, STORAGE)
	setPlayerStorageValue(cid, STORAGE, s < 1 and 1 or s == 1 and 2 or s == 2 and -1)
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ordinal(tostring(getPlayerStorageValue(cid, STORAGE))) .. " floor")
	return TRUE
end
Code:
--[[
    Script by: Colex
    Part: 2/2
    Script Name: Elevator System
    Modified by: Tryller/Shynzo, Cykotitan
]]--

local STORAGE = 5080
local floors = {
	{x=512, y=509, z=7},
	{x=512, y=509, z=6},
	{x=512, y=509, z=5}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local s = getPlayerStorageValue(cid, STORAGE)
 	if 0 < s and s <= #floors then
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
		doRelocate(getCreaturePosition(cid), floor[s])
		doSendMagicEffect(floor[s], CONST_ME_POFF)
		return TRUE
	end
	return FALSE
end
 
Last edited:

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
Cykotitan, you can't stop can you? :huh:
It get's anoying.

What happened to your "real map project" anyways?

@topic,
Nice, I've seen this in Kiwi Server.
 

chojrak

Banned User
Joined
Oct 25, 2008
Messages
5,832
Best answers
2
Reaction score
158
Code:
doRelocate(getCreaturePosition(cid), floor[s])
doSendMagicEffect(floor[s, CONST_ME_POFF)
It should'nt be:
Code:
doRelocate(getCreaturePosition(cid), floors[s])
doSendMagicEffect(floors[s], CONST_ME_POFF)
? :p
 

Cykotitan

Experienced G'
Joined
Nov 4, 2008
Messages
16,894
Best answers
4
Reaction score
817
Code:
doRelocate(getCreaturePosition(cid), floor[s])
doSendMagicEffect(floor[s, CONST_ME_POFF)
It should'nt be:
Code:
doRelocate(getCreaturePosition(cid), floors[s])
doSendMagicEffect(floors[s], CONST_ME_POFF)
? :p
Whoops xd fixed
Cykotitan, you can't stop can you? :huh:
It get's anoying.

What happened to your "real map project" anyways?
That's annoying, too.
 
Last edited:

president vankk

Web Developer & AuraOT Owner
Joined
Jul 10, 2009
Messages
5,717
Best answers
8
Reaction score
285
I think I have ever seen
this script
a forum
 
OP
Shynzo

Shynzo

Banned User
Joined
Jun 15, 2008
Messages
142
Best answers
0
Reaction score
0
Location
Brazil
Thanks to all ;)
coments and Rep++ ;)
 
Top