MC
script

HELP WAR CASTLE AUTOMATICO

Por mczx4ndinho, 14 de jul. de 2015 em Archived

6
931
mczx4ndinhoM
14 de julho de 2015 às 03:21

Queria Saber se esse script da pra deixa automatico \/


SE TIVER COMO COLOCA TAG TB PLIZ












local THRONE_POS = {x = 561, y = 446, z = 5}

local STORAGE_EVENT = 83902

local STORAGE_PLAYER = 73289

local DUR = 10 -- in minutes

function OpenEvent()

for _, tid in ipairs(getPlayersOnline()) do

setPlayerStorageValue(tid, STORAGE_PLAYER, 1)

end

setGlobalStorageValue(STORAGE_EVENT, 1)

doBroadcastMessage("O Evento castle foi aberto.", 25)

end

function getWinnerCastle(cid)

CastleWalls()

local player = getTopCreature(THRONE_POS).uid

if getGlobalStorageValue(STORAGE_EVENT) < 0 then

return true

end

if (isPlayer(player)) then

if (getPlayerStorageValue(player, STORAGE_PLAYER) > 0) then

pid = getPlayerGUID(cid)

setHouseOwner(6258, pid)

doPlayerAddPremiumDays(player, 7)

for _, cid in ipairs(getPlayersOnline()) do

setPlayerStorageValue(cid, STORAGE_PLAYER, 0)

doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))

end

doBroadcastMessage(getCreatureName(player) .. " ganhou o evento.", 25)

doTeleportThing(player, {x = 531, y = 460, z = 7})

doCreateItem(391, 1, {x = 500, y = 500, z = 7})

end

else

doBroadcastMessage("Ningúem ganhou o evento.", 27)

for _, pid in ipairs(getPlayersOnline()) do

setPlayerStorageValue(pid, STORAGE_PLAYER, 0)

doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)))

end

end

setGlobalStorageValue(STORAGE_EVENT, 0)

return db.executeQuery("DELETE FROM `player_storage` WHERE `key` = " .. STORAGE_PLAYER)

end

function CastleWalls()

local pedra = getTileItemById({ x = 539, y = 474, z = 7}, 1285)

local escada = getTileItemById({ x = 539, y = 474, z = 7}, 3687)

if pedra.uid > 0 then

return doRemoveItem(pedra.uid)

else

return doCreateItem(1285, 1, { x = 500, y = 500, z = 7})

end

if escada.uid > 0 then

return doRemoveItem(escada.uid)

else

return doCreateItem(3687, 1, {x = 500, y = 500, z = 7})

end

end

function onSay(cid, words, param, channel)

if ((param == "abrir") and (getGlobalStorageValue(STORAGE_EVENT) == 1)) then

doPlayerSendTextMessage(cid, 27, "O evento já esta aberto.") return true

elseif ((param == "fechar") and (getGlobalStorageValue(STORAGE_EVENT) == 1)) then

getWinnerCastle()

CastleWalls()

return true

end

doCreateItem(3687, 1, {x = 500, y = 500, z = 7})

OpenEvent()

CastleWalls()

addEvent(getWinnerCastle, DUR * 60 * 1000)

return true

end


HelflinH
15 de julho de 2015 às 13:53

Eu sei que o War OF Emperium é um castle automatico, que acontece em dias e horarios que vc define... Quanto a esse seu castle eu não sei não, mas pode ser que alguém consiga fazer isso...

BrunoB
15 de julho de 2015 às 14:57

@@mczx4ndinho,

 

Vá em data/globalevents/globalevents.xml e adicione a seguinte tag:

<globalevent name="autoEvent" interval="50000" event="script" value="evento.lua"/>
Agora vá em data/globalevents/scripts, crie um arquivo chamado evento.lua com o seguinte conteúdo:

 

 

--[[
	Segunda-feira - monday
	Terça-feira - tuesday
	Quarta-feira - wednesday
	Quinta-feira - thursday
	Sexta-feira - friday
	Sábado - saturday
	Domingo - sunday
	
	** Vale lembrar que o horário é baseado no horário do servidor que o OT está rodando
]]

local config = {
	days = {'monday', 'wednesday', 'friday', 'sunday'},
	hour = 18,
	minu = 00
}

