Jump to content

Recommended Posts

Olá galera do TK,

 

Provavelmente maioria aqui não me conhece, meu nome é Raphael ( Fael ), e minha área preferida é o mapa porém estou com um conteúdo aqui que muitos buscam separado mas não encontram.

O bom evento Run Event.

 

É um evento de corrida em um mapa com muitos obstáculos.

Todos os players possuem a mesma velocidade.

Objetivo muito simples, o primeiro que chegar no final vence :)

Para entrar no evento é preciso dizer "!run" a mensagem será anunciada na hora que preciso.

Tem que estar em área pz pra executa-lo.

 

Bom vamos ao MOD:

 

OTserver/Mod/... Adiciona um RunEvent.xml

 

 

Script:

<?xml version="1.0" encoding="UTF-8"?>
<mod name="Run_Event" version="3.0" author="CollocorpuseK" contact="otland.net" enabled="yes">

	<config name="config_run_event">
		<![CDATA[
			configRunEvent = {
				storages = {
					player = 'runEventPlayer', -- set free storage
					joining = 'runEventJoining', -- set free storage
					group = 'runEventGroup', -- set free storage
					exhaust = 'runEventExhaust', -- set free storage
					countEvent = 'runEventCountEvent' -- set free storage
				},

				position = {x=885, y=1002, z=7}, -- Posicao que vai ser teleportado os players
				
				rewards = {9931, 7697, 2346, 8880}, -- Itens pro vencedor ( Sera sortido)
				players = {
					max = 45, -- Maximo de player
					min = 5, -- Minimo de player
					minLevel = 100, -- Level minimo pra entrar no evento
					speed = 200 -- Velocidade que todos ficaram
				},
				
				days = {
					['Monday'] = {'16:00:20'},
					['Tuesday'] = {'16:00:20'},
					['Wednesday'] = {'16:00:20'},
					['Thursday'] = {'16:00:20'},
					['Friday'] = {'16:00:20'},
					['Saturday'] = {'16:00:20'},
					['Sunday'] = {'16:00:20'}
				},

				delayTime = 5.0, -- Tempo pros players dizer o comando [minutos]
				startEvent = 2, -- Tempo pra começar o evento quando todos players tiverem no local [ segundos ]
				text = 'Vai comecar o Run Evento, se preparem'
			}
		]]>
	</config>

	<lib name="lib_run_event">
		<![CDATA[
			function doStartEventRun()
				if configRunEvent.players.min <= doCountPlayersRunEvent() then
					for _, cid in ipairs(getPlayersOnline()) do
						if getCreatureStorage(cid, configRunEvent.storages.player) > 0 then
							doRemoveCondition(cid, CONDITION_INFIGHT) -- fight
							doTeleportThing(cid, configRunEvent.position)	-- teleport pos
							doChangeSpeed(cid, configRunEvent.players.speed - getCreatureBaseSpeed(cid)) -- predkosc
							doCreatureSetStorage(cid, configRunEvent.storages.group, getPlayerGroupId(cid)) -- storage
							doPlayerSetGroupId(cid, 7) -- grupa
							addEvent(doCreatureSetNoMove, configRunEvent.startEvent * 1000, cid, false)
							doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, 'Get ready. Run Event start in '..configRunEvent.startEvent..' seconds.')
						end
					end

					addEvent(doCheckSpeedRunEvent, configRunEvent.startEvent * 1000)
					doBroadcastMessage('Run Event has started. LET\'S GO!')
				else
					for _, cid in ipairs(getPlayersOnline()) do
						if getCreatureStorage(cid, configRunEvent.storages.player) > 0 then
							doCreatureSetStorage(cid, configRunEvent.storages.player, -1)
							doCreatureSetNoMove(cid, false)
							doRemoveCondition(cid, CONDITION_INFIGHT)
						end
					end

					doBroadcastMessage('Run Event hasn\'t started beacuse there were not enough players.')
				end

				doSetStorage(configRunEvent.storages.joining, -1)
			end

			function doCountPlayersRunEvent()
				local x = 0
				for _, cid in ipairs(getPlayersOnline()) do
					if getCreatureStorage(cid, configRunEvent.storages.player) > 0 then
						x = x + 1
					end
				end
				return x
			end
			
			function doStartCountingRunEvent(x)
				if configRunEvent.delayTime-x > 0 then
					doBroadcastMessage('Run Event is going to start in '..configRunEvent.delayTime-x..' minutes. You can join to the event by saying "!run join".')
					addEvent(doStartCountingRunEvent, 60*1000, x+1)
				end
			end

			function doCheckSpeedRunEvent()
				if doCountPlayersRunEvent() > 0 then
					addEvent(doCheckSpeedRunEvent, 1000)
				end

				for _, cid in ipairs(getPlayersOnline()) do
					if getCreatureStorage(cid, configRunEvent.storages.player) > 0 then
						if getCreatureSpeed(cid) ~= configRunEvent.players.speed then
							doChangeSpeed(cid, (getCreatureSpeed(cid) < configRunEvent.players.speed and configRunEvent.players.speed - getCreatureSpeed(cid) or getCreatureSpeed(cid) > configRunEvent.players.speed and - (getCreatureSpeed(cid) - configRunEvent.players.speed)))
						end
					end
				end
			end
		]]>
	</lib>

	<talkaction words="!run" event="script">
		<![CDATA[
			domodlib("config_run_event")

			function onSay(cid, words, param)
				if getStorage(configRunEvent.storages.joining) ~= 1 then
					return doPlayerSendCancel(cid, 'The Run Event hasn\'t started yet.')
				elseif param == '' then
					return doPlayerSendCancel(cid, 'Command param required (say: "!run join" or "!run leave.").')
				elseif getPlayerLevel(cid) < configRunEvent.players.minLevel then
					return doPlayerSendCancel(cid, 'You can\'t join to the event if you don\'t have a require '..configRunEvent.players.minLevel..' level.')
				elseif getTileInfo(getThingPos(cid)).protection ~= true then
					return doPlayerSendCancel(cid, 'You can\'t join to the event if you aren\'t in protection zone.')
				elseif exhaustion.check(cid, configRunEvent.storages.exhaust) ~= false then
					return doPlayerSendCancel(cid, 'You must wait '..exhaustion.get(cid, configRunEvent.storages.exhaust)..' seconds to use this command again.')
				end

				if param == 'join' then
					if getCreatureStorage(cid, configRunEvent.storages.player) > 0 then
						return doPlayerSendCancel(cid, 'You have arleady joined to event. Wait patiently for start.')
					elseif doCountPlayersRunEvent() == configRunEvent.players.max then
						return doPlayerSendCancel(cid, 'Max players in the event have been reached.')
					end

					doCreatureSetNoMove(cid, true)
					doPlayerPopupFYI(cid, configRunEvent.text)
					doCreatureSetStorage(cid, configRunEvent.storages.player, 1)
					doAddCondition(cid, createConditionObject(CONDITION_INFIGHT, -1))
					doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, 'You have joined to Run Event. You can\'t move until event don\'t start. Wait patiently for the event start.')
					doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, 'You have joined to Run Event.')					
				elseif param == 'leave' then
					if getCreatureStorage(cid, configRunEvent.storages.player) <= 0 then
						return doPlayerSendCancel(cid, 'You can\'t leave from the event if you don\'t join.')
					end

					doCreatureSetNoMove(cid, false)
					doCreatureSetStorage(cid, configRunEvent.storages.player, -1)
					doRemoveCondition(cid, CONDITION_INFIGHT)
					doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, 'You have left from the Run Event.')
				end

				exhaustion.set(cid, configRunEvent.storages.exhaust, 5)
				return true
			end
		]]>
	</talkaction>

	<talkaction words="!startrun" access="5" event="script">
		<![CDATA[
			domodlib("config_run_event")
			domodlib("lib_run_event")

			function onSay(cid, words, param)
				doSetStorage(configRunEvent.storages.joining, 1)
				addEvent(doStartEventRun, configRunEvent.delayTime * 60 * 1000)
				doStartCountingRunEvent(0)

				for _, pid in ipairs(getPlayersOnline()) do
					if getCreatureStorage(pid, configRunEvent.storages.player) > 0 then
						doCreatureSetStorage(pid, configRunEvent.storages.player, -1)

						doPlayerSetGroupId(pid, getCreatureStorage(pid, configRunEvent.storages.group))
						doChangeSpeed(pid, getCreatureBaseSpeed(pid) - configRunEvent.players.speed)
						doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)), true)
					end
				end
				return true
			end
		]]>
	</talkaction>

	<movement type="StepIn" actionid="5467" event="script">
		<![CDATA[
			domodlib("config_run_event")

			function onStepIn(cid, item, position)
				if getCreatureStorage(cid, configRunEvent.storages.player) > 0 then
					local prize = math.random(#configRunEvent.rewards)

					doCreatureSetStorage(cid, configRunEvent.storages.player, -1)
					doPlayerAddItem(cid, configRunEvent.rewards[prize], 1)
					doChangeSpeed(cid, getCreatureBaseSpeed(cid) - configRunEvent.players.speed)
					doPlayerSetGroupId(cid, math.max(1, getCreatureStorage(cid, configRunEvent.storages.group)))
					doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), true)
					doBroadcastMessage('Run Event has finished. The winner is '..getCreatureName(cid)..'.')
					doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, 'You are winner. You have won '..getItemNameById(configRunEvent.rewards[prize])..'.')
					db.query("INSERT INTO `events` (`event_name`, `winner_name`, `won_item`, `time_win`) VALUES (\"Run\", \"" .. getCreatureName(cid) .. "\", \"" .. getItemNameById(configRunEvent.rewards[prize]) .. "\", " .. getStorage(configRunEvent.storages.countEvent) ..");")

					doSetStorage(configRunEvent.storages.countEvent, getStorage(configRunEvent.storages.countEvent) + 1)

					for _, pid in ipairs(getPlayersOnline()) do
						if getCreatureStorage(pid, configRunEvent.storages.player) > 0 then
							doCreatureSetStorage(pid, configRunEvent.storages.player, -1)
							
							doPlayerSetGroupId(pid, math.max(1, getCreatureStorage(pid, configRunEvent.storages.group)))
							doChangeSpeed(pid, getCreatureBaseSpeed(pid) - configRunEvent.players.speed)
							doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)), true)
							doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE, 'You loss.')
						end
					end
				end
				return true
			end
		]]>
	</movement>

	<globalevent name="Run_Event_Days" interval="1000" event="script">
		<![CDATA[
			domodlib("config_run_event")
			domodlib("lib_run_event")

			local daysOpen = {}
			for k, v in pairs(configRunEvent.days) do
				table.insert(daysOpen, k)
			end

			function onThink(interval)
				if isInArray(daysOpen, os.date("%A")) then
					if isInArray(configRunEvent.days[os.date("%A")], os.date("%X", os.time())) then
						if getStorage(configRunEvent.storages.joining) ~= 1 then
							doSetStorage(configRunEvent.storages.joining, 1)
							addEvent(doStartEventRun, configRunEvent.delayTime * 60 * 1000)
							doStartCountingRunEvent(0)

							for _, pid in ipairs(getPlayersOnline()) do
								if getCreatureStorage(pid, configRunEvent.storages.player) > 0 then
									doCreatureSetStorage(pid, configRunEvent.storages.player, -1)

									doPlayerSetGroupId(pid, math.max(1, getCreatureStorage(pid, configRunEvent.storages.group)))
									doChangeSpeed(pid, getCreatureBaseSpeed(pid) - configRunEvent.players.speed)
									doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)), true)
								end
							end
						end
					end
				end
				return true
			end
		]]>
	</globalevent>

	<event type="login" name="Run_Event_Login" event="script">
		<![CDATA[
			domodlib("config_run_event")

			function onLogin(cid)
				if getCreatureStorage(cid, configRunEvent.storages.player) > 0 then
					doCreatureSetStorage(cid, configRunEvent.storages.player, -1)
					doPlayerSetGroupId(cid, math.max(1, getCreatureStorage(cid, configRunEvent.storages.group)))
					doCreatureSetNoMove(cid, false)
					doRemoveCondition(cid, CONDITION_INFIGHT)
					doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), true)
				end
				return true
			end
		]]>
	</event>
	
	<globalevent name="Run_Event_Start" type="startup" event="script">
		<![CDATA[
			domodlib("config_run_event")

			function onStartup()
				doSetStorage(configRunEvent.storages.joining, -1)
				return true
			end
		]]>
	</globalevent>
