Ir para conteúdo

Featured Replies

Postado

Este é um evento do tipo lastmanstanding, um evento de guerra que rolava na cidade.

Foi feito pro tfs 0.4

 

Informações sobre configuração está na lib.

 

Em creaturescripts:

Adicione no login. lua:

-- Verificar se é primeira vez que loga, pois ao usar storage ele ja começa com -1,
-- Então vamos zera-lo para que os frags/kills comecem do 0.
if (getPlayerStorageValue(cid, 102089) ~= 1) then
   setPlayerStorageValue(cid, 102089, 1)
   setPlayerStorageValue(cid, configCityWar.storageEvent1, 0)
   setPlayerStorageValue(cid, configCityWar.storageEvent2, 0)
end

registerCreatureEvent(cid, "WarCityDeath")

warCityDeath.lua:

function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
	if isInArea(getCreaturePosition(cid), configCityWar.fromPos, configCityWar.toPos) then
		setPlayerStorageValue(cid, configCityWar.storageEvent2, getPlayerStorageValue(cid, configCityWar.storageEvent2)+1)
		setPlayerStorageValue(lastHitKiller, configCityWar.storageEvent1, getPlayerStorageValue(lastHitKiller, configCityWar.storageEvent1)+1)
	end
return true
end

creaturescripts.xml

<event type="preparedeath" name="WarCityDeath" event="script" value="warCityDeath.lua"/>

 

globalevents:

function onTime(interval)
    OpenEventCityWar()
	return true
end
<globalevent name="CityWar" time="13:18" event="script" value="GlobalEventCityWar.lua"/>

 

lib:

-- Funcionamento: Assim que iniciado o evento, aparecerá um teleport em uma posição pré-determinada na variavel "teleportPosition" que levará
-- os jogadores que pretendem entrar no evento para a posição no mapa configurado em "teleportToPosition", nesse lugar será tipo uma sala de espera
-- que todos os player vão esperar o tempo configurado em "timeTeleport", para que os portões/pedras configurados em "positionsTrapFlorest" sejam
-- abertos e assim iniciando o evento! Não esquece de colocar pvp tool e no logout em toda zona do evento.
 
configCityWar = {
	teleportId = 1387, -- id do teleport.
	storageEvent1 = 59682, -- storage no qual será guardada o número de kill do jogador no evento.
	storageEvent2 = 59683, -- storage no qual será guardada o número de death do jogador no evento.
	storageGlobal = 92831, -- verifica se evento está aberto ou feixado.
	teleportToPosition = {x = 97, y = 72, z = 7}, -- posição para qual o teleporte leva.
	teleportPosition = {x = 32347, y = 32213, z = 7, stackpos = 1}, -- posição que é criado o teleporte na cidade, não é necessario alterar o stackpos.
	timeOpen = 5, -- tempo em minutos que abrirá o teleporte após iniciar o evento.
	timeShow = 3, -- tempo em que fica mostrando na tela os tops frags do evento.
	timeTeleport = 30, -- tempo em minutos para o portal do evento ser fechado altomaticamente, 5 minutos antes do final do evento em si.
	fromPos = {x = 32366, y = 32213, z = 7}, -- area superior esquerda do mapa do evento.
	toPos = {x = 32370, y = 32217, z = 7}, -- area inferior direita do mapa do evento.
}

recompensaCityWar = {
	{itemid = 2160, quant = 5},
	{itemid = 2316, quant = 1} -- pode adicionar quantos premios for necessario, mas a ultima linha deixa sem a virgula final.
}

function OpenEventCityWar() -- abri o evento.
	local posTp = configCityWar.teleportPosition
	for i=0, 255 do
		posTp.stackpos = i
		if (getThingfromPos(posTp).itemid == configCityWar.teleportId) then
			doRemoveItem(getThingfromPos(posTp).uid)
		end
	end
	setGlobalStorageValue(configCityWar.storageGlobal, 1)
	addEvent(OpenTeleport, 1000*60*configCityWar.timeOpen)
	doBroadcastMessage("O teleport para a City War iniciará em ".. configCityWar.timeOpen .." minutos!")
end

function OpenTeleport() -- abri teleporte inicial.
	doCreateTeleport(configCityWar.teleportId, configCityWar.teleportToPosition, configCityWar.teleportPosition)
	addEvent(printCityWar, 1000*60*configCityWar.timeShow)
	addEvent(CloseTeleportCityWar, 1000*60*configCityWar.timeTeleport)
end

function printCityWar()
	if (getStatusCityWar()) then
		showTopsCityWar()
		addEvent(printCityWar, 1000*60*configCityWar.timeShow)
	end
end

function CloseTeleportCityWar() -- fexa teleporte na cidade.
	local posTp = configCityWar.teleportPosition
	for i=0, 255 do
		posTp.stackpos = i
		if (getThingfromPos(posTp).itemid == configCityWar.teleportId) then
			doRemoveItem(getThingfromPos(posTp).uid)
		end
	end
	addEvent(CloseEventCityWar, 1000*60*5)
	doBroadcastMessage("O evento City War acabará em 5 minutos!")
