Ir para conteúdo

Featured Replies

  • Respostas 26
  • Visualizações 4.8k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

Posted Images

Postado
-- 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
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

 

Postado

Bom dia!

 

A script agora funciona sem erro algum no console, porém não está reconhecendo que quem abriu o portal é o dono.

E por isso, da este erro:

image.png.08f32c7766a69169458facbad49d6622.png

Obrigado por consertar pra mim <3

Postado
-- 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:setAttribute(ITEM_ATTRIBUTE_TEXT, playerId:getParty())
						end
						portal:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, playerId:getName())
					end
					addEvent(checkPortal, config.portalTime * 1000, uid, pos)
				end
			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:getAttribute(ITEM_ATTRIBUTE_TEXT)
			local itemDescription = item:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION)
			if itemParty then
				local party = player:getParty()
				if party then
					if party == itemParty then
						player:teleportTo(player:getTown():getTemplePosition(), true)
						return true
					else
						player:popupFYI("You do not participate in the portal creator's party.")
					end
				end
			elseif itemDescription then
				if player:getName() == itemDescription then
					player:teleportTo(player:getTown():getTemplePosition(), true)
				else
					player:popupFYI("You isn't the owner.")
					return true
				end
			end
		else
			player:popupFYI("You are PZ locked or in battle.")
		end
	end
	return true
end

 

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo