Jump to content
Close
Nazo

Action Town Portal System (based Dota 2)

Recommended Posts

Buenas, TK!

Um mano gringo aí pediu algo do tipo, e eu precisava me familiarizar melhor com a orientação a objetos usada em Lua do TFS 1.3, então fiz esse action, onde o player que possui um scroll pode fazer um portal para seu templo, que é usado dando USE mesmo, e sua party inteira pode ir junto para seus respectivos templos se não estiverem pz locked ou com battle, e caso o player não esteja em uma party, apenas o mesmo pode entrar no portal.

 

Tags XML:

<action itemid="PORTALID HERE" script="townportalsystem.lua"/>
<action itemid="SCROLLID HERE" script="townportalsystem.lua"/>

 

Arquivo townportalsystem.lua em actions/scripts/:

-- Town Portal Scroll System based in Dota 2
-- by Nazo (tibiaking.com)

local config = {
	portalId = 1231,		-- change to portal item id
	portalTime = 30,		-- portal duration in seconds
	scrollId = 1232,		-- change to scroll item id
	effect = CONST_ME_POFF	-- effect id or CONST that appears at the end of time
}

local function removePortal(portal)
    if(portal)
		portal:remove()
		portal:getPosition():sendMagicEffect(config.effect)
    else
		print("Admin excluiu o portal, parabéns")
    end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
	if(item:getId()==config.scrollId) then
		portal = Game.createItem(config.portalId, 1, player:getPosition())
		if(player:getParty()) then
			portal:setCustomAttribute("party", player:getParty())
		else
			portal:setCustomAttribute("owner", player:getName())
		end
		addEvent(removePortal, config.portalTime * 1000, portal)
		item:remove()
	else
		if(not player:isPzLocked() and not player:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT)) then
			if(item:getCustomAttribute("party")) then
				if(player:getParty()==item:getCustomAttribute("party")) then
					player:teleportTo(player:getTown():getTemplePosition(), true)
				else
					player:popupFYI("You do not participate in the portal creator's party.")
				end
			elseif(item:getCustomAttribute("name") and player:getName() == item:getCustomAttribute("name")) then
				player:teleportTo(player:getTown():getTemplePosition(), true)
			else
				player:popupFYI("You isn't the owner.")
			end
		else
			player:popupFYI("You are PZ locked or in battle.")
		end
	end
	return true
end

 


Edited by Nazo (see edit history)

Programador PHP, Lua, Java, database administrator.

 

"Nada é verdade, tudo é permitido."

Requiescat in pace.

Share this post


Link to post
Share on other sites

Parabéns, seu tópico de conteúdo foi aprovado!
Muito obrigado pela sua contribuição, nós do Tibia King agradecemos.
Seu conteúdo com certeza ajudará à muitos outros, você recebeu +1 REP.

Spoiler

Congratulations, your content has been approved!
Thank you for your contribution, we of Tibia King we are grateful.
Your content will help many other users, you received +1 REP.

 



"Eu não luto por que acho que vou vencer, eu luto por que tenho que vencer!"

ichigo.gif
https://github.com/Eternal-Scripts/<

  , _ ,
 ( o o )
/'` ' `'\                     ESTOU TE OBSERVANDO O_O
|'''''''|
|\\'''//|
   """

 

Share this post


Link to post
Share on other sites

Coloca uma verificação na função removePortal para verificar se existe o userdata do item no qual foi enviado no parâmetro. Evita possíveis bugs, e crashs.



CANSADO DE OTS AMADORES?

AuraOT - www.auraot.com

Clique no banner para entrar em nosso site.

 

discord.pngDiscord: vankk #7765

Precisa de ajuda? Entre em contato comigo via Discord.
 

CEO da AuraOT

Programador de Lua, PHP, JavaScript.

 

Muitos vêm seus muitos dias de glória, mas poucos vêm seus muitos dias de luta.

Share this post


Link to post
Share on other sites
7 minutos atrás, vankk disse:

Coloca uma verificação na função removePortal para verificar se existe o userdata do item no qual foi enviado no parâmetro. Evita possíveis bugs, e crashs.

Evita que dê algum bug caso o admin de muita inteligência dar /r no portal, mas como você tá acostumado habituado com tal tipo de erros, tá feito <3 



Programador PHP, Lua, Java, database administrator.

 

"Nada é verdade, tudo é permitido."

Requiescat in pace.

Share this post


Link to post
Share on other sites
5 horas atrás, noktuno disse:

Im mexican!  Nice script btw

Haha, gringo = is a different country u.u


Edited by Nazo (see edit history)

Programador PHP, Lua, Java, database administrator.

 

"Nada é verdade, tudo é permitido."

Requiescat in pace.

Share this post


Link to post
Share on other sites
Agora, noktuno disse:

Learning Br with @Nazo, es muy parecido al español.

 

Yo se, haha



Programador PHP, Lua, Java, database administrator.

 

"Nada é verdade, tudo é permitido."

Requiescat in pace.

Share this post


Link to post
Share on other sites

Olá, bom dia a todos!

 

Coloquei a script exatamente como está aqui, apenas coloquei o ID do portal e o ID do item na script, quando abri o console já deu este erro. E ao usar o item, (de se esperar por causa do erro), não funcionou.

image.thumb.png.396951443a859f8f7b2aa9fa36d869fa.png

 

Eu uso TFS 1.3

image.thumb.png.781b6fee74bdfedbdd94410ccaf963b0.png

 

Valeu clan!


Edited by Trayron1 (see edit history)

Share this post


Link to post
Share on other sites
-- Town Portal Scroll System based in Dota 2
-- by Nazo (tibiaking.com)

local config = {
	portalId = 11796,		-- change to portal item id
	portalTime = 30,		-- portal duration in seconds
	scrollId = 14324,		-- change to scroll item id
	effect = CONST_ME_POFF	-- effect id or CONST that appears at the end of time
}

local function removePortal(portal)
    if(portal)
		portal:remove()
		portal:getPosition():sendMagicEffect(config.effect)
    else
		print("The portal has been undone.")
    end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
	if(item:getId()==config.scrollId) then
		portal = Game.createItem(config.portalId, 1, player:getPosition())
		if(player:getParty()) then
			portal:setCustomAttribute("party", player:getParty())
		else
			portal:setCustomAttribute("owner", player:getName())
		end
		addEvent(removePortal, config.portalTime * 1000, portal)
		item:remove()
	else
		if(not player:isPzLocked() and not player:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT)) then
			if(item:getCustomAttribute("party")) then
				if(player:getParty()==item:getCustomAttribute("party")) then
					player:teleportTo(player:getTown():getTemplePosition(), true)
				else
					player:popupFYI("You do not participate in the portal creator's party.")
				end
			elseif(item:getCustomAttribute("name") and player:getName() == item:getCustomAttribute("name")) then
				player:teleportTo(player:getTown():getTemplePosition(), true)
			else
				player:popupFYI("You isn't the owner.")
			end
		else
			player:popupFYI("You are PZ locked or in battle.")
		end
	end
	return true
end
	<action itemid="11796" script="other/townportalsystem.lua"/>
	<action itemid="14324" script="other/townportalsystem.lua"/>	

 


Edited by Trayron1 (see edit history)

Share this post


Link to post
Share on other sites
-- Town Portal Scroll System based in Dota 2
-- by Nazo (tibiaking.com)

local config = {
	portalId = 11796,		-- change to portal item id
	portalTime = 30,		-- portal duration in seconds
	scrollId = 14324,		-- change to scroll item id
	effect = CONST_ME_POFF	-- effect id or CONST that appears at the end of time
}

local function removePortal(portal)
    if portal then
		portal:remove()
		portal:getPosition():sendMagicEffect(config.effect)
    else
		print("The portal has been undone.")
    end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
	if item:getId() == config.scrollId then
		local portal = Game.createItem(config.portalId, 1, player:getPosition())
		if player:getParty() then
			portal:setCustomAttribute("party", player:getParty())
		else
			portal:setCustomAttribute("owner", player:getName())
		end
		addEvent(removePortal, config.portalTime * 1000, portal)
		item:remove()
	else
		if (not player:isPzLocked() and not player:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT)) then
			if item:getCustomAttribute("party") then
				if player:getParty() == item:getCustomAttribute("party") then
					player:teleportTo(player:getTown():getTemplePosition(), true)
				else
					player:popupFYI("You do not participate in the portal creator's party.")
				end
			elseif item:getCustomAttribute("name") and player:getName() == item:getCustomAttribute("name")) then
				player:teleportTo(player:getTown():getTemplePosition(), true)
			else
				player:popupFYI("You isn't the owner.")
			end
		else
			player:popupFYI("You are PZ locked or in battle.")
		end
	end
	return true
end

 



[OTX3 - 8.60] Projeto STYLLER 2019 (Download)

 

Share this post


Link to post
Share on other sites
2 horas atrás, luanluciano93 disse:

-- Town Portal Scroll System based in Dota 2
-- by Nazo (tibiaking.com)

local config = {
	portalId = 11796,		-- change to portal item id
	portalTime = 30,		-- portal duration in seconds
	scrollId = 14324,		-- change to scroll item id
	effect = CONST_ME_POFF	-- effect id or CONST that appears at the end of time
}

local function removePortal(portal)
    if portal then
		portal:remove()
		portal:getPosition():sendMagicEffect(config.effect)
    else
		print("The portal has been undone.")
    end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
	if item:getId() == config.scrollId then
		local portal = Game.createItem(config.portalId, 1, player:getPosition())
		if player:getParty() then
			portal:setCustomAttribute("party", player:getParty())
		else
			portal:setCustomAttribute("owner", player:getName())
		end
		addEvent(removePortal, config.portalTime * 1000, portal)
		item:remove()
	else
		if (not player:isPzLocked() and not player:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT)) then
			if item:getCustomAttribute("party") then
				if player:getParty() == item:getCustomAttribute("party") then
					player:teleportTo(player:getTown():getTemplePosition(), true)
				else
					player:popupFYI("You do not participate in the portal creator's party.")
				end
			elseif item:getCustomAttribute("name") and player:getName() == item:getCustomAttribute("name")) then
				player:teleportTo(player:getTown():getTemplePosition(), true)
			else
				player:popupFYI("You isn't the owner.")
			end
		else
			player:popupFYI("You are PZ locked or in battle.")
		end
	end
	return true
end

 

 

Copiei e colei a sua, mas no console deu este erro agora:

image.thumb.png.50ad3128dd88096eb353f4c4ec0678e7.png


Share this post


Link to post
Share on other sites
-- Town Portal Scroll System based in Dota 2
-- by Nazo (tibiaking.com)

local config = {
	portalId = 11796,		-- change to portal item id
	portalTime = 30,		-- portal duration in seconds
	scrollId = 14324,		-- change to scroll item id
	effect = CONST_ME_POFF	-- effect id or CONST that appears at the end of time
}

local function removePortal(portal)
    if portal then
		portal:remove()
		portal:getPosition():sendMagicEffect(config.effect)
    else
		print("The portal has been undone.")
    end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
	if item:getId() == config.scrollId then
		local portal = Game.createItem(config.portalId, 1, player:getPosition())
		if player:getParty() then
			portal:setCustomAttribute("party", player:getParty())
		else
			portal:setCustomAttribute("owner", player:getName())
		end
		addEvent(removePortal, config.portalTime * 1000, portal)
		item:remove()
	else
		if not player:isPzLocked() and not player:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT) then
			if item:getCustomAttribute("party") then
				if player:getParty() == item:getCustomAttribute("party") then
					player:teleportTo(player:getTown():getTemplePosition(), true)
				else
					player:popupFYI("You do not participate in the portal creator's party.")
				end
			elseif item:getCustomAttribute("name") and player:getName() == item:getCustomAttribute("name") then
				player:teleportTo(player:getTown():getTemplePosition(), true)
			else
				player:popupFYI("You isn't the owner.")
			end
		else
			player:popupFYI("You are PZ locked or in battle.")
		end
	end
	return true
end

 



[OTX3 - 8.60] Projeto STYLLER 2019 (Download)

 

Share this post


Link to post
Share on other sites

Boa tarde nobre sayajin.

 

Ainda sigo com erro.

Assim que dei use no item pra abrir o portal, deu este erro:

image.thumb.png.533ddfe0bb658b6f27ab61222f9b293d.png

 

Alguns segundos depois, acredito que após os 30 segundos para o portal sumir, deu este erro também e o portal não sumiu.

image.thumb.png.30786ab4fc6680c70100680f3b5f9bc0.png

 

Obrigado por toda ajuda!


Share this post


Link to post
Share on other sites

Ajuda eu por favor <3


Share this post


Link to post
Share on other sites
-- Town Portal Scroll System based in Dota 2

local config = {
	portalId = 11796,		-- change to portal item id
	portalTime = 30,		-- portal duration in seconds
	scrollId = 14324,		-- change to scroll item id
	effect = CONST_ME_POFF	-- effect id or CONST that appears at the end of time
}

local function checkPortal(uid, pos)
    local position = Position(pos)
	if position then
		local tile = Tile(position)
		if tile then
		local item = tile:getItemById(config.portalId)
		if item then
			item:remove()
			item:getPosition():sendMagicEffect(config.effect)
		else
			local playerId = Player(uid)
			if playerId then
				local portal = Game.createItem(config.portalId, 1, position)
				if portal then
					if playerId:getParty() then
						portal:setCustomAttribute("party", playerId:getParty())
					else
						portal:setCustomAttribute("owner", playerId:getName())
					end
				end
				addEvent(checkPortal, config.portalTime * 1000, uid, pos)
			end
		end
	end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
	if item:getId() == config.scrollId then
		checkPortal(player:getGuid(), player:getPosition())
	else
		if not player:isPzLocked() and not player:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT) then
			local itemParty = item:getCustomAttribute("party")
			local itemName = item:getCustomAttribute("name")
			if itemParty then
				if player:getParty() == itemParty or then
					player:teleportTo(player:getTown():getTemplePosition(), true)
				else
					player:popupFYI("You do not participate in the portal creator's party.")
				end
			elseif itemName then
				if player:getName() == itemName then
					player:teleportTo(player:getTown():getTemplePosition(), true)
				else
					player:popupFYI("You isn't the owner.")
				end
			else
				player:popupFYI("You isn't the owner.")
			end
		else
			player:popupFYI("You are PZ locked or in battle.")
		end
	end
	return true
end

 



[OTX3 - 8.60] Projeto STYLLER 2019 (Download)

 

Share this post


Link to post
Share on other sites

Bom dia!

 

Deu este erro no distro:

image.thumb.png.fa08a43c6f6b6c131b89148fd2edf417.png

 

Obrigado por todo suporte que vem me dando.


Share this post


Link to post
Share on other sites
-- Town Portal Scroll System based in Dota 2

local config = {
	portalId = 11796,		-- change to portal item id
	portalTime = 30,		-- portal duration in seconds
	scrollId = 14324,		-- change to scroll item id
	effect = CONST_ME_POFF	-- effect id or CONST that appears at the end of time
}

local function checkPortal(uid, pos)
    local position = Position(pos)
	if position then
		local tile = Tile(position)
		if tile then
		local item = tile:getItemById(config.portalId)
		if item then
			item:remove()
			item:getPosition():sendMagicEffect(config.effect)
		else
			local playerId = Player(uid)
			if playerId then
				local portal = Game.createItem(config.portalId, 1, position)
				if portal then
					if playerId:getParty() then
						portal:setCustomAttribute("party", playerId:getParty())
					else
						portal:setCustomAttribute("owner", playerId:getName())
					end
				end
				addEvent(checkPortal, config.portalTime * 1000, uid, pos)
			end
		end
	end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
	if item:getId() == config.scrollId then
		checkPortal(player:getGuid(), player:getPosition())
	else
		if not player:isPzLocked() and not player:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT) then
			local itemParty = item:getCustomAttribute("party")
			local itemName = item:getCustomAttribute("name")
			if itemParty then
				if player:getParty() == itemParty then
					player:teleportTo(player:getTown():getTemplePosition(), true)
				else
					player:popupFYI("You do not participate in the portal creator's party.")
				end
			elseif itemName then
				if player:getName() == itemName then
					player:teleportTo(player:getTown():getTemplePosition(), true)
				else
					player:popupFYI("You isn't the owner.")
				end
			else
				player:popupFYI("You isn't the owner.")
			end
		else
			player:popupFYI("You are PZ locked or in battle.")
		end
	end
	return true
end

 



[OTX3 - 8.60] Projeto STYLLER 2019 (Download)

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


Open Tibia Server

Quer aprender a criar seu próprio servidor de Tibia? Então está no lugar certo, aqui você encontrará milhares de tutorias, scripts, códigos, mapas e utilitários para que você possa fazer o seu próprio servidor de Tibia começando do zero.

Redes Sociais

Anuncie no Tibia King

Precisa de mais visibilidade em seus projetos? Quer fazer um plano publicitário para o seu servidor? Anuncie no Tibia King e faça sua divulgação, possuímos centenas de acessos simultâneos e milhares diários, com certeza será a sua solução!

×
×
  • Create New...