MA

Sistema De Portas & Tiles Avançado!

Por MarcolinoGOD, 25 de mar. de 2009 em Actions e Talkactions

otserv
tibia
script
23
6.5k
MarcolinoGODM
25 de março de 2009 às 14:12

Sistema de portas & tiles avançado.

 

Tive apenas o trabalho de traduzir e postar aqui para vocês e espero que gostem! :blush:

 

Créditos: slawkens :smile_positivo:

 

Este pack ira adicionar novas features nas suas portas, e special tiles.

 

Usos: Você pode usar em level doors ou tiles especiais (Isto pode ser usado nos tiles usados em depots -ex. id: 416)

 

Coloque a actionid para isto:

-
100+vocationID
- somente por vocações

example
-
104
- Somente Knight podem passar (Elite Knight também!), você deve colocar actionid = 108 para que somente Elite Knights possam passar. Isto funciona com vocações customizadas também!

-
200+groupID
- somente por grupo

Exemplo
-
202
- Somente Tutores podem passar.

-
300+skullID
- Somente players com Skull

Exemplo
-
304
- Somente players com RED_SKULL podem entrar

-
400
- somente mulheres podem entrar

-
401
- somente homens

-
500
- somente premium accounts

 

Estes são somente para TILES:

-
501
- tile - somente para players

-
502
- tile - somente para monstros

-
503
- tile - somente para NPCs

 

-
506
- tile -
não
podem passar players

-
507
- tile -
não
podem passar monstros

-
508
- tile -
não
podem passar NPCs

 

-
504
- tile - não podem passar players (somente monstros & NPCs podem entrar) [Deprecated - NÃO use, prefira usar 506]

 

-
1000+level - level tile

Exemplo
-
1150
- somente players com level 1150+ podem passar.

 

OK! Agora vamos trabalhar!

 

Troque em actions/scripts/other/doors.lua por isso:

PLAYERSEX_FEMALE = 0

PLAYERSEX_MALE = 1

 

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)

if(item.uid ~= thing.uid and thing.itemid >= 100 or field.itemid ~= 0) then

return FALSE

end

 

return TRUE

end

 

local function doPlayerOpenDoor(cid, item, toPosition)

doTransformItem(item.uid, item.itemid + 1)

doTeleportThing(cid, toPosition, TRUE)

end

 

function onUse(cid, item, fromPosition, itemEx, toPosition)

if(getItemLevelDoor(item.itemid) > 0) then

if(item.actionid == 500) then

if(isPremium(cid) ~= TRUE) then

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Premium account required to enter.")

return TRUE

end

 

doPlayerOpenDoor(cid, item, toPosition)

return TRUE

end

 

local gender = item.actionid - 400

if(gender == PLAYERSEX_FEMALE or gender == PLAYERSEX_MALE) then

local playerSex = getPlayerSex(cid)

if(playerSex ~= gender) then

local tmp = {"females", "males"}

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Doors only for " .. tmp[gender+ 1] .. ".")

return TRUE

end

 

doPlayerOpenDoor(cid, item, toPosition)

return TRUE

end

 

local skull = item.actionid - 300

if(skull >= 0 and skull <= 50) then

local playerSkull = getCreatureSkullType(cid)

if(skull == 0 and playerSkull ~= SKULL_NONE) then

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Doors only for players without skull.")

return TRUE

elseif(playerSkull ~= skull) then

local skulls = {"yellow", "green", "white", "red"}

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Doors only for players with " .. skulls[playerSkull] .. " skulls.")

return TRUE

end

 

doPlayerOpenDoor(cid, item, toPosition)

return TRUE

end

 

local group = item.actionid - 200

if(group >= 0 and group <= 50) then

local playerGroup = getPlayerGroupId(cid)

if(playerGroup < group) then

local tmp = getGroupInfo(group)

if(tmp ~= FALSE) then

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Doors only for " .. tmp.name .. "s.")

end

 

return TRUE

end

 

doPlayerOpenDoor(cid, item, toPosition)

return TRUE

end

 

local vocation = item.actionid - 100

if(vocation >= 0 and vocation <= 50) then

local playerVocation = getVocationInfo(getPlayerVocation(cid))

if(playerVocation.id ~= vocation and playerVocation.fromVocation ~= vocation) then

local tmp = getVocationInfo(vocation)

if(tmp ~= FALSE) then

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Doors only for " .. tmp.name .. "s.")

end

 

return TRUE

end

 

doPlayerOpenDoor(cid, item, toPosition)

return TRUE

end

 

if(item.actionid > 0 and getPlayerLevel(cid) >= (item.actionid - getItemLevelDoor(item.itemid))) then

doPlayerOpenDoor(cid, item, toPosition)

else

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only the worthy may pass.")

end

 

return TRUE

end

 

if(isInArray(specialDoors, item.itemid) == TRUE) then

if(item.actionid == 100 or (item.actionid ~= 0 and getPlayerStorageValue(cid, item.actionid) > 0)) then