</mod>

Executem essa QUERY na sua DataBase


  1. CREATE TABLE `events` (   `event_name` varchar(255) NOT NULL,   `winner_name` varchar(255) NOT NULL,   `won_item` varchar(255) NOT NULL,   `time_win` varchar(256) NOT NULL,   PRIMARY KEY  (`event_name`) );

 

No final do mapa para marcar o vencedor você marque um ActionID - 5467 no piso final.

 

Não dou suporte !

 

 

 

Mapa Link

Edited by Faelzdanil (see edit history)
Link to post
Share on other sites

Muito obrigado pela contribuição.. significa muito pro Tibia King.
 

Todos os meus trabalhos importantes estão na seção "Sobre mim" no meu perfil; Dá uma passada lá!

"Há três caminhos para o fracasso: não ensinar o que se sabe, não praticar o que se ensina, e não perguntar o que se ignora." - São Beda

I7Pm6ih.png

(obg ao @Beeny por fazer essa linda sign <3)

Link to post
Share on other sites

Ai esta dando erro no evento
quanto abro o tfs e uso a versao 0.4

 

> Loading RunEvent.xml...[Error - ScriptingManager::loadFromXml] Cannot load mod mods/RunEvent.xml
[27/05/2014 23:47:11] Line: 35, Info: Input is not proper UTF-8, indicate encoding !
[27/05/2014 23:47:11] Bytes: 0xE7 0x61 0x72 0x20

EM BREVE BAIAK FAST 2019

Link to post
Share on other sites

 

Ai esta dando erro no evento

quanto abro o tfs e uso a versao 0.4

 

> Loading RunEvent.xml...[Error - ScriptingManager::loadFromXml] Cannot load mod mods/RunEvent.xml
[27/05/2014 23:47:11] Line: 35, Info: Input is not proper UTF-8, indicate encoding !
[27/05/2014 23:47:11] Bytes: 0xE7 0x61 0x72 0x20

 

eu tb to com esse erro .......

A mais uma dica faz uma instalação tirando print de como seria colocando no mapa  ai fica melhor .

Link to post
Share on other sites

Mesmo erro

 

> Loading RunEvent.xml...[Error - ScriptingManager::loadFromXml] Cannot load mod mods/RunEvent.xml
[28/05/2014 13:09:44] Line: 36, Info: Input is not proper UTF-8, indicate encoding !
[28/05/2014 13:09:44] Bytes: 0xE7 0x61 0x72 0x20
 
e executei as query que voce mando =s

EM BREVE BAIAK FAST 2019

Link to post
Share on other sites

estou com um erro kai 

 

 

mods/RunEvent.xml:1: parser error : xmlParsePI : no target name
<? xml version = "1.0" encoding = "UTF-8" ?>
  ^
mods/RunEvent.xml:1: parser error : Start tag expected, '<' not found
<? xml version = "1.0" encoding = "UTF-8" ?>
   ^
[15:57:12.250] > Loading RunEvent.xml...[Error - ScriptManager::loadFromXml] Can
not load mod mods/RunEvent.xml
[15:57:12.251] Line: 1, Info: Start tag expected, '<' not found

Link to post
Share on other sites

Estou com Este Erro no Distro 0.4

