• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

Lua How can i make a stoptile to prevent player to go up stairs?

Loiz

New Member
Joined
Jul 25, 2018
Messages
7
Solutions
1
Reaction score
0
How can i make a script to prevent player to get up on stairs?
i made this script but the player is not going down



Lua:
function onStepIn(cid, item, pos)
local pos = getCreaturePosition(cid)
local newpos = pos
local direction = getPlayerLookDir(cid)
    if getPlayerGUID(cid) >= 1 then
        if    getPlayerStorageValue(cid, 50002) <= 8 then
                newpos = {x=pos.x+2, y=pos.y, z=pos.z+1}
                doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "This is Telas's room. Maybe you should talk to him before sniffing around in his house.")
                doTeleportThing(cid, newpos, true)
                
        elseif getPlayerStorageValue(cid, 50002) >= 11 then
                newpos = {x=pos.x+2, y=pos.y, z=pos.z-1}
                doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You have no business here anymore, talk with Tela to remember what you have to do.")
                doTeleportThing(cid, newpos, true)
            
            end
    else
        return FALSE
    end
return TRUE
end
 
Solution
TFS 0.3.2
im trying to remove the stair and trapdor atribute on items.xml
and rewrite its atributes on movements.xml with a script, because i found it conflicts with the items.xml atribute
Post automatically merged:

Solved Script to prevent player from using stairs ou trapdoors!

First i removed the atributes from "Wooden Stair ID 8709" and "Trapdoor ID 8596" on items.xml

XML:
FROM

<item id="8709" name="stairs">
        <attribute key="floorchange" value="west"/>
    </item>
<item id="8596" article="a" name="trapdoor">
        <attribute key="floorchange" value="down"/>
    </item>

To

<item id="8709" name="stairs">
    </item>
<item id="8596" article="a" name="trapdoor">
    </item>

Removing atributes

The seccond step was inserting ID...

Dakos

Well-Known Member
Joined
Jan 1, 2010
Messages
157
Solutions
22
Reaction score
82
Lua:
local storage = 50002

function onStepIn(cid, item, position, fromPosition)
    
    if getPlayerStorageValue(cid, storage) <= 8 then
       doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "This is Telas's room. Maybe you should talk to him before sniffing around in his house.")
       doTeleportThing(cid, fromPosition, true)
       return false
    elseif getPlayerStorageValue(cid, storage) >= 11 then
       doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You have no business here anymore, talk with Tela to remember what you have to do.")
       doTeleportThing(cid, fromPosition, true)   
       return false
    end       

    return true
end
 
OP
OP
L

Loiz

New Member
Joined
Jul 25, 2018
Messages
7
Solutions
1
Reaction score
0
Lua:
local storage = 50002

function onStepIn(cid, item, position, fromPosition)
   
    if getPlayerStorageValue(cid, storage) <= 8 then
       doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "This is Telas's room. Maybe you should talk to him before sniffing around in his house.")
       doTeleportThing(cid, fromPosition, true)
       return false
    elseif getPlayerStorageValue(cid, storage) >= 11 then
       doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You have no business here anymore, talk with Tela to remember what you have to do.")
       doTeleportThing(cid, fromPosition, true)  
       return false
    end      

    return true
end
if i only put the actionid on a ground tile it works like mine script
but if i put it on the stair, it's not working anyway... the player goes to the next floor and give's me the Text message. i will attach a video to see it

 
OP
OP
L

Loiz

New Member
Joined
Jul 25, 2018
Messages
7
Solutions
1
Reaction score
0
TFS 0.3.2
im trying to remove the stair and trapdor atribute on items.xml
and rewrite its atributes on movements.xml with a script, because i found it conflicts with the items.xml atribute
Post automatically merged:

Solved Script to prevent player from using stairs ou trapdoors!

First i removed the atributes from "Wooden Stair ID 8709" and "Trapdoor ID 8596" on items.xml

XML:
FROM

<item id="8709" name="stairs">
        <attribute key="floorchange" value="west"/>
    </item>
<item id="8596" article="a" name="trapdoor">
        <attribute key="floorchange" value="down"/>
    </item>

To

<item id="8709" name="stairs">
    </item>
<item id="8596" article="a" name="trapdoor">
    </item>

Removing atributes

The seccond step was inserting ID from Stair and Trapdoor in movements.xml as a script

XML:
<!--Stairs-->
    <movement type="StepIn" itemid="8709" event="script" value="/stairs/woodenstair.lua"/>
    <movement type="StepIn" itemid="8596" event="script" value="/stairs/trapdoor.lua"/>


Now on woodenstair.lua:
Lua:
function onStepIn(cid, item, position, fromPosition)
local pos = getCreaturePosition(cid)
local newpos = pos
    if getPlayerGUID(cid) >= 1 then -- This is for if a npc came to the tile it will no bug you server
        if item.actionid == 50008 then -- if you put this ActionID you lock the stair with id 8709 >:)
            if getPlayerStorageValue(cid, 50002) <= 8 then
            doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "This is Telas's room. Maybe you should talk to him before sniffing around in his house.")
            doTeleportThing(cid, fromPosition, TRUE)
            elseif getPlayerStorageValue(cid, 50002) == 11 then
            doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You have no business here anymore, talk with Tela to remember what you have to do.")
            doTeleportThing(cid, fromPosition, TRUE)   
            else
            newpos = {x=pos.x-1, y=pos.y, z=pos.z-1}
            doTeleportThing(cid, newpos, TRUE)
            end
        else -- if you don't put any Action ID it will work as the stair atribute on items.xml
        newpos = {x=pos.x-1, y=pos.y, z=pos.z-1}
        doTeleportThing(cid, newpos, TRUE)
        end
    else
    return false
    end
    return true
end

and trapdoor.lua i put:

Lua:
function onStepIn(cid, item, position, fromPosition)
local config = {
      item = 8709, --- Stair ID
      item2 = 1396, --- Vertical Stair ID
}
local pos = getCreaturePosition(cid)
local newpos = pos
local posescada = pos
    if getPlayerGUID(cid) >= 1 then
        if item.actionid == 50008 then -- If it was a horizontal stair it will lock putting this ActionID
            if getPlayerStorageValue(cid, 50002) <= 8 then
                doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "This is Tela's cellar. You have no business there yet.")
                doTeleportThing(cid, fromPosition, TRUE)
            elseif getPlayerStorageValue(cid, 50002) == 11 then
                doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "This is Tela's cellar - and you wouldn't want to go back to this nasty place.")
                doTeleportThing(cid, fromPosition, TRUE)
            else
            newpos = {x=pos.x+1, y=pos.y, z=pos.z+1}
            doTeleportThing(cid, newpos, TRUE)
            end
        elseif item.actionid == 50009 then -- If it was a vertical stair it will lock putting this ActionID
        newpos = {x=pos.x, y=pos.y+1, z=pos.z+1}
        doTeleportThing(cid, newpos, TRUE)
        else
         if getTileItemById({x=pos.x, y=pos.y, z=pos.z+1}, config.item).uid > 0 then -- The script will check on the down floor if it has an horizontal stair
         newpos = {x=pos.x+1, y=pos.y, z=pos.z+1}
         doTeleportThing(cid, newpos, TRUE)
        
         elseif getTileItemById({x=pos.x, y=pos.y, z=pos.z+1}, config.item2).uid > 0 then -- The script will check on the down floor if it has an vertical stair
         newpos = {x=pos.x, y=pos.y+1, z=pos.z+1}
         doTeleportThing(cid, newpos, TRUE)
        
         else
         newpos = {x=pos.x, y=pos.y, z=pos.z+1}
         doTeleportThing(cid, newpos, TRUE)
         end
        end
    else
        return false
    end
return true
end


The script works perfect, but it will only work with PLAYERS, NPC and Items doesnt work, if someone know how to do this with items i will be greatfull
Post automatically merged:

Edit I solved how to place items on the ladder and see them going up or down:
in movements.xml add this string:

XML:
<!--Stairs-->
    <movevent type="AddItem" tileitem="1" itemid="8709" event="script" value="/stairs/woodenstairaddtem.lua"/>
    <movevent type="AddItem" tileitem="1" itemid="8596" event="script" value="/stairs/trapdooradditem.lua"/>

and on woodenstairadditem.lua put:
Lua:
function onAddItem(moveitem, tileitem, position)
    if moveitem.itemid > 0 then
        newpos = {x=position.x-1, y=position.y, z=position.z-1}
        doTeleportThing(moveitem.uid, newpos, FALSE)
    else
    return false
    end
    return TRUE
end

and on trapdooradditem.lua put:
Lua:
function onAddItem(moveitem, tileitem, position)
local config = {
      item = 8709, --- Escada horizontal
      item2 = 1396, --- Escada vertical
      }
    if moveitem.itemid > 0 then
        if getTileItemById({x=position.x, y=position.y, z=position.z+1}, config.item).uid > 0 then -- This is for 8709 horizontal stair
        newpos = {x=position.x+1, y=position.y, z=position.z+1}
        doTeleportThing(moveitem.uid, newpos, FALSE)
        elseif getTileItemById({x=position.x, y=position.y, z=position.z+1}, config.item).uid > 0 then -- This is for 1396 vertical stair
        newpos = {x=position.x, y=position.y+1, z=position.z+1}
        doTeleportThing(moveitem.uid, newpos, FALSE)
        else
        newpos = {x=position.x, y=position.y, z=position.z+1} -- If is there no stair on the previous floor
        doTeleportThing(moveitem.uid, newpos, FALSE)
        end
    else
    return false
    end
    return TRUE
end

The next issue is when you put more than 3 objects on the first floor and you put another item it stacks on the trapdoor, is there any way of doing a stack check before the item teleport? so i can put a Cancel massage saying "can't do this" after the teleport floor is full of items
 
Last edited:
Solution
Top