FA
action

[Duvida] Porta que abre com Chave

Por Farathor, 29 de mai. de 2016 em Scripts

2
1.5k
FarathorF
29 de maio de 2016 às 19:22

Pessoal, eu sempre tive a duvida de como criar uma porta que só poderá ser aberta por certa chave

Eu jogava um servidor a um tempo atras, que em um quest, vc ganhava uma chave, e essa chave servia para abrir uma porta que era a entrada de uma certa  cave

gostaria que vocês me ajudassem, obrigado !

 

OBS: esse é o script que eu tenho

 

 

	REVERSE_DOORS, CHILD_DOORS = {}, {}	for k, v in pairs(DOORS) do	    REVERSE_DOORS[v] = k	    local tmp = getItemInfo(v)	    if(tmp.transformUseTo ~= 0) then	        CHILD_DOORS[tmp.transformUseTo] = k	    end	end	function onUse(cid, item, fromPosition, itemEx, toPosition)	    if(item.aid > 0 and itemEx.aid > 0) then	        if(isPlayerPzLocked(cid) and getTileInfo(toPosition).protection) then	            doPlayerSendDefaultCancel(cid, RETURNVALUE_ACTIONNOTPERMITTEDINPROTECTIONZONE)	            return true	        end	        local doors = DOORS[itemEx.itemid]	        if(not doors) then	            doors = REVERSE_DOORS[itemEx.itemid]	        end	        if(not doors) then	            doors = CHILD_DOORS[itemEx.itemid]	        end	        if(doors) then	            if(item.actionid ~= itemEx.actionid) then	                doPlayerSendCancel(cid, "The key does not match.")	            else	                doTransformItem(itemEx.uid, doors)	            end	            return true	        end	    end	    return false	end	

 

Editado Maio 29 por Farathor

ImperatrizI
29 de maio de 2016 às 20:14

Olha, eu uso esse daqui, a porta abre com um determinado item por um determinado tempo ( no caso 10 segundos ) eu testei no PDA e funciona normalmente

crie um arquivo em actions com o nome "porta.lua"

 

Citar

local config = {
    itens = {2090, 1},          --ID do item/quantidade que deve "dar" a porta.
    time = 10,                    --Tempo, em segundos, para a porta fechar.
    storage = 90661,
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, config.storage) > -1 then
        return doPlayerSendCancel(cid, "You already passed through the door.")
    elseif getPlayerItemCount(cid, config.itens[1]) < config.itens[2] then
        return doPlayerSendCancel(cid, "You need "..config.itens[2].." "..getItemNameById(config.itens[1]).." to open the door.")
    end
    local guid, name, itemid = getPlayerGUID(cid), getCreatureName(cid), item.itemid + 1
    addEvent(function()
        item = getTileItemById(toPosition, itemid).uid
        if item > 0 then
            doItemSetAttribute(item, "aid", 7815)
            doTransformItem(item, itemid - 1)
        end
        if isPlayer(cid) then
            setPlayerStorageValue(cid, config.storage, 1)
        else
            cid = getPlayerByName(name)
            if isCreatlocal config = {
    itens = {2090, 1},          --ID do item/quantidade que deve "dar" a porta.
    time = 10,                    --Tempo, em segundos, para a porta fechar.
    storage = 90661,
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, config.storage) > -1 then
        return doPlayerSendCancel(cid, "You already passed through the door.")
    elseif getPlayerItemCount(cid, config.itens[1]) < config.itens[2] then
        return doPlayerSendCancel(cid, "You need "..config.itens[2].." "..getItemNameById(config.itens[1]).." to open the door.")
    end
    local guid, name, itemid = getPlayerGUID(cid), getCreatureName(cid), item.itemid + 1
    addEvent(function()
        item = getTileItemById(toPosition, itemid).uid
        if item > 0 then
            doItemSetAttribute(item, "aid", 7815)
            doTransformItem(item, itemid - 1)
        end
        if isPlayer(cid) then
            setPlayerStorageValue(cid, config.storage, 1)
        else
            cid = getPlayerByName(name)
            if isCreature(cid) then
                setPlayerStorageValue(cid, config.storage, 1)
            else
                db.executeQuery("UPDATE player_storage SET value = 1 WHERE key = "..config.storage.." AND player_id = "..guid)
            end
        end
    end, config.time * 1000)
    doPlayerRemoveItem(cid, config.itens[1], config.itens[2])
    doPlayerSendTextMessage(cid, 27, "You sacrificed "..config.itens[2].." "..getItemNameById(config.itens[1]).." to open the door.")
    doTransformItem(item.uid, item.itemid + 1)
    doItemSetAttribute(item.uid, "aid", 7815)
    return true
end
ure(cid) then
                setPlayerStorageValue(cid, config.storage, 1)
            else
                db.executeQuery("UPDATE player_storage SET value = 1 WHERE key = "..config.storage.." AND player_id = "..guid)
            end
        end
    end, config.time * 1000)
    doPlayerRemoveItem(cid, config.itens[1], config.itens[2])
    doPlayerSendTextMessage(cid, 27, "You sacrificed "..config.itens[2].." "..getItemNameById(config.itens[1]).." to open the door.")
    doTransformItem(item.uid, item.itemid + 1)
    doItemSetAttribute(item.uid, "aid", 7815)
    return true
end

e em Actions.xml  <action actionid="7815" event="script" value="porta.lua"/>