> Loading RunEvent.xml...[Error - ScriptingManager::loadFromXml] Cannot load mod mods/RunEvent.xml
[28/05/2014 13:09:44] Line: 36, Info: Input is not proper UTF-8, indicate encoding !
[28/05/2014 13:09:44] Bytes: 0xE7 0x61 0x72 0x20
Alguem me ajuda ?





configRunEvent = {
storages = {
player = 'runEventPlayer', -- set free storage
joining = 'runEventJoining', -- set free storage
group = 'runEventGroup', -- set free storage
exhaust = 'runEventExhaust', -- set free storage
countEvent = 'runEventCountEvent' -- set free storage
},

position = {x=885, y=1002, z=7}, -- Posicao que vai ser teleportado os players

rewards = {9931, 7697, 2346, 8880}, -- Itens pro vencedor ( Sera sortido)
players = {
max = 45, -- Maximo de player
min = 5, -- Minimo de player
minLevel = 100, -- Level minimo pra entrar no evento
speed = 200 -- Velocidade que todos ficaram
},

days = {
['Monday'] = {'16:00:20'},
['Tuesday'] = {'16:00:20'},
['Wednesday'] = {'16:00:20'},
['Thursday'] = {'16:00:20'},
['Friday'] = {'16:00:20'},
['Saturday'] = {'16:00:20'},
['Sunday'] = {'16:00:20'}
},

delayTime = 5.0, -- Tempo pros players dizer o comando [minutos]
startEvent = 2, -- Tempo pra começar o evento quando todos players tiverem no local [ segundos ]
text = 'Vai comecar o Run Evento, se preparem'
}
]]>



function doStartEventRun()
if configRunEvent.players.min <= doCountPlayersRunEvent() then
for _, cid in ipairs(getPlayersOnline()) do
if getCreatureStorage(cid, configRunEvent.storages.player) > 0 then
doRemoveCondition(cid, CONDITION_INFIGHT) -- fight
doTeleportThing(cid, configRunEvent.position) -- teleport pos
doChangeSpeed(cid, configRunEvent.players.speed - getCreatureBaseSpeed(cid)) -- predkosc
doCreatureSetStorage(cid, configRunEvent.storages.group, getPlayerGroupId(cid)) -- storage
doPlayerSetGroupId(cid, 7) -- grupa
addEvent(doCreatureSetNoMove, configRunEvent.startEvent * 1000, cid, false)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, 'Get ready. Run Event start in '..configRunEvent.startEvent..' seconds.')
end
end

addEvent(doCheckSpeedRunEvent, configRunEvent.startEvent * 1000)
doBroadcastMessage('Run Event has started. LET\'S GO!')
else
for _, cid in ipairs(getPlayersOnline()) do
if getCreatureStorage(cid, configRunEvent.storages.player) > 0 then
doCreatureSetStorage(cid, configRunEvent.storages.player, -1)
doCreatureSetNoMove(cid, false)
doRemoveCondition(cid, CONDITION_INFIGHT)
end
end

doBroadcastMessage('Run Event hasn\'t started beacuse there were not enough players.')
end

doSetStorage(configRunEvent.storages.joining, -1)
end

function doCountPlayersRunEvent()
local x = 0
for _, cid in ipairs(getPlayersOnline()) do
if getCreatureStorage(cid, configRunEvent.storages.player) > 0 then
x = x + 1
end
end
return x
end

function doStartCountingRunEvent(x)
if configRunEvent.delayTime-x > 0 then
doBroadcastMessage('Run Event is going to start in '..configRunEvent.delayTime-x..' minutes. You can join to the event by saying "!run join".')
addEvent(doStartCountingRunEvent, 60*1000, x+1)
end
end

function doCheckSpeedRunEvent()
if doCountPlayersRunEvent() > 0 then
addEvent(doCheckSpeedRunEvent, 1000)
end

for _, cid in ipairs(getPlayersOnline()) do
if getCreatureStorage(cid, configRunEvent.storages.player) > 0 then
if getCreatureSpeed(cid) ~= configRunEvent.players.speed then
doChangeSpeed(cid, (getCreatureSpeed(cid) < configRunEvent.players.speed and configRunEvent.players.speed - getCreatureSpeed(cid) or getCreatureSpeed(cid) > configRunEvent.players.speed and - (getCreatureSpeed(cid) - configRunEvent.players.speed)))
end
end
end
end
]]>



domodlib("config_run_event")

function onSay(cid, words, param)
if getStorage(configRunEvent.storages.joining) ~= 1 then
return doPlayerSendCancel(cid, 'The Run Event hasn\'t started yet.')
elseif param == '' then
return doPlayerSendCancel(cid, 'Command param required (say: "!run join" or "!run leave.").')
elseif getPlayerLevel(cid) < configRunEvent.players.minLevel then
return doPlayerSendCancel(cid, 'You can\'t join to the event if you don\'t have a require '..configRunEvent.players.minLevel..' level.')
elseif getTileInfo(getThingPos(cid)).protection ~= true then
return doPlayerSendCancel(cid, 'You can\'t join to the event if you aren\'t in protection zone.')
elseif exhaustion.check(cid, configRunEvent.storages.exhaust) ~= false then
return doPlayerSendCancel(cid, 'You must wait '..exhaustion.get(cid, configRunEvent.storages.exhaust)..' seconds to use this command again.')
end