local THRONE_POS = {x = 561, y = 446, z = 5}
local STORAGE_EVENT = 83902
local STORAGE_PLAYER = 73289
local DUR = 10 -- in minutes

function OpenEvent()
          for _, tid in ipairs(getPlayersOnline()) do
                    setPlayerStorageValue(tid, STORAGE_PLAYER, 1)
          end
          setGlobalStorageValue(STORAGE_EVENT, 1)
          doBroadcastMessage("O Evento castle foi aberto.", 25)
end

function getWinnerCastle(cid)
          CastleWalls()
          local player = getTopCreature(THRONE_POS).uid
          if getGlobalStorageValue(STORAGE_EVENT) < 0 then
                    return true
          end
          if (isPlayer(player)) then
                    if (getPlayerStorageValue(player, STORAGE_PLAYER) > 0) then
                              pid = getPlayerGUID(cid)
                              setHouseOwner(6258, pid)
                              doPlayerAddPremiumDays(player, 7)
                              for _, cid in ipairs(getPlayersOnline()) do
                                        setPlayerStorageValue(cid, STORAGE_PLAYER, 0)
                                        doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
                              end
                              doBroadcastMessage(getCreatureName(player) .. " ganhou o evento.", 25)
                              doTeleportThing(player, {x = 531, y = 460, z = 7})
                              doCreateItem(391, 1, {x = 500, y = 500, z = 7})
                    end
          else
                    doBroadcastMessage("Ningúem ganhou o evento.", 27)
                    for _, pid in ipairs(getPlayersOnline()) do
                              setPlayerStorageValue(pid, STORAGE_PLAYER, 0)
                              doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)))
                    end
          end
          setGlobalStorageValue(STORAGE_EVENT, 0)
          return db.executeQuery("DELETE FROM `player_storage` WHERE `key` = " .. STORAGE_PLAYER)
end

function CastleWalls()
          local pedra = getTileItemById({ x = 539, y = 474, z = 7}, 1285)
          local escada = getTileItemById({ x = 539, y = 474, z = 7}, 3687)
          if pedra.uid > 0 then
                    return doRemoveItem(pedra.uid)
          else
                    return doCreateItem(1285, 1, { x = 500, y = 500, z = 7})
          end
          if escada.uid > 0 then
                    return doRemoveItem(escada.uid)
          else
                    return doCreateItem(3687, 1, {x = 500, y = 500, z = 7})
          end
end

function onThink(interval, lastExecution, thinkInterval)
	for _, b in ipairs(config) do
		local day = os.date("%A", static_time):lower()
		if isInArray(b.days, day) then
			local hour = tonumber(os.date("%H", static_time))
			if b.hour == hour then
				local minute = tonumber(os.date("%M", static_time))
				if b.minu == minute then
					doCreateItem(3687, 1, {x = 500, y = 500, z = 7})
					OpenEvent()
					CastleWalls()
					addEvent(getWinnerCastle, DUR * 60 * 1000)
				end
			end
		end
	end
	return true
end

 

 

Seu script está configura para abrir todos os dias as 18h00 (horário do servidor).

Editado Julho 16 por Bruno Minervino

mczx4ndinhoM
16 de julho de 2015 às 02:34

ok vou testa jaja falo se foi resolvido :D


[16/07/2015 02:31:37] [Error - GlobalEvents::think] Couldn't execute event: evento

 

me salva ae pliz e se tem como coloca segunta ,quarta ,sexta ,doming0

Editado Julho 16 por mczx4ndinho

BrunoB
16 de julho de 2015 às 06:06

ok vou testa jaja falo se foi resolvido :D

[16/07/2015 02:31:37] [Error - GlobalEvents::think] Couldn't execute event: evento

 

me salva ae pliz e se tem como coloca segunta ,quarta ,sexta ,domingo

Refaz os procedimentos...

Alterei conforme sua solicitação, muda a tag xml também.

1 mês depois...
BrunoB
03 de agosto de 2015 às 11:50

O tópico foi fechado e movido para lixeira por estar inativo a mais de 10 dias. Caso seja preciso reabrir o mesmo, favor entrar em contato com a equipe.