@Emanueldk, eu preciso saber sobre os 4 ids, quais são da porta horizontal e quais são da vertical ok? Eu vou tentar presumir isso e te ajudar com os códigos prontos, mas se não funcionar me de essa informação que eu resolvo.
em data/actions/actions.xml adicione:
<action itemid="13477" event="script" value="doors/door01.lua"/> <action itemid="13480" event="script" value="doors/door02.lua"/> <action itemid="13479" event="script" value="doors/door03.lua"/> <action itemid="13478" event="script" value="doors/door04.lua"/>
em data/actions/scripts crie um pasta nomeada: doors -> dentro dela crie door01.lua
Para a porta 13479 abrir/se transformar na porta 13480 em door01.lua adicione:
local config = { door1 = {level = 1, uniqueid = 3000}, door2 = {level = 2, uniqueid = 3001}, } local function doorEnter(cid, item, toPosition) doTransformItem(item.uid, item.itemid + 1) doTeleportThing(cid, toPosition) end function onUse(cid, item, toPosition) if item.uid == config.door1.uniqueid then if getPlayerLevel(cid) >= config.door1.level and item.uid == config.door1.uniqueid then doorEnter(cid, item, toPosition) else doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You need level " ..config.door1.level.. " to pass.") end end if item.uid == config.door2.uniqueid then if getPlayerLevel(cid) >= config.door2.level and item.uid == config.door2.uniqueid then doorEnter(cid, item, toPosition) else doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You need level " ..config.door2.level.. " to pass.") end end return TRUE end
Agora para a porta (13480) fechar, vá em data/movements/movements.xml e adicione:
<movevent type="StepOut" itemid="13480" event="script" value="doors/closedoor01.lua"/>
Em data/movements/scripts crie uma pasta nomeada: doors -> dentro dela crie o arquivo closedoor01.lua
Adicione dentro:
function onStepOut(cid, item, position, fromPosition) if(getTileInfo(position).creatures > 0) then return true end local newPosition = {x = position.x, y = position.y, z = position.z} if(isInArray(verticalOpenDoors, item.itemid)) then newPosition.x = newPosition.x + 1 else newPosition.y = newPosition.y + 1 end doRelocate(position, newPosition) local tmpPos = position tmpPos.stackpos = -1 local i, tmpItem, tileCount = 1, {uid = 1}, getTileThingByPos(tmpPos) while(tmpItem.uid ~= 0 and i < tileCount) do tmpPos.stackpos = i tmpItem = getTileThingByPos(tmpPos) if(tmpItem.uid ~= item.uid and tmpItem.uid ~= 0 and not isMoveable(tmpItem.uid)) then doRemoveItem(tmpItem.uid) else i = i + 1 end end doTransformItem(item.uid, item.itemid - 1) return true end
Segunda parte -> em data/actions/scripts/doors crie door02.lua
Para a porta 13478 abrir/se transformar na porta 13477 em door02.lua adicione:
local config = { door1 = {level = 1, uniqueid = 4000}, door2 = {level = 2, uniqueid = 4001}, } local function doorEnter(cid, item, toPosition) doTransformItem(item.uid, item.itemid - 1) doTeleportThing(cid, toPosition) end function onUse(cid, item, toPosition) if item.uid == config.door1.uniqueid then if getPlayerLevel(cid) >= config.door1.level and item.uid == config.door1.uniqueid then doorEnter(cid, item, toPosition) else doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You need level " ..config.door1.level.. " to pass.") end end if item.uid == config.door2.uniqueid then if getPlayerLevel(cid) >= config.door2.level and item.uid == config.door2.uniqueid then doorEnter(cid, item, toPosition) else doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You need level " ..config.door2.level.. " to pass.") end end return TRUE end
Agora para a porta (13477) fechar, vá em data/movements/movements.xml e adicione:
<movevent type="StepOut" itemid="13477" event="script" value="doors/closedoor02.lua"/>
Em data/movements/scripts crie uma pasta nomeada: doors -> dentro dela crie o arquivo closedoor02.lua
Adicione dentro:
function onStepOut(cid, item, position, fromPosition) if(getTileInfo(position).creatures > 0) then return true end local newPosition = {x = position.x, y = position.y, z = position.z} if(isInArray(verticalOpenDoors, item.itemid)) then newPosition.x = newPosition.x + 1 else newPosition.y = newPosition.y + 1 end doRelocate(position, newPosition) local tmpPos = position tmpPos.stackpos = -1 local i, tmpItem, tileCount = 1, {uid = 1}, getTileThingByPos(tmpPos) while(tmpItem.uid ~= 0 and i < tileCount) do tmpPos.stackpos = i tmpItem = getTileThingByPos(tmpPos) if(tmpItem.uid ~= item.uid and tmpItem.uid ~= 0 and not isMoveable(tmpItem.uid)) then doRemoveItem(tmpItem.uid) else i = i + 1 end end doTransformItem(item.uid, item.itemid + 1) return true end
Dentro dos dois scripts de actions, door01.lua e door02.lua, tem essas duas configurações:
local config = {
door1 = {level = 1, uniqueid = 3000},
door2 = {level = 2, uniqueid = 3001},
}
e:
local config = {
door1 = {level = 1, uniqueid = 4000},
door2 = {level = 2, uniqueid = 4001},
}
Como configurar:
- Se não quiser utilizar level na door, apenas não adicione o uniqueid na porta. Se quiser, faça o contrário. (não esqueça de registrar esse uniqueid lá em actions.xml);
- Não mexa aqui;
- Aqui você configura o level para passar.