if param == 'join' then
if getCreatureStorage(cid, configRunEvent.storages.player) > 0 then
return doPlayerSendCancel(cid, 'You have arleady joined to event. Wait patiently for start.')
elseif doCountPlayersRunEvent() == configRunEvent.players.max then
return doPlayerSendCancel(cid, 'Max players in the event have been reached.')
end

doCreatureSetNoMove(cid, true)
doPlayerPopupFYI(cid, configRunEvent.text)
doCreatureSetStorage(cid, configRunEvent.storages.player, 1)
doAddCondition(cid, createConditionObject(CONDITION_INFIGHT, -1))
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, 'You have joined to Run Event. You can\'t move until event don\'t start. Wait patiently for the event start.')
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, 'You have joined to Run Event.')
elseif param == 'leave' then
if getCreatureStorage(cid, configRunEvent.storages.player) <= 0 then
return doPlayerSendCancel(cid, 'You can\'t leave from the event if you don\'t join.')
end

doCreatureSetNoMove(cid, false)
doCreatureSetStorage(cid, configRunEvent.storages.player, -1)
doRemoveCondition(cid, CONDITION_INFIGHT)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, 'You have left from the Run Event.')
end

exhaustion.set(cid, configRunEvent.storages.exhaust, 5)
return true
end
]]>



domodlib("config_run_event")
domodlib("lib_run_event")

function onSay(cid, words, param)
doSetStorage(configRunEvent.storages.joining, 1)
addEvent(doStartEventRun, configRunEvent.delayTime * 60 * 1000)
doStartCountingRunEvent(0)

for _, pid in ipairs(getPlayersOnline()) do
if getCreatureStorage(pid, configRunEvent.storages.player) > 0 then
doCreatureSetStorage(pid, configRunEvent.storages.player, -1)

doPlayerSetGroupId(pid, getCreatureStorage(pid, configRunEvent.storages.group))
doChangeSpeed(pid, getCreatureBaseSpeed(pid) - configRunEvent.players.speed)
doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)), true)
end
end
return true
end
]]>



domodlib("config_run_event")

function onStepIn(cid, item, position)
if getCreatureStorage(cid, configRunEvent.storages.player) > 0 then
local prize = math.random(#configRunEvent.rewards)

doCreatureSetStorage(cid, configRunEvent.storages.player, -1)
doPlayerAddItem(cid, configRunEvent.rewards[prize], 1)
doChangeSpeed(cid, getCreatureBaseSpeed(cid) - configRunEvent.players.speed)
doPlayerSetGroupId(cid, math.max(1, getCreatureStorage(cid, configRunEvent.storages.group)))
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), true)
doBroadcastMessage('Run Event has finished. The winner is '..getCreatureName(cid)..'.')
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, 'You are winner. You have won '..getItemNameById(configRunEvent.rewards[prize])..'.')
db.query("INSERT INTO `events` (`event_name`, `winner_name`, `won_item`, `time_win`) VALUES (\"Run\", \"" .. getCreatureName(cid) .. "\", \"" .. getItemNameById(configRunEvent.rewards[prize]) .. "\", " .. getStorage(configRunEvent.storages.countEvent) ..");")

doSetStorage(configRunEvent.storages.countEvent, getStorage(configRunEvent.storages.countEvent) + 1)

for _, pid in ipairs(getPlayersOnline()) do
if getCreatureStorage(pid, configRunEvent.storages.player) > 0 then
doCreatureSetStorage(pid, configRunEvent.storages.player, -1)

doPlayerSetGroupId(pid, math.max(1, getCreatureStorage(pid, configRunEvent.storages.group)))
doChangeSpeed(pid, getCreatureBaseSpeed(pid) - configRunEvent.players.speed)
doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)), true)
doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE, 'You loss.')
end
end
end
return true
end
]]>



domodlib("config_run_event")
domodlib("lib_run_event")

local daysOpen = {}
for k, v in pairs(configRunEvent.days) do
table.insert(daysOpen, k)
end

function onThink(interval)
if isInArray(daysOpen, os.date("%A")) then
if isInArray(configRunEvent.days[os.date("%A")], os.date("%X", os.time())) then
if getStorage(configRunEvent.storages.joining) ~= 1 then
doSetStorage(configRunEvent.storages.joining, 1)
addEvent(doStartEventRun, configRunEvent.delayTime * 60 * 1000)
doStartCountingRunEvent(0)

for _, pid in ipairs(getPlayersOnline()) do
if getCreatureStorage(pid, configRunEvent.storages.player) > 0 then
doCreatureSetStorage(pid, configRunEvent.storages.player, -1)

doPlayerSetGroupId(pid, math.max(1, getCreatureStorage(pid, configRunEvent.storages.group)))
doChangeSpeed(pid, getCreatureBaseSpeed(pid) - configRunEvent.players.speed)
doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)), true)
end
end
end
end
end
return true
end
]]>



domodlib("config_run_event")

function onLogin(cid)
if getCreatureStorage(cid, configRunEvent.storages.player) > 0 then
doCreatureSetStorage(cid, configRunEvent.storages.player, -1)
doPlayerSetGroupId(cid, math.max(1, getCreatureStorage(cid, configRunEvent.storages.group)))
doCreatureSetNoMove(cid, false)
doRemoveCondition(cid, CONDITION_INFIGHT)
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), true)
end
return true
end
]]>



domodlib("config_run_event")