doPlayerOpenDoor(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) == TRUE) then

if(itemEx.actionid > 0) then

if(item.actionid == itemEx.actionid) then

if doors[itemEx.itemid] ~= nil then

doTransformItem(itemEx.uid, doors[itemEx.itemid])

return TRUE

end

end

 

doPlayerSendCancel(cid, "The key does not match.")

return TRUE

end

 

return FALSE

end

 

if(isInArray(horizontalOpenDoors, item.itemid) == TRUE and checkStackpos(item, fromPosition) == TRUE) 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

if(getTilePzInfo(doorPosition) == TRUE and getTilePzInfo(newPosition) == FALSE and doorCreature.uid ~= cid) then

doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)

else

doTeleportThing(doorCreature.uid, newPosition, TRUE)

if(isInArray(closingDoors, item.itemid) ~= TRUE) 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) == TRUE and checkStackpos(item, fromPosition) == TRUE) 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(getTilePzInfo(doorPosition) == TRUE and getTilePzInfo(newPosition) == FALSE and doorCreature.uid ~= cid) then

doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)

else

doTeleportThing(doorCreature.uid, newPosition, TRUE)

if(isInArray(closingDoors, item.itemid) ~= TRUE) 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) == TRUE) 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

 

Troque em movements/scripts/tiles.lua por isto:

PLAYERSEX_FEMALE = 0

PLAYERSEX_MALE = 1

 

local increasingItems = {[416] = 417, [426] = 425, [446] = 447, [3216] = 3217, [3202] = 3215}

local decreasingItems = {[417] = 416, [425] = 426, [447] = 446, [3217] = 3216, [3215] = 3202}

local depots = {2589, 2590, 2591, 2592}

 

local function doPlayerMoveBack(cid, position, fromPosition)

doTeleportThing(cid, fromPosition, FALSE)

doSendMagicEffect(position, CONST_ME_MAGIC_BLUE)

end

 

local creatureFunc = {isPlayer, isMonster, isNpc}

function onStepIn(cid, item, position, fromPosition)

if(not increasingItems[item.itemid]) then

return TRUE

end

 

if(isPlayer(cid) ~= TRUE or isPlayerGhost(cid) ~= TRUE) then

doTransformItem(item.uid, increasingItems[item.itemid])

end

 

if(item.actionid >= 501 and item.actionid <= 503) then

local f = creatureFunc[item.actionid-500]

if(f(cid) ~= TRUE) then

doPlayerMoveBack(cid, position, fromPosition)

end

 

return TRUE

end

 

if(item.actionid == 504 and isPlayer(cid) == TRUE) then

doPlayerMoveBack(cid, position, fromPosition)

return TRUE

end

 

if(item.actionid >= 506 and item.actionid <= 508) then

local f = creatureFunc[item.actionid-505]

if(f(cid) == TRUE) then

doPlayerMoveBack(cid, position, fromPosition)

end

 

return TRUE

end

 

if(isPlayer(cid) ~= TRUE) then

return TRUE

end

 

if(item.actionid == 500 and isPremium(cid) ~= TRUE) then

doPlayerMoveBack(cid, position, fromPosition)

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Premium account required to enter.")

return TRUE

end

 

local gender = item.actionid - 400

if(gender == PLAYERSEX_FEMALE or gender == PLAYERSEX_MALE) then

local playerSex = getPlayerSex(cid)

if(playerSex ~= gender) then

local tmp = {"females", "males"}

doPlayerMoveBack(cid, position, fromPosition)

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only " .. tmp[gender+ 1] .. " can enter.")

end

 

return TRUE

end

 

local skull = item.actionid - 300

if(skull >= 0 and skull <= 50) then

local playerSkull = getCreatureSkullType(cid)

if(skull == 0 and playerSkull ~= SKULL_NONE) then

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only players without skull can enter.")

doPlayerMoveBack(cid, position, fromPosition)

elseif(playerSkull ~= skull) then

local skulls = {"yellow", "green", "white", "red"}

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only players with " .. skulls[playerSkull] .. " skull can enter.")

doPlayerMoveBack(cid, position, fromPosition)

end

 

return TRUE

end

 

local group = item.actionid - 200

if(group >= 0 and group <= 50) then

local playerGroup = getPlayerGroupId(cid)

if(playerGroup < group) then

doPlayerMoveBack(cid, position, fromPosition)

local tmp = getGroupInfo(group)

if(tmp ~= FALSE) then

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only " .. tmp.name .. "s can enter.")

end

end

 

return TRUE

end

 

local vocation = item.actionid - 100

if(vocation >= 0 and vocation <= 50) then

local playerVocation = getVocationInfo(getPlayerVocation(cid))

if(playerVocation.id ~= vocation and playerVocation.fromVocation ~= vocation) then

local tmp = getVocationInfo(vocation)

if(tmp ~= FALSE) then

doPlayerMoveBack(cid, position, fromPosition)

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only " .. tmp.name .. "s can enter.")

end

end

 