info
Grupo: Campones
Registrado: 08/03/18
Posts: 98
Reputação: 0
Gênero: Masculino
o que eu fiz de errado que essas portas ainda nao querem abrir, e nem fechar?
eu ja adicionei no actions.xml
<action itemid="13477" event="script" value="other/doors.lua"/>
<action itemid="13478" event="script" value="other/doors.lua"/>
<action itemid="13479" event="script" value="other/doors.lua"/>
<action itemid="13480" event="script" value="other/doors.lua"/>
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
action/scripts/doors "nao mexi em nada, so coloquei aqui para que se for pra modificar, voces me ajudarem"
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(item.actionid == 189) then
if(not isPremium(cid)) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only the worthy may pass.")
return true
end
doorEnter(cid, item, toPosition)
return true
end
local gender = item.actionid - 186
if(isInArray({PLAYERSEX_FEMALE, PLAYERSEX_MALE, PLAYERSEX_GAMEMASTER}, gender)) then
if(gender ~= getPlayerSex(cid)) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only the worthy may pass.")
return true
end
doorEnter(cid, item, toPosition)
return true
end
local skull = item.actionid - 180
if(skull >= SKULL_NONE and skull <= SKULL_BLACK) then
if(skull ~= getCreatureSkullType(cid)) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only the worthy may pass.")
return true
end
doorEnter(cid, item, toPosition)
return true
end
local group = item.actionid - 150
if(group >= 0 and group < 30) then
if(group > getPlayerGroupId(cid)) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only the worthy may pass.")
return true
end
doorEnter(cid, item, toPosition)
return true
end
local vocation = item.actionid - 100
if(vocation >= 0 and vocation < 50) then
local playerVocationInfo = getVocationInfo(getPlayerVocation(cid))
if(playerVocationInfo.id ~= vocation and playerVocationInfo.fromVocation ~= vocation) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only the worthy may pass.")
return true
end
doorEnter(cid, item, toPosition)
return true
end
if(item.actionid == 190 or (item.actionid ~= 0 and getPlayerLevel(cid) >= (item.actionid - getItemLevelDoor(item.itemid)))) then
doorEnter(cid, item, toPosition)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only the worthy may pass.")
end
return true
end
if(isInArray(specialDoors, item.itemid)) then
if(item.actionid == 100 or (item.actionid ~= 0 and getPlayerStorageValue(cid, item.actionid) > 0)) then
doorEnter(cid, item, toPosition)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "The door seems to be sealed against unwanted intruders.")
end
return true
end
if(isInArray(keys, item.itemid)) then
if(itemEx.actionid > 0) then
if(item.actionid == itemEx.actionid and doors[itemEx.itemid] ~= nil) then
doTransformItem(itemEx.uid, doors[itemEx.itemid])
return true
end
doPlayerSendCancel(cid, "The key does not match.")
return true
end
return false
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
if(doors[item.itemid] ~= nil and checkStackpos(item, fromPosition)) then
if(item.actionid == 0) then
doTransformItem(item.uid, doors[item.itemid])
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is locked.")
end
return true
end
return false
end
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
items.xml
</item>
<item id="13477" article="an" name="open door">
<attribute key="type" value="door" />
</item>
<item id="13480" article="an" name="open door">
<attribute key="type" value="door" />
</item>
<item id="13479" article="an" name="closed door">
<attribute key="type" value="door" />
</item>
<item id="13478" article="an" name="closed door">
<attribute key="type" value="door" />
</item>