end

function CloseEventCityWar() -- fecha o evento.
	setGlobalStorageValue(configCityWar.storageGlobal, 0)
	removePlayersCityWar()
	premiarTopsCityWar()
	zeraStoragesPlayers()
	doBroadcastMessage("O evento City War foi finalizado, agradecemos aos participantes!")
end

function removePlayersCityWar() -- remove os players do evento.
	local online = getPlayersOnline()
	for i=1, #online do
        if isInArea(getPlayerPosition(online[i]), configCityWar.fromPos, configCityWar.toPos) then
			doTeleportThing(online[i], getTownTemplePosition(getPlayerTown(online[i])))
        end
	end
end

function premiarTopsCityWar() -- adiciona os premios para os ganhadores.
	for i=1, 5 do
		local S = string.explode(listaFrags[i], "-")
        if getPlayerByNameWildcard(S[2]) then
			for i=1, #recompensaCityWar do
				doPlayerAddItem(getPlayerByNameWildcard(S[2]), recompensaCityWar[i].itemid, recompensaCityWar[i].quant)
			end
        else
			local parcel = doCreateItemEx(9081, 1)
			for i=1, #recompensaCityWar do
				doAddContainerItem(parcel, recompensaCityWar[i].itemid, recompensaCityWar[i].quant)
			end
			doPlayerSendMailByName(S[2], parcel)
        end
	end
end

function showTopsCityWar() -- mostra na tela os top frags.
	local listaFrags = {}
	local online = getPlayersOnline()
	
	for i=1, #online do
		listaFrags[#listaFrags+1] = getPlayerStorageValue(online[i], configCityWar.storageEvent1) .."-".. getPlayerName(online[i]) .."-".. getPlayerStorageValue(online[i], configCityWar.storageEvent2)
	end
	
	local stringAux = ""
	for j=1, #listaFrags-1 do
		for i=1, #listaFrags-j do
			local listaPosition1 = string.explode(listaFrags[i], "-")
			local listaPosition2 = string.explode(listaFrags[i+1], "-")
			if (tonumber(listaPosition1[1]) < tonumber(listaPosition2[1])) then
				stringAux = listaFrags[i]
				listaFrags[i] = listaFrags[i+1]
				listaFrags[i+1] = stringAux
			end
		end
	end
	
	local textPrint = "Top City War fraggers: "
	for i=1, 5 do
		local listaPosition = string.explode(listaFrags[i], "-")
		if i~=5 then
			textPrint = textPrint.. listaPosition[2] .."[".. listaPosition[1] .."/".. listaPosition[3] .."], "
		else
			textPrint = textPrint.. listaPosition[2] .."[".. listaPosition[1] .."/".. listaPosition[3] .."]."
		end
	end
	doBroadcastMessage(textPrint)
end

function getTopsCityWar()  -- retorna uma lista com os top frags.
	local listaFrags = {}
	local online = getPlayersOnline()
	
	for i=1, #online do
		listaFrags[#listaFrags+1] = getPlayerStorageValue(online[i], configCityWar.storageEvent1) .."-".. getPlayerName(online[i]) .."-".. getPlayerStorageValue(online[i], configCityWar.storageEvent2)
	end
	
	local stringAux = ""
	for j=1, #listaFrags-1 do
		for i=1, #listaFrags-j do
			local listaPosition1 = string.explode(listaFrags[i], "-")
			local listaPosition2 = string.explode(listaFrags[i+1], "-")
			if (tonumber(listaPosition1[1]) < tonumber(listaPosition2[1])) then
				stringAux = listaFrags[i]
				listaFrags[i] = listaFrags[i+1]
				listaFrags[i+1] = stringAux
			end
		end
	end
	return listaFrags	
end

function getStatusCityWar() -- retorna se o evento esta aberto ou feixado.
	if (getGlobalStorageValue(configCityWar.storageGlobal) > 0) then
		return true
	end
return false	
end

function zeraStoragesPlayers()
    db.executeQuery("UPDATE `player_storage` SET `value` = 0 WHERE `key` = '".. configCityWar.storageEvent1 .."';")
	db.executeQuery("UPDATE `player_storage` SET `value` = 0 WHERE `key` = '".. configCityWar.storageEvent2 .."';")
end

 

talkactions:

function onSay(cid, words, param, channel)
	OpenEventCityWar()
	return true
end
<talkaction log="yes" words="/opencity" access="5" event="script" value="openCityWar.lua"/>

 

  • Respostas 7
  • Visualizações 2.4k
  • Created
  • Última resposta

Top Posters In This Topic

Postado

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.

 

  • 7 months later...

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.6k

Informação Importante

Confirmação de Termo