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

Action Script

Castic

Member
Joined
Sep 10, 2010
Messages
175
Reaction score
7
I'm in need of a script that if you use a door and you don't have a certain storagevalue, you won't be able to use it, and a text appears to. If you do have the required storagevalue you can use the door, and it closes behind you as well.

For example:
(If you dont have the required storagevalue)
You have not completed the required quest to pass through this door. Complete the quest if you want to pass!
 
use a gate of expertise
XML:
<action uniqueid="2345" event="script" value="storage.lua"/>
Lua:
-- \\ CONFIG // --
local STORAGE = 13456
local VALUE = 1 --required value of storage to pass thru expertise gate
local TEXT = 'You may not pass.'
-- //         \\ --

local function checkStackpos(item, position)
    position.stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE
    local thing = getThingFromPos(position)
 
    position.stackpos = STACKPOS_TOP_FIELD
    local field = getThingFromPos(position)
 
    return (item.uid == thing.uid or thing.itemid < 100 or field.itemid == 0)
end
 
local function doorEnter(cid, item, toPosition)
    doTransformItem(item.uid, item.itemid + 1)
    doTeleportThing(cid, toPosition)
end
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(fromPosition.x ~= CONTAINER_POSITION and isPlayerPzLocked(cid) and getTileInfo(fromPosition).protection) then
        doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
        return true
    end
 
    if(getItemLevelDoor(item.itemid) > 0) then
        if getCreatureStorage(cid, STORAGE) ~= VALUE then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, TEXT)
            return true
        end
 
        doorEnter(cid, item, toPosition)
        return true
    end
 
    if(isInArray(horizontalOpenDoors, item.itemid) and checkStackpos(item, fromPosition)) then
        local newPosition = toPosition
        newPosition.y = newPosition.y + 1
        local doorPosition = fromPosition
        doorPosition.stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE
        local doorCreature = getThingfromPos(doorPosition)
        if(doorCreature.itemid ~= 0) then
            local pzDoorPosition = getTileInfo(doorPosition).protection
            local pzNewPosition = getTileInfo(newPosition).protection
            if((pzDoorPosition and not pzNewPosition and doorCreature.uid ~= cid) or
                (not pzDoorPosition and pzNewPosition and doorCreature.uid == cid and isPlayerPzLocked(cid))) then
                doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
            else
                doTeleportThing(doorCreature.uid, newPosition)
                if(not isInArray(closingDoors, item.itemid)) then
                    doTransformItem(item.uid, item.itemid - 1)
                end
            end
 
            return true
        end
 
        doTransformItem(item.uid, item.itemid - 1)
        return true
    end
 
    if(isInArray(verticalOpenDoors, item.itemid) and checkStackpos(item, fromPosition)) then
        local newPosition = toPosition
        newPosition.x = newPosition.x + 1
        local doorPosition = fromPosition
        doorPosition.stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE
        local doorCreature = getThingfromPos(doorPosition)
        if(doorCreature.itemid ~= 0) then
            if(getTileInfo(doorPosition).protection and not getTileInfo(newPosition).protection and doorCreature.uid ~= cid) then
                doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
            else
                doTeleportThing(doorCreature.uid, newPosition)
                if(not isInArray(closingDoors, item.itemid)) then
                    doTransformItem(item.uid, item.itemid - 1)
                end
            end
 
            return true
        end
 
        doTransformItem(item.uid, item.itemid - 1)
        return true
    end
 
    return false
end
 
Back
Top