return TRUE

end

 

if(item.actionid > 1000) then

if(getPlayerLevel(cid) < item.actionid - 1000) then

doPlayerSendCancel(cid, "You need " .. item.actionid - 1000 .. " level to enter here.")

doPlayerMoveBack(cid, position, fromPosition)

end

elseif(getTileInfo(position).protection) then

local depotPos = getPlayerLookPos(cid)

depotPos.stackpos = 3 -- ground = 0, table = 1, depot should be 2

--local depot = getThingFromPos(depotPos)

local depot

for i = 0, #depots do

depot = getTileItemById(depotPos, depots)

if(depot.uid > 0) then

break

end

end

 

if(depot.uid > 0 and isInArray(depots, depot.itemid) == TRUE) then

local depotItems = getPlayerDepotItems(cid, getDepotId(depot.uid))

if(depotItems < 2) then

doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Your depot contains 1 item.")

else

doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Your depot contains " .. depotItems .. " items.")

end

end

end

 

return TRUE

end

 

function onStepOut(cid, item, position, fromPosition)

if(decreasingItems[item.itemid] ~= nil) then

if(isPlayer(cid) ~= TRUE or isPlayerGhost(cid) ~= TRUE) then

doTransformItem(item.uid, decreasingItems[item.itemid])

end

end

 

return TRUE

end

 

Agora funciona no TFS 0.3.4 PL1...

Editado Maio 21 por Albert José

SchiavinatoS
25 de março de 2009 às 15:41

Facil de entender, facil aplicação no ot, e de uma funcionalidade perfeita

 

:]

 

Aprovado

Editado Abril 9 por Schiavinato

dwhfmsD
25 de março de 2009 às 15:51

Gostei, entendi tudo direitinho, para mim merece fixo! Muito obrigado por trazer isso para o nosso forum :)

MarcolinoGODM
25 de março de 2009 às 20:28
Não intendi mto bem isso dai...

Tpw, se eu colokar isso no meu ot, e colokar o action id 104 na porta, ker dize q soh kina passa?

 

E assim por diante?

Isto mesmo amigo! Só você ler direitinho que não tem erro...

Boa sorte e obrigado por comentar. :positive:

 

Gostei, entendi tudo direitinho, para mim merece fixo! Muito obrigado por trazer isso para o nosso forum :)

Muito obrigado por comentar e "de nada"...

Não sei se merece fixo mas que é util e pratico não podemos descordar!

 

@For All

Não seja Sangue-Suga... Comente! :smile_positivo:

Editado Março 25 por Albert José

DiogoD
26 de março de 2009 às 14:25

Muito com cara, parabéns ae =D

1 mês depois...
MarcolinoGODM
07 de abril de 2009 às 12:42

@VaL

Obrigado por comentar e que com que gostou...

 

Esse será provavelmente meu ultimo post aqui no XTibia ja que aqui

a maioria dos usuarios só sabem sugar e sugar e nada de comentar!!!

 

Até mais...

gkaonicx72G
07 de abril de 2009 às 12:47

Ai gostei parabens continue assim mais so que uma coisa que tal fazer para GM?? ouseja seria muito util eu acho pelomenos para mim sim hehe

CriticalC
08 de abril de 2009 às 20:57

Perfeito , Mereçe Fixo ^^ , Valeu Por Nos Trazer Isso :D

 

 

Atenciosamente , Critical

3 semanas depois...
linkayL
24 de abril de 2009 às 21:58

:surprised:Cara, útil de mais, parabens a você por traser a action, e um super parabéns ao criador da action, o trabalho quê deve dar configurar todas as actions...

Por mim merece Fixo

KhostK
25 de abril de 2009 às 22:14

kra uma pergunta eu vo em door tiro a que eu tenho ponho essa ?? e tb oq eu fasso com as actions que valiam pra antiga door??? substituo por essas ?? como fikaria posta ae!

 

Khost!

careca21C
27 de abril de 2009 às 00:19

Meu Querido Parabens Otimo Trabalho :smile_positivo:

Henrique MouraH
27 de abril de 2009 às 03:05

Troque os CODEBOX por QUOTEBOX.

Assim fica melhor a visualização e não estraga o layout do fórum.

Abraços.

\Mattheus ~*\
28 de abril de 2009 às 21:13

Gostei !

Vlw

 

Funfo aqui no meu OT ;x

ThorzenhOoOT
29 de abril de 2009 às 17:06
Facil de entender, facil aplicação no ot, e de uma funcionalidade perfeita

 

:]

 

Aprovado

 

Concordo 100% ! com oque vocÊ disse.

E qualquer Ot que seje "perfeito" , tem este tipo de sistema =))

 

Abraços e continue nos trazendo scripts bons como este !

Faz um escelente trabalho

 

:smile_positivo:

1 mês depois...
MarcolinoGODM
21 de maio de 2009 às 17:43

~ :excl: ~ Atualizado ~ :excl: ~



 

Agradeço ao slawkens pela atualização...