Apollos
Dude who does stuff
For TFS 1.1:
Having a few issues with an elevator script I've been working on.
First, I can't figure out how to make this part recognize the tiles and only let the player use the elevator if he is standing on those tiles. (Located in first part of script, line 12-15)
Second, I have a text animation through do creature say when you arrive at the floor but it only works half the time, it probably is because I couldn't correctly call multiple items in the tables either. (Located in the second part of the script, lines 24-50)
Having a few issues with an elevator script I've been working on.
First, I can't figure out how to make this part recognize the tiles and only let the player use the elevator if he is standing on those tiles. (Located in first part of script, line 12-15)
Second, I have a text animation through do creature say when you arrive at the floor but it only works half the time, it probably is because I couldn't correctly call multiple items in the tables either. (Located in the second part of the script, lines 24-50)
Lua:
function onUse(cid, words, position, Toposition)
local player = Player(cid)
local playerPos = getPlayerPosition(cid)
local modal = ModalWindow (1901, "Depot Elevator", "Choose a floor:")
local tilePos = {
{x=1232, y=1043, z=7},
{x=1232, y=1043, z=6},
{x=1232, y=1043, z=5},
{x=1232, y=1043, z=4}
}
if Tile(playerPos) ~= Tile(tilePos) then
doPlayerSendTextMessage(cid.uid, 18, "You must be inside the elevator.")
return false
end
modal:addChoice(1, "Ground Floor")
modal:addChoice(2, "Floor 1")
modal:addChoice(3, "Floor 2")
modal:addChoice(4, "Floor 3")
if modal:getId() == 1901 then
modal:addButton(3, "Select")
modal:addButton(4, "Cancel")
end
modal:sendToPlayer(player)
return true
end
Lua:
local pos1 = {x=1232, y=1043, z=7}
local pos2 = {x=1232, y=1043, z=6}
local pos3 = {x=1232, y=1043, z=5}
local pos4 = {x=1232, y=1043, z=4}
local ding1 = {x=1231, y=1043, z=7}
local ding2 = {x=1231, y=1043, z=6}
local ding3 = {x=1231, y=1043, z=5}
local ding4 = {x=1231, y=1043, z=4}
local function removeWall1 (p1, itemId)
local gate1 = getTileItemById(p1, 9486)
if gate1 then
doRemoveItem(gate1.uid,1)
end
end
local function removeWall2 (p2, itemId)
local gate2 = getTileItemById(p2, 9486)
if gate2 then
doRemoveItem(gate2.uid,1)
end
end
local function onDing1(cid)
local player = Player(cid)
if player then
player:say("*ding*", TALKTYPE_MONSTER_SAY, false, nil, Position(ding1))
end
end
local function onDing2(cid)
local player = Player(cid)
if player then
player:say("*ding*", TALKTYPE_MONSTER_SAY, false, nil, Position(ding2))
end
end
local function onDing3(cid)
local player = Player(cid)
if player then
player:say("*ding*", TALKTYPE_MONSTER_SAY, false, nil, Position(ding3))
end
end
local function onDing4(cid)
local player = Player(cid)
if player then
player:say("*ding*", TALKTYPE_MONSTER_SAY, false, nil, Position(ding4))
end
end
function onModalWindow(cid, modalWindowId, buttonId, choiceId, item, position, pos, toPosition, fromPosition, itemEx)
local p1 = getPlayerPosition(cid)
p1.x = p1.x + 1
p1.y = p1.y + 1
local p2 = getPlayerPosition(cid)
p2.y = p2.y + 1
if modalWindowId == 1901 and buttonId ~= 3 then
return false
end
if modalWindowId == 1901 and choiceId == 1 then
addEvent(doCreateItem, 1, 9486, 1, p1)
addEvent(doCreateItem, 500, 9486, 1, p2)
addEvent(doPlayerSendTextMessage, 1000, cid.uid, 18, "You have arrived at the ground floor.")
addEvent(doTeleportThing, 1000, cid.uid, pos1, true)
addEvent(onDing1, 1000, cid.uid)
addEvent(removeWall2, 1500, p2, 9486)
addEvent(removeWall1, 2000, p1, 9486)
return true
end
if modalWindowId == 1901 and choiceId == 2 then
addEvent(doCreateItem, 1, 9486, 1, p1)
addEvent(doCreateItem, 500, 9486, 1, p2)
addEvent(doPlayerSendTextMessage, 1000, cid.uid, 18, "You have arrived at Floor 1.")
addEvent(doTeleportThing, 1000, cid.uid, pos2, true)
addEvent(onDing2, 1000, cid.uid)
addEvent(removeWall2, 1500, p2, 9486)
addEvent(removeWall1, 2000, p1, 9486)
return true
end
if modalWindowId == 1901 and choiceId == 3 then
addEvent(doCreateItem, 1, 9486, 1, p1)
addEvent(doCreateItem, 500, 9486, 1, p2)
addEvent(doPlayerSendTextMessage, 1000, cid.uid, 18, "You have arrived at Floor 2.")
addEvent(doTeleportThing, 1000, cid.uid, pos3, true)
addEvent(onDing3, 1000, cid.uid)
addEvent(removeWall2, 1500, p2, 9486)
addEvent(removeWall1, 2000, p1, 9486)
return true
end
if modalWindowId == 1901 and choiceId == 4 then
addEvent(doCreateItem, 1, 9486, 1, p1)
addEvent(doCreateItem, 500, 9486, 1, p2)
addEvent(doPlayerSendTextMessage, 1000, cid.uid, 18, "You have arrived at Floor 3.")
addEvent(doTeleportThing, 1000, cid.uid, pos4, true)
addEvent(onDing4, 1000, cid.uid)
addEvent(removeWall2, 1500, p2, 9486)
addEvent(removeWall1, 2000, p1, 9486)
return true
end
end
Last edited: