• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Problem With Raids Automatic (MOD)

TibiaGameHost

Hello!
Joined
Feb 25, 2009
Messages
255
Reaction score
0
Location
Canadá
Not respecting the amount of monsters to be summoned.
m = 2 morgaroth is to summon 2 morgaroth is summoning more than that, like 100 for example.

What's the problem?

Code:
<?xml version="1.0" encoding="UTF-8"?>  
<mod name="Automatic Raids" version="1.0" author="Igor Pereira" contact="[email protected]" enabled="yes">  
<config name="raids_func"><![CDATA[
days = {
["Monday"] = {
["08:00"] = {nome = "Rat", pos = {fromPosition = {x=32331, y=32189, z=7},toPosition = {x=32425, y=32255, z=7}},m = {"100 Cave Rat", "100 Rat"}, Time = 30},
["19:00"] = {nome = "Demon", pos = {fromPosition = {x=32331, y=32189, z=7},toPosition = {x=32425, y=32255, z=7}},m = {"20 Demon"}, Time = 30},
["16:00"] = {nome = "Ghazbaran", pos = {fromPosition = {x=32331, y=32189, z=7},toPosition = {x=32425, y=32255, z=7}},m = {"2 Ghazbaran"}, Time = 30}
},
["Tuesday"] = {
["10:00"] = {nome = "Elf", pos = {fromPosition = {x=32331, y=32189, z=7},toPosition = {x=32425, y=32255, z=7}},m = {"100 Elf Scout", "100 Elf"}, Time = 30},
["18:00"] = {nome = "Dragon", pos = {fromPosition = {x=32331, y=32189, z=7},toPosition = {x=32425, y=32255, z=7}},m = {"100 Dragon"}, Time = 30},
["20:00"] = {nome = "Zulazza the Corruptor", pos = {fromPosition = {x=32331, y=32189, z=7},toPosition = {x=32425, y=32255, z=7}},m = {"20 Zulazza the Corruptor"}, Time = 30}
},
["Wednesday"] = {
["08:00"] = {nome = "Nomad", pos = {fromPosition = {x=32331, y=32189, z=7},toPosition = {x=32425, y=32255, z=7}},m = {"20 Hunter", "100 Nomad"}, Time = 30},
["19:00"] = {nome = "The Old Widow", pos = {fromPosition = {x=32331, y=32189, z=7},toPosition = {x=32425, y=32255, z=7}},m = {"100 The Old Widow"}, Time = 30}
},
["Thursday"] = {
["10:00"] = {nome = "Barbarian Bloodwalker", pos = {fromPosition = {x=32331, y=32189, z=7},toPosition = {x=32425, y=32255, z=7}},m = {"20 Barbarian Brutetamer", "100 Barbarian Bloodwalker"}, Time = 30},
["20:00"] = {nome = "Necropharus", pos = {fromPosition = {x=32331, y=32189, z=7},toPosition = {x=32425, y=32255, z=7}},m = {"100 Necropharus"}, Time = 30}
},
["Friday"] = {
["04:00"] = {nome = "Quara Hydromancer", pos = {fromPosition = {x=32331, y=32189, z=7},toPosition = {x=32425, y=32255, z=7}},m = {"20 Quara Mantassin", "100 Quara Hydromancer"}, Time = 30},
["23:11"] = {nome = "Morgaroth", pos = {fromPosition = {x=32331, y=32189, z=7},toPosition = {x=32425, y=32255, z=7}},m = {"2 Morgaroth"}, Time = 30},
["23:43"] = {nome = "Hydra", pos = {fromPosition = {x=32331, y=32189, z=7},toPosition = {x=32425, y=32255, z=7}},m = {"2 Hydra"}, Time = 30}
},
["Saturday"] = {
["04:00"] = {nome = "Pirate Buccaneer", pos = {fromPosition = {x=32331, y=32189, z=7},toPosition = {x=32425, y=32255, z=7}},m = {"20 Pirate Corsair", "100 Pirate Buccaneer"}, Time = 30},
["22:00"] = {nome = "Ferumbras", pos = {fromPosition = {x=32331, y=32189, z=7},toPosition = {x=32425, y=32255, z=7}},m = {"5 Ferumbras"}, Time = 30}
},
["Sunday"] = {
["15:00"] = {nome = "Demodras", pos = {fromPosition = {x=32331, y=32189, z=7},toPosition = {x=32425, y=32255, z=7}},m = {"100 Demodras"}, Time = 30},
["08:00"] = {nome = "The Horned Fox", pos = {fromPosition = {x=32331, y=32189, z=7},toPosition = {x=32425, y=32255, z=7}},m = {"100 The Horned Fox"}, Time = 30},
["18:00"] = {nome = "Orshabaal", pos = {fromPosition = {x=32331, y=32189, z=7},toPosition = {x=32425, y=32255, z=7}},m = {"3 Orshabaal"}, Time = 30}
}
}
]]></config>    
<globalevent name="AutomaticRaids" interval="60" event="script"><![CDATA[
domodlib('raids_func')
function onThink(interval, lastExecution)  
if days[os.date("%A")] then
hours = tostring(os.date("%X")):sub(1, 5)       
tb = days[os.date("%A")][hours] 
if tb then        
function removeCreature(tb)
for x = ((tb.pos.fromPosition.x)-10), ((tb.pos.toPosition.x)+10) do
for y = ((tb.pos.fromPosition.y)-10), ((tb.pos.toPosition.y)+10) do
localm = getTopCreature({x=x, y=y, z= tb.pos.fromPosition.z}).uid
if m ~= 0 and isMonster(m) then
doRemoveCreature(m)
end
end
end
end
doBroadcastMessage("The invasion of " .. tb.nome .. " started")
for _,x in pairs(tb.m) do
for s = 1, tonumber(x:match("%d+")) do
pos = {x = math.random(tb.pos.fromPosition.x, tb.pos.toPosition.x), y = math.random(tb.pos.fromPosition.y, tb.pos.toPosition.y), z = tb.pos.fromPosition.z}
doSummonCreature(x:match("%s(.+)"), pos)
end
end
addEvent(removeCreature, tb.Time*60*1000, tb)
end
end
return true
end
]]></globalevent>
</mod>
 
try this one
its a globalevent script

globalevents.xml
Code:
<globalevent name="raids" interval="60000" event="script" value="raid.lua"/>

raid.lua
Code:
--[[
- hour should be exact SERVER hour
- to do the raid at clock 00 minutes 00
- to do the raid at exaxt date use type "exact"
- to do the raid weekly use type "weekly"
- days names are used only for weekly type and should be 
- "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"
- also should be inside a array -> {}
]]

local raids =
	{
		[1] = 
			{
				name = 'Morgaroth',
				type = 'exact',
				date = {day = 15, month = 08},
				hour = 16,
				minu = 27
			},
		[2] = 
			{
				name = 'Zulazza the Corruptor',
				type = 'weekly',
				days = {'monday'},
				hour = 20,
				minu = 00
			},
		[3] = 
			{
				name = 'RatsThais',
				type = 'exact',
				date = {day = 31, month = 07},
				hour = 03,
				minu = 00
			},
		[4] = 
			{
				name = 'OrcsThais',
				type = 'exact',
				date = {day = 03, month = 08},
				hour = 17,
				minu = 00
			},
		[5] = 
			{
				name = 'Barbarian',
				type = 'exact',
				date = {day = 05, month = 08},
				hour = 18,
				minu = 00
			},
		[6] = 
			{
				name = 'Demodras',
				type = 'exact',
				date = {day = 07, month = 08},
				hour = 19,
				minu = 00
			},
		[7] = 
			{
				name = 'Elfos',
				type = 'exact',
				date = {day = 09, month = 08},
				hour = 20,
				minu = 00
			},
		[8] = 
			{
				name = 'Ferumbras',
				type = 'exact',
				date = {day = 11, month = 08},
				hour = 21,
				minu = 00
			},
		[9] = 
			{
				name = 'Ghazbaran',
				type = 'exact',
				date = {day = 13, month = 08},
				hour = 22,
				minu = 00
			},
		[10] = 
			{
				name = 'Horned Fox',
				type = 'exact',
				date = {day = 17, month = 08},
				hour = 23,
				minu = 00
			},
		[11] = 
			{
				name = 'Necropharus',
				type = 'exact',
				date = {day = 19, month = 08},
				hour = 00,
				minu = 00
			},
		[12] = 
			{
				name = 'Nomads',
				type = 'exact',
				date = {day = 21, month = 08},
				hour = 01,
				minu = 00
			},
		[13] = 
			{
				name = 'Orshabaal',
				type = 'exact',
				date = {day = 23, month = 08},
				hour = 14,
				minu = 00
			},
		[14] = 
			{
				name = 'Pirates',
				type = 'exact',
				date = {day = 25, month = 08},
				hour = 15,
				minu = 00
			},
		[15] = 
			{
				name = 'Quaras',
				type = 'exact',
				date = {day = 27, month = 08},
				hour = 16,
				minu = 00
			},
		[16] = 
			{
				name = 'Scarabs',
				type = 'exact',
				date = {day = 29, month = 08},
				hour = 17,
				minu = 00
			},
		[17] = 
			{
				name = 'Old Widow',
				type = 'exact',
				date = {day = 31, month = 08},
				hour = 18,
				minu = 00
			},
		[18] = 
			{
				name = 'Undead Army',
				type = 'exact',
				date = {day = 02, month = 09},
				hour = 19,
				minu = 00
			},
		[19] = 
			{
				name = 'Undead Darashia',
				type = 'exact',
				date = {day = 04, month = 09},
				hour = 20,
				minu = 00
			},
		[20] = 
			{
				name = 'Sir Valorcrest',
				type = 'weekly',
				days = {'monday'},
				hour = 20,
				minu = 00
			},
		[21] = 
			{
				name = 'Zevelong Duskbringer',
				type = 'weekly',
				days = {'tuesday'},
				hour = 20,
				minu = 00
			},
		[22] = 
			{
				name = 'Diblis The Fair',
				type = 'weekly',
				days = {'thursday'},
				hour = 20,
				minu = 00
			},
		[23] = 
			{
				name = 'Arachir the Ancient One',
				type = 'weekly',
				days = {'saturday'},
				hour = 20,
				minu = 00
			},
		[24] = 
			{
				name = 'Halloween Hare',
				type = 'exact',
				date = {day = 31, month = 10},
				hour = 16,
				minu = 00
			}	
	}
	
local last_execsutes = {}

function onThink(interval, lastExecution, thinkInterval)
	local static_time = os.time()
	for k, raid in ipairs(raids) do
		if (raid.type == 'weekly') then
			local day = os.date("%A", static_time):lower()
			if isInArray(raid.days, day) then
				local hour = tonumber(os.date("%H", static_time))
				if (raid.hour == hour) then
					local minute = tonumber(os.date("%M", static_time))
					if (raid.minu == minute) then
						local day_number = tonumber(os.date("%d", static_time))
						if (last_execsutes[k] ~= day_number) then
							last_execsutes[k] = day_number
							doExecuteRaid(raid.name)
						end
					end
				end
			end
		elseif (raid.type == 'exact') then
			local month = tonumber(os.date("%m", static_time))
			if (raid.date.month == month) then
				local day = tonumber(os.date("%d", static_time))
				if (raid.date.day == day) then
					local hour = tonumber(os.date("%H", static_time))
					if (raid.hour == hour) then
						local minute = tonumber(os.date("%M", static_time))
						if (raid.minu == minute) then
							if (last_execsutes[k] ~= day) then
								last_execsutes[k] = day
								doExecuteRaid(raid.name)
							end
						end
					end
				end
			end
		end
	end
	return true
end
 
No. I do not want this. This I already have.
I want my, I set everything in one script only.
This your script need to configure in your raids, do not want it.
My only script is not working the amount of monsters.
Someone can fix it?
 
Back
Top