function onStartup()
doSetStorage(configRunEvent.storages.joining, -1)
return true
end
]]>

Edited by DeathRocks (see edit history)

EM BREVE BAIAK FAST 2019

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.

  • Similar Content

    • By Fausto32
      Script/Tutorial+ Php +Map +Talkaction +Portal.
      Ps: Antes de falar q o topico já existe no forum teste os outros scripts
      Então começando por informações basícas :
      Para abrir o evento : /zombiestart numero de players . exemplo : /zombiestart 2
      Para Iniciar o evento sem o numero maximo de players: /zombiestart force.
      Apos aberto sempre q um player ente no portal do evento e avisado por broadcast quem
      entrou na arena e o numero de players restantes para o evento ser iniciado.
      Apos o evento ser iniciado um zombie e sumonado a cada 20 segundos, o player que for infectado e teleportado para o templo vence o ultimo player restante na arena.
      Ao terminar o evento e anuciado por broadcast o nome do player vencedor tempo q durou na arena e por quantos zombies ele sobreviveu, entrega de premio automatica, premio configuravel.
      Garantia de funcionabilidade perfeita em TFS 0.4 se configurado corretamente, não testado em outras versões de distros.
      Creditos: Me .. não criei mais montei peguei de varios servers/topicos e corigi os varios bugs de distro colocaria os creditos de onde peguei a maioria do script mais foi de um server sem creditos q nem era pra ter sido postado.
      Enfim Vamos ao Evento !
      Primeiro vou estar postando a pagina classica do Zombie event no Gesior que seria a parte PHP para informar os players sobre o evento.
      Pagina PHP + Tutorial de como implementar ela no seu site.
      Agora alguns mapas para o zombie event:
      Então Agora vamos ao script !
      data\creaturescripts\scripts\zombie – A pasta ‘zombie’ deve ser criada no diretorio citado.
      \data\creaturescripts\scripts\Zombie\onattack.lua
        function loseOnZombieArena(cid) kickPlayerFromZombiesArea(cid) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "BOOM! You are dead.") local players = getZombiesEventPlayers() if(#players <= 1) then local winner = players[1] if(winner) then doPlayerAddItem(winner, 2157, 5, true) doPlayerAddItem(winner, 6119, 1, true) doPlayerSendTextMessage(winner, MESSAGE_STATUS_CONSOLE_BLUE, "You won zombies arena event.") doBroadcastMessage("After " .. os.time() - getPlayerZombiesEventStatus(winner) .. " seconds of fight " .. getCreatureName(winner) .. " won Zombie Arena Event in game versus " .. getStorage(ZE_ZOMBIES_SPAWNED) .. " zombies!") kickPlayerFromZombiesArea(winner) else doBroadcastMessage("Zombie arena event finished! No one win?!?!?! WTF!") end doSetStorage(ZE_STATUS, 0) doSetStorage(ZE_PLAYERS_NUMBER, ZE_DEFAULT_NUMBER_OF_PLAYERS) doSetStorage(ZE_ZOMBIES_TO_SPAWN, 0) doSetStorage(ZE_ZOMBIES_SPAWNED, 0) local width = (math.max(ZE_spawnFromPosition.x, ZE_spawnToPosition.x) - math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)) / 2 + 1 local height = (math.max(ZE_spawnFromPosition.y, ZE_spawnToPosition.y) - math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)) / 2 + 1 local centerPos = {x=math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)+width,y=math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)+height,z=ZE_spawnFromPosition.z} for z = math.min(ZE_spawnFromPosition.z, ZE_spawnToPosition.z), math.max(ZE_spawnFromPosition.z, ZE_spawnToPosition.z) do centerPos.z = z for i, uid in pairs(getSpectators(centerPos, width, height, false)) do if(isMonster(uid)) then doRemoveCreature(uid) end end end end end function onStatsChange(target, cid, changetype, combat, value) if((cid and isMonster(cid) and getCreatureName(cid) == "Zombie Event") or (isInRange(getThingPosition(target), ZE_spawnFromPosition, ZE_spawnToPosition) and changetype == STATSCHANGE_HEALTHLOSS and math.abs(value) >= getCreatureHealth(target))) then doCreatureAddHealth(target, getCreatureMaxHealth(target)) loseOnZombieArena(target) return false end return true end \data\creaturescripts\scripts\Zombie\ondeath.lua
        function onDeath(cid) setZombiesToSpawnCount(getZombiesToSpawnCount() + 2) doCreatureSay(cid, "I'll be back!", 19) return true end \data\creaturescripts\scripts\Zombie\onthink.lua
        function onThink(cid) local target = getCreatureTarget(cid) if(target ~= 0 and not isPlayer(target)) then doRemoveCreature(target) end return true end \data\globalevents\scripts\zombie\ onstartup.lua
        function onstartup() db.executeQuery("UPDATE `player_storage` SET `value` = 0 WHERE `key` = " .. ZE_isOnZombieArea .. ";") doSetStorage(ZE_STATUS, 0) doSetStorage(ZE_PLAYERS_NUMBER, ZE_DEFAULT_NUMBER_OF_PLAYERS) doSetStorage(ZE_ZOMBIES_TO_SPAWN, 0) doSetStorage(ZE_ZOMBIES_SPAWNED, 0) addZombiesEventBlockEnterPosition() return true end \data\globalevents\scripts\zombie\onthink.lua
        function onThink(interval, lastExecution, thinkInterval) if(getStorage(ZE_STATUS) == 2) then setZombiesToSpawnCount(getZombiesToSpawnCount()+1) local players = getZombiesEventPlayers() for i=1, getZombiesToSpawnCount() * 2 do if(getZombiesToSpawnCount() > 0 and spawnNewZombie()) then setZombiesToSpawnCount(getZombiesToSpawnCount()-1) end end end return true end \data\lib\zombie_event.lua
        -- CONFIG ZE_DEFAULT_NUMBER_OF_PLAYERS = 20 ZE_ACCESS_TO_IGNORE_ARENA = 4 -- POSITIONS ZE_blockEnterItemPosition = {x=32341, y=32213, z=7} -- onde nasce o teleport? ZE_enterPosition = {x=32154, y=32578, z=7} -- onde os players nascem dentro da arena zombie? ZE_kickPosition = {x=32368, y=32241, z=7} -- quando morre vai para onde? ZE_spawnFromPosition = {x=32140,y=32566,z=7} -- para sumonar zombie (de) ZE_spawnToPosition = {x=32168,y=32590,z=7} -- para sumonar zombie (ate) -- ITEM IDS --ZE_blockEnterItemID = 2700 ZE_blockEnterItemID = 1387 -- STORAGES -- - player ZE_isOnZombieArea = 34370 -- - global ZE_STATUS = 34370 -- =< 0 - off, 1 - waiting for players, 2 - is running ZE_PLAYERS_NUMBER = 34371 ZE_ZOMBIES_TO_SPAWN = 34372 ZE_ZOMBIES_SPAWNED = 34373 -- FUNCTION function setZombiesEventPlayersLimit(value) doSetStorage(ZE_PLAYERS_NUMBER, value) end function getZombiesEventPlayersLimit() return getStorage(ZE_PLAYERS_NUMBER) end function addPlayerToZombiesArea(cid) doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT) doTeleportThing(cid, ZE_enterPosition, true) doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT) if(getPlayerAccess(cid) < ZE_ACCESS_TO_IGNORE_ARENA) then setPlayerZombiesEventStatus(cid, os.time()) end end function kickPlayerFromZombiesArea(cid) doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT) doTeleportThing(cid, ZE_kickPosition, true) doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT) setPlayerZombiesEventStatus(cid, 0) end function getPlayerZombiesEventStatus(cid) return getCreatureStorage(cid, ZE_isOnZombieArea) end function setPlayerZombiesEventStatus(cid, value) doCreatureSetStorage(cid, ZE_isOnZombieArea, value) end function getZombiesEventPlayers() local players = {} for i, cid in pairs(getPlayersOnline()) do if(getPlayerZombiesEventStatus(cid) > 0) then table.insert(players, cid) end end return players end function getZombiesCount() return getStorage(ZE_ZOMBIES_SPAWNED) end function addZombiesCount() doSetStorage(ZE_ZOMBIES_SPAWNED, getStorage(ZE_ZOMBIES_SPAWNED)+1) end function resetZombiesCount() doSetStorage(ZE_ZOMBIES_SPAWNED, 0) end function getZombiesToSpawnCount() return getStorage(ZE_ZOMBIES_TO_SPAWN) end function setZombiesToSpawnCount(count) doSetStorage(ZE_ZOMBIES_TO_SPAWN, count) end function addZombiesEventBlockEnterPosition() -- remove tp -- remove o TP local item = getTileItemById(ZE_blockEnterItemPosition, ZE_blockEnterItemID) if(item.uid ~= 0) then doRemoveItem(item.uid) end --doRemoveItem(getThingFromPos(Castle.desde).uid) --[[ if(getTileItemById(ZE_blockEnterItemPosition, ZE_blockEnterItemID).uid == 0) then doCreateItem(ZE_blockEnterItemID, 1, ZE_blockEnterItemPosition) end ]]-- end function removeZombiesEventBlockEnterPosition() -- add tp if(getTileItemById(ZE_blockEnterItemPosition, ZE_blockEnterItemID).uid == 0) then --doCreateItem(ZE_blockEnterItemID, 1, ZE_blockEnterItemPosition) local tp = doCreateTeleport(ZE_blockEnterItemID, ZE_enterPosition, ZE_blockEnterItemPosition) doItemSetAttribute(tp, "aid", "5555") end --[[ local item = getTileItemById(ZE_blockEnterItemPosition, ZE_blockEnterItemID) if(item.uid ~= 0) then doRemoveItem(item.uid) end ]]-- end function spawnNewZombie() local posx = {} local posy = {} local posz = {} local pir = {} for i=1, 5 do local posx_tmp = math.random(ZE_spawnFromPosition.x ,ZE_spawnToPosition.x) local posy_tmp = math.random(ZE_spawnFromPosition.y ,ZE_spawnToPosition.y) local posz_tmp = math.random(ZE_spawnFromPosition.z ,ZE_spawnToPosition.z) local pir_tmp = 0 local spec = getSpectators({x=posx_tmp, y=posy_tmp, z=posz_tmp}, 3, 3, false) if(spec and #spec > 0) then for z, pid in pairs(spec) do if(isPlayer(pid)) then pir_tmp = pir_tmp + 1 end end end posx[i] = posx_tmp posy[i] = posy_tmp posz[i] = posz_tmp pir[i] = pir_tmp end local lowest_i = 1 for i=2, 5 do if(pir[i] < pir[lowest_i]) then lowest_i = i end end local ret = doCreateMonster("Zombie Event", {x=posx[lowest_i], y=posy[lowest_i], z=posz[lowest_i]}, false) if type(ret) == "number" then addZombiesCount() setGlobalStorageValue(201201051801, ret) end return type(ret) == "number" end \data\movements\scripts\zombie\ onenter.lua
        function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor) if(not isPlayer(cid)) then return true end if(getPlayerAccess(cid) >= ZE_ACCESS_TO_IGNORE_ARENA) then addPlayerToZombiesArea(cid) elseif(#getZombiesEventPlayers() < getZombiesEventPlayersLimit() and getStorage(ZE_STATUS) == 1) then addPlayerToZombiesArea(cid) local players_on_arena_count = #getZombiesEventPlayers() if(players_on_arena_count == getZombiesEventPlayersLimit()) then addZombiesEventBlockEnterPosition() -- removeTP doSetStorage(ZE_STATUS, 2) doBroadcastMessage("Zombie Arena Event started.") else doBroadcastMessage(getCreatureName(cid) .. " has entered a Zombie Arena. We still need " .. getZombiesEventPlayersLimit() - players_on_arena_count .. " players.") end else doTeleportThing(cid, fromPosition, true) addZombiesEventBlockEnterPosition() end return true end \data\talkactions\scripts\zombie\ onsay.lua
        function onSay(cid, words, param, channel) if(getStorage(ZE_STATUS) ~= 2) then local players_on_arena_count = #getZombiesEventPlayers() if(param == 'force') then if(players_on_arena_count > 0) then setZombiesEventPlayersLimit(players_on_arena_count ) addZombiesEventBlockEnterPosition() doSetStorage(ZE_STATUS, 2) doBroadcastMessage("Zombie Arena Event started.") doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Zombies event started.") else doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Cannot start Zombies event. There is no players on arena.") end else if(param ~= '' and tonumber(param) > 0) then setZombiesEventPlayersLimit(tonumber(param)) end removeZombiesEventBlockEnterPosition() doSetStorage(ZE_STATUS, 1) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Event started.") doPlayerBroadcastMessage(cid, "Zombie Arena Event teleport is opened. We are waiting for " .. getZombiesEventPlayersLimit() - players_on_arena_count .. " players to start.") end else doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Zombies event is already running.") end return true end data\monster\zombie_event.xml
        <monster name="Zombie Event" nameDescription="an event zombie" race="undead" experience="480" speed="170" manacost="0"> <health now="20000" max="20000"/> <look type="311" corpse="9875"/> <targetchange interval="5000" chance="50"/> <strategy attack="100" defense="0"/> <flags> <flag summonable="0"/> <flag attackable="1"/> <flag hostile="1"/> <flag illusionable="0"/> <flag convinceable="0"/> <flag pushable="0"/> <flag canpushitems="1"/> <flag canpushcreatures="1"/> <flag targetdistance="1"/> <flag staticattack="90"/> <flag runonhealth="0"/> </flags> <attacks> <attack name="melee" interval="1000" min="-1500" max="-2350"/> </attacks> <defenses armor="0" defense="0"/> <immunities> <immunity paralyze="1"/> <immunity invisible="1"/> <immunity fire="1"/> <immunity energy="1"/> <immunity poison="1"/> </immunities> <voices interval="5000" chance="10"> <voice sentence="You wont last long!"/> <voice sentence="Mmmmh.. braains!"/> </voices> <script> <event name="ZombieThink"/> <event name="ZombieDeath"/> </script> <loot> </loot> </monster> Agora as Tags nos xml’s . /data/creaturescripts/creaturescripts.xml
        <event type="think" name="ZombieThink" event="script" value="zombie/onthink.lua"/> <event type="statschange" name="ZombieAttack" event="script" value="zombie/onattack.lua"/> <event type="death" name="ZombieDeath" event="script" value="zombie/ondeath.lua"/> /data/globalevents/globalevents.xml
        <globalevent name="ZombieGlobalThink" interval="5000" event="script" value="zombie/onthink.lua"/> <globalevent name="ZombieGlobalStartup" type="start" event="script" value="zombie/onstartup.lua"/> /data/movements/movements.xml
        <movevent type="StepIn" actionid="5555" event="script" value="zombie/onenter.lua"/> /data/talkactions/talkactions.xml
        <talkaction log="yes" words="/zombiestart" access="4" event="script" value="zombie/onsay.lua"/> /data/monster/monsters.xml
        <monster name="Zombie Event" file="zombie_event.xml"/> Script Terminado ! Next: Tutorial de como configurar o zombie event ! Estarei postando apenas as partes q podem ou devem ser editadas em cada script. data\creaturescripts\scripts\zombiez\onattack.lua
      Next: \data\lib\zombie_event.lua
      Então galera eh isso ai .-. meu primeiro post não mim crucifiquem k Duvidas, reclamações elogios chigamentos u.u só comentar como dizia o mestre o topico ta explicado nos minimos detalhes e ''de forma bem entendida'' (entendedoresentenderam) então eh isso vlw ai a todos q mim ajudaram nisso e nem sabem 😄
  • Recently Browsing   0 members

    No registered users viewing this page.


×
×
  • Create New...