• 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!

Castle System - Giving errors

Pnurt

New Member
Joined
Apr 22, 2009
Messages
205
Reaction score
0
Hey guys, I've run into some troubles when using the castle mod from otsmateria datapack.

I'm running 0.3.7, 9.81

This is what I get after the event has been started (by !startcastle) then 2 guilds have joined the event, waiting for it to start.
Code:
[23:52:09.586] [Error - TalkAction Interface]
[23:52:09.587] In a timer event called from:
[23:52:09.589]                  domodlib('castle_config')
[23:52:09.590]                  domodlib('castle_lib')

[23:52:09.591]                  function onSay(cid, words, param)
[23:52:09.593]                          if getStorage(castleCfg.storage.event) ~
= 1 then
[23:52:09.595]                                  doSetStorage(castleCfg.storage.e
vent, 1)
[23:52:09.599]                                  doCleanCastleFighters()
[23:52:09.600]
[23:52:09.600]                                  addEvent(castleOpen, castleCfg.t
imeToStartJoinToCastleWar * 60 * 1000)
[23:52:09.603]                                  doBroadcastMessage('[CASTLE WAR]
\n\nCastle war will start in ' .. castleCfg.timeToStartJoinToCastleWar .. ' mins
.', MESSAGE_EVENT_ADVANCE)

[23:52:09.608]                                  for _, pid in ipairs(getPlayersO
nline()) do
[23:52:09.610]                                          if getCreatureStorage(pi
d, castleCfg.storage.winner) > 0 then
[23:52:09.613]                                                  doCreatureSetSto
rage(pid, castleCfg.storage.winner, -1)
[23:52:09.615]                                                  doTeleportThing(
pid, getTownTemplePosition(getPlayerTown(pid)), true)
[23:52:09.618]                                          end
[23:52:09.619]                                  end
[23:52:09.620]                          else
[23:52:09.620]                                  doPlayerSendCancel(cid, 'You can
 not do it if "castle war" is enabled yet.')
[23:52:09.623]                          end
[23:52:09.624]                          return true
[23:52:09.624]                  end
[23:52:09.625]          :onSay
[23:52:09.626] Description:
[23:52:09.627] (LuaInterface::luaDoCreateMonster) Monster with name '' not found

Here is my castle.xml
Code:
<?xml version='1.0' encoding='UTF-8'?>
<mod name='Castle War' version='1.1' author='VirrageS' contact='otland.net' enabled='yes'>
	<config name='castle_config'>
		<![CDATA[
			castleCfg = {
				-- STORAGES --
				storage = {
					-- player --
					playersEvent = 456378, -- wolne storage
					attackers = 456836, -- wolne storage
					winner = 976553, -- wolne storage
					exhaust = 5665254, -- wolne storage
					group = 216845,

					-- event --
					event = 457866, -- wlone storage
					joinEvent = 435773, -- wolne storage
					time = 782346 -- wolne storage
				},

				-- CZASY --
				exhaustTime = 8, -- co ile mozna uzywac !castleback [minuty]
				timeToStartJoinToCastleWar = 1.0, -- od broadcasta do czasu w ktorym mozna zapisywac guildie
				timeToStartCastleWar = 1.0, -- od kiedy mozna sie zapisywac do startu calego wara
				timeToCloseWar = 30, -- w miutach (czas od rozpoczecia castle waru (kiedy znikna bramy) do zakonczyenia (jezeli nikt wczeniej nie przejmie))

				-- OGOLNE --
				minLevel = 100,
				minMembers = {p = 200, first = 1, second = 10}, 
				-- p = minimum amount of players online needed; 
				-- first (amount of gmembers needed online if < p); second (amount of gmembers needed online if > p);

				guildsMinMax = {min = 2, max = 8},
				days = {['Monday'] = {'17:59:00'},
					['Wednesday'] = {'17:59:00'},
					['Saturday'] = {'14:59:00'}
				},

				-- POZYCJE --
				kingPos = {x = 533, y = 538, z = 4},

				gates = {
					{pos = {x = 516, y = 549, z = 7}},
					{pos = {x = 545, y = 561, z = 7}},
					{pos = {x = 515, y = 563, z = 7}},
					{pos = {x = 517, y = 536, z = 7}},
					{pos = {x = 562, y = 551, z = 6}},
					{pos = {x = 540, y = 547, z = 6}},
					{pos = {x = 528, y = 529, z = 7}},
					{pos = {x = 550, y = 534, z = 7}}
				},
				
				telePositions = {
					{x = 504, y = 553, z = 7},
					{x = 1582, y = 1113, z = 6},
					{x = 1593, y = 1106, z = 6},
					{x = 1615, y = 1111, z = 6},
					{x = 1609, y = 1125, z = 6},
					{x = 1616, y = 1150, z = 6},
					{x = 1580, y = 1151, z = 6},
					{x = 1634, y = 1134, z = 5}
				},

				-- REWARD --
				castleGetReward = true, -- true lub false
				levelToGetReward = 100,
				itemsToGive = {
					2644, -- king
					9778, -- yalaha mask
					8865, -- dark lords cape
					8890, -- robe of the underworld
					3983, -- bast skirt
					9933, -- firewalker boots
					7735, -- star wand
					2640, -- softy
					9693, -- addon
					8306, -- remover
					2506, -- dragon scale helmet
					8888, -- master archers armor
					9777, -- yalahari leg piece
					8850, -- chain bolter
					6433, -- necromancer shield
					8903, -- spellbook of lost souls
					2496, -- horned helmet
					9776, -- yalahari armor
					2469, -- dragon scale legs
					6391, -- nightmare shield
					8925, -- solar
					7422, -- jade hammer
					2390, -- mls
					7722, -- stamina
					11302, -- zao helmet
					11301, -- zao armor
					11304, -- zao legs
					8300, -- upgrade
					8266, -- koshei
					2349  -- 100pkt
				},
				cash = { -- W CC
					min = 10,
					max = 100
				}
			}
		]]>
	</config>

	<lib name='castle_lib'>
		<![CDATA[
			domodlib('castle_config')

			_G.gates = {}

			function getCastleGuildName(guildId)
				q = db.getResult("SELECT `name` FROM `guilds` WHERE `id` = " .. guildId .. " LIMIT 1")
				local pol = q:getDataString("name")
				q:free()
				return pol
			end

			---- FIGHTERS ---
			function doCleanCastleFighters()
				db.executeQuery("DELETE FROM `castle_fighters`")
			end

			function doAddCastleFighter(id, guild)
				db.executeQuery("INSERT INTO `castle_fighters` (`id`, `guild`) VALUES (".. id ..", ".. guild ..")")
			end
			
			function isGuildInCastle(guild)
				local res = -1
				tmp = db.getResult("SELECT `id` FROM `castle_fighters` WHERE `guild` = ".. guild .."")
				if tmp:getID() ~= -1 then
					res = tmp:getDataInt("id")
					tmp:free()
				end
				return res
			end
			
			function getCastleFightingGuilds()
				local res = ''
				tmp = db.getResult("SELECT COUNT(*) as `count` FROM `castle_fighters` WHERE `id` > -1")
				if tmp:getID() ~= -1 then
					res = tmp:getDataInt("count")
					tmp:free()
				end
				return res
			end
			---- FIGHTERS ----
			
			function getCastleGuildMembers(guid, bool)
				local mem  = {}
				for _, cid in ipairs(getPlayersOnline()) do
					if getPlayerGuildId(cid) == guid then
						if getTileInfo(getThingPos(cid)).protection == true or bool then
							table.insert(mem, cid)
						end
					end
				end
				return mem
			end

			function secondsToClock(sSeconds)
				local nSeconds = tonumber(sSeconds)
				if nSeconds == 0 then
					return "00:00:00"
				else
					local nHours = string.format("%02.f", math.floor(nSeconds / 3600))
					local nMins = string.format("%02.f", math.floor(nSeconds / 60 - (nHours * 60)))
					local nSecs = string.format("%02.f", math.floor(nSeconds - nHours * 3600 - nMins * 60))

					return nHours..":"..nMins..":"..nSecs
				end
			end

			function getCastleOwner()
				local res, guildName = '', ''

				tmp = db.getResult("SELECT `guild_name` FROM `castle` WHERE `owner` > 0")
				if tmp:getID() ~= -1 then
					guildName = guildName .. tmp:getDataString("guild_name")
					if guildName == 'No one' then
						tmp:free()
					else
						res = guildName
					end
				end
				return res
			end

			function getCastleWarId()
				tmp = db.getResult("SELECT `id` FROM `castle` ORDER BY `id` DESC LIMIT 1")
				local res = tmp:getDataInt("id")
				tmp:free()
				return res
			end

			function doSetCastleOwner(guildId)
				db.executeQuery("INSERT INTO `castle` (`id`, `owner`, `guild_name`)	VALUES ('NULL', '1', '" .. tostring(getCastleGuildName(guildId)) .. "');")
			end




			--- KING ---
			function doSetCastleKing(king)
				db.executeQuery("UPDATE `castle` SET `king` = " .. king .. " WHERE `id` = " .. getCastleWarId() .. ";")
			end

			function getCastleKing()
				tmp = db.getResult("SELECT `king` FROM `castle` ORDER BY `id` DESC LIMIT 1")
				local res = tmp:getDataInt("king")
				tmp:free()
				return res
			end
			--- END KING ---



			--- DMG ---
			function doSetCastleDmg0(guildId)
				db.executeQuery("INSERT INTO `castle_dmg` (`guild`, `dmg`) VALUES ('" .. guildId .. "', '0');")
			end

			function doCleanCastleDmg()
				db.executeQuery("DELETE FROM `castle_dmg` WHERE `dmg` > -1;")
			end

			function doSetCastleDmg(value, guildId)
				db.executeQuery("UPDATE `castle_dmg` SET `dmg` = `dmg` + " .. value .. " WHERE `guild` = " .. guildId .. "")
				return true
			end

			function getCastleWinner()
				tmp = db.getResult("SELECT `guild` FROM `castle_dmg` ORDER BY `dmg` DESC LIMIT 1")
				local res = tmp:getDataInt("guild")
				tmp:free()
				return res
			end
			--- END DMG ---



			--- EVENT ---
			function castleOpen()
				doSetStorage(castleCfg.storage.joinEvent, 1)
				doBroadcastMessage('[CASTLE WAR]\n\nPrepare for battle! If you are guild leader with level higher than ' .. castleCfg.minLevel .. ' you can join the war saying "!castle"', MESSAGE_EVENT_ADVANCE)
				addEvent(doStartCastleWar, castleCfg.timeToStartCastleWar * 1000 * 60)

				for i = 1, #castleCfg.gates do
					if isCreature(getCreatureByName('Gate')) then
						doRemoveCreature(getCreatureByName('Gate'))
					end
				end

				for i = 1, #castleCfg.gates do
					_G.gates[i] = doCreateMonster('Gate', castleCfg.gates[i].pos, false, false, false)
				end
				
				doCleanCastleFighters()
			end

			function doStartCastleWar()
				for _, pid in ipairs(getPlayersOnline()) do
					if getCreatureStorage(pid, castleCfg.storage.playersEvent) == 1 then
						doCreatureSetNoMove(pid, false)
						doRemoveCondition(pid, CONDITION_INFIGHT)
					end
				end

				if getCastleFightingGuilds() >= castleCfg.guildsMinMax.min then
					kingId = doCreateMonster('King', castleCfg.kingPos)
					doSetCastleKing(kingId)

					doBroadcastMessage('[CASTLE WAR]\n\nGates are opened! Kill the king or die trying!', MESSAGE_EVENT_ADVANCE)
					doSetStorage(castleCfg.storage.time, os.time() + castleCfg.timeToCloseWar * 60)

					db.executeQuery("UPDATE `castle` SET `owner` = 0 WHERE `owner` > 0")
				else
					doBroadcastMessage('[CASTLE WAR]\n\nWar failed, not enough guilds joined to fight!', MESSAGE_EVENT_ADVANCE)

					for _, pid in ipairs(getPlayersOnline()) do
						if getCreatureStorage(pid, castleCfg.storage.playersEvent) == 1 then
							doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)), true)
							doCreatureSetStorage(pid, castleCfg.storage.playersEvent, -1)
						end
					end

					db.executeQuery("INSERT INTO `castle` (`id`, `owner`, `guild_name`)	VALUES ('NULL', '0', 'No one');")
					
					doCleanCastleFighters()
					doCleanCastleDmg()
					doSetStorage(castleCfg.storage.event, -1)
				end

				doSetStorage(castleCfg.storage.joinEvent, -1)
			end

			function doCloseCastleWar(bool)				
				if getStorage(castleCfg.storage.event) == 1 then

					if isCreature(getCastleKing()) then
						doRemoveCreature(getCastleKing())
					end

					doBroadcastMessage('[CASTLE WAR]\n\nWar ended! The new leader is: ' .. getCastleGuildName(getCastleWinner()) .. '. Congratulations!', MESSAGE_INFO_DESCR)
					doSetCastleOwner(getCastleWinner())

					for _, winners in ipairs(getPlayersOnline()) do
						if getPlayerGuildId(winners) == getCastleWinner() then
							doCreatureSetStorage(winners, castleCfg.storage.winner, 1)
						end
					end

					doCleanCastleDmg()
					doSetStorage(castleCfg.storage.event, -1)
					doSetStorage(castleCfg.storage.time, 0)

					for i = 1, #castleCfg.gates do
						if isCreature(getCreatureByName('Gate')) then
							doRemoveCreature(getCreatureByName('Gate'))
						end
					end
					
					for _, all in ipairs(getPlayersOnline()) do
						if getCreatureStorage(all, castleCfg.storage.playersEvent) == 1 then
							doCreatureSetStorage(all, castleCfg.storage.playersEvent, -1)
							doRemoveConditions(all)
							doTeleportThing(all, getTownTemplePosition(getPlayerTown(all)), true)
						end
					end

					for i = 1, #castleCfg.gates do
						_G.gates[i] = doCreateMonster('Gate', castleCfg.gates[i].pos, false, false, false)
					end
					
					doCleanCastleFighters()
					doSaveServer()
				end
			end
		]]>
	</lib>

	<talkaction words='!castleback' event='script'>
		<![CDATA[
			domodlib('castle_config')
			domodlib('castle_lib')

			function onSay(cid, words, param)
				if exhaustion.check(cid, castleCfg.storage.exhaust) ~= false then
					return doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'You must to wait a ' .. exhaustion.get(cid, castleCfg.storage.exhaust) .. ' sec.')
				end

				if getPlayerGuildId(cid) < 1 then
					return doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'You do not have a guild!')
				end
				
				if getTileInfo(getThingPos(cid)).protection ~= true then
					return doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'You can not back to castle war if are not in protection zone.')
				end

				if getStorage(castleCfg.storage.event) == 1 then					
					if isGuildInCastle(getPlayerGuildId(cid)) ~= -1 then
						local randX, randY, pos = math.random(-1,1), math.random(-1,1), castleCfg.telePositions[isGuildInCastle(getPlayerGuildId(cid))]
						
						doTeleportThing(cid, {x = pos.x + randX, y = pos.y + randY, z = pos.z})							
						doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)

						doCreatureSetStorage(cid, castleCfg.storage.playersEvent, 1)
						
						exhaustion.set(cid, castleCfg.storage.exhaust, castleCfg.exhaustTime * 60)
					else
						doPlayerSendCancel(cid, 'Your guild is not in castle war!')
					end
				else
					doPlayerSendCancel(cid, 'You can not do it right now!')
				end
				return true
			end
		]]>
	</talkaction>

	<talkaction words='!castle' event='script'>
		<![CDATA[
			domodlib('castle_config')
			domodlib('castle_lib')

			function onSay(cid, words, param)
				if param == 'info' then
					if getStorage(castleCfg.storage.event) == 1 and getStorage(castleCfg.storage.joinEvent) == -1 and getStorage(castleCfg.storage.time) > 0 then
						doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, '[CASTLE WAR]\n\nCastle war will end in ' .. math.floor(os.difftime(getStorage(castleCfg.storage.time), os.time()) / 60) .. ' mins.')
					else
						doPlayerSendCancel(cid, 'You can not do it right now!')
					end
					return true
				elseif param == 'back' then
					if exhaustion.check(cid, castleCfg.storage.exhaust) ~= false then
						return doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'You must to wait a ' .. exhaustion.get(cid, castleCfg.storage.exhaust) .. ' sec.')
					end

					if getPlayerGuildId(cid) < 1 then
						return doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'You do not have a guild!')
					end
					
					if getTileInfo(getThingPos(cid)).protection ~= true then
						return doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'You can not back to castle war if are not in protection zone.')
					end

					if getStorage(castleCfg.storage.event) == 1 then					
						if isGuildInCastle(getPlayerGuildId(cid)) ~= -1 then
							local randX, randY, pos = math.random(-1,1), math.random(-1,1), castleCfg.telePositions[isGuildInCastle(getPlayerGuildId(cid))]
							
							doTeleportThing(cid, {x = pos.x + randX, y = pos.y + randY, z = pos.z})							
							doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)

							doCreatureSetStorage(cid, castleCfg.storage.playersEvent, 1)
							
							exhaustion.set(cid, castleCfg.storage.exhaust, castleCfg.exhaustTime * 60)
						else
							doPlayerSendCancel(cid, 'Your guild is not in castle war!')
						end
					else
						doPlayerSendCancel(cid, 'You can not do it right now!')
					end
					return true
				end
				
				if getStorage(castleCfg.storage.joinEvent) == 1 then
					if castleCfg.guildsMinMax.max > getCastleFightingGuilds() then
						if getPlayerGuildId(cid) < 1 then
							return doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'You do not have a guild!')
						end

						if getPlayerLevel(cid) < castleCfg.minLevel then
							return doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'You can not sing up your guild to castle war if you do not have a require level. [' .. castleCfg.minLevel .. ']')
						end

						if getTileInfo(getThingPos(cid)).protection ~= true then
							return doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'You can not sing up your guild to castle war if are not in protection zone.')
						end

						if isGuildInCastle(getPlayerGuildId(cid)) ~= -1 then
							return doPlayerSendCancel(cid, 'You can not use this talkactions 2 times!')
						end

						if getPlayerGuildLevel(cid) >= GUILDLEVEL_LEADER then
							local guildMembers = getCastleGuildMembers(getPlayerGuildId(cid), false)
							if castleCfg.minMembers.p >= #getPlayersOnline() then
								if #guildMembers < castleCfg.minMembers.first then
									return doPlayerSendCancel(cid, 'You don\'t have a '..castleCfg.minMembers.first..' guild members online or someone isn\'t standing in protection zone!')
								end
							else
								if #guildMembers < castleCfg.minMembers.second then
									return doPlayerSendCancel(cid, 'You don\'t have a '..castleCfg.minMembers.second..' guild members online or someone isn\'t standing in protection zone!')
								end
							end
							
							doAddCastleFighter(math.max(0, getCastleFightingGuilds()) + 1, getPlayerGuildId(cid))							
							doSetCastleDmg0(getPlayerGuildId(cid))

							for _, pid in ipairs(guildMembers) do
								local randX, randY, pos = math.random(-1,1), math.random(-1,1), castleCfg.telePositions[getCastleFightingGuilds()]
									
								doTeleportThing(pid, {x = pos.x + randX, y = pos.y + randY, z = pos.z})
								doCreatureSetNoMove(pid, true)
								doAddCondition(pid, createConditionObject(CONDITION_INFIGHT, -1))

								doCreatureSetStorage(pid, castleCfg.storage.playersEvent, 1)
							end

							doBroadcastMessage('[CASTLE WAR]\n\nGuild "' .. getPlayerGuildName(cid) .. '" have joined the battle for castle!\nGuilds fighting: ' .. getCastleFightingGuilds() .. '/' .. castleCfg.guildsMinMax.max .. '.', MESSAGE_INFO_DESCR)
						else
							doPlayerSendCancel(cid, 'You must be the leader of your guild!')
						end
					else
						doPlayerSendCancel(cid, 'Max guilds in war has been reached!')
					end
				else
					doPlayerSendCancel(cid, 'It is not time yet!')
				end
				return true
			end
		]]>
	</talkaction>

	<talkaction words='!startcastle' access='5' event='script'>
		<![CDATA[
			domodlib('castle_config')
			domodlib('castle_lib')

			function onSay(cid, words, param)
				if getStorage(castleCfg.storage.event) ~= 1 then
					doSetStorage(castleCfg.storage.event, 1)
					doCleanCastleFighters()
					
					addEvent(castleOpen, castleCfg.timeToStartJoinToCastleWar * 60 * 1000)
					doBroadcastMessage('[CASTLE WAR]\n\nCastle war will start in ' .. castleCfg.timeToStartJoinToCastleWar .. ' mins.', MESSAGE_EVENT_ADVANCE)

					for _, pid in ipairs(getPlayersOnline()) do
						if getCreatureStorage(pid, castleCfg.storage.winner) > 0 then
							doCreatureSetStorage(pid, castleCfg.storage.winner, -1)
							doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)), true)
						end
					end
				else
					doPlayerSendCancel(cid, 'You can not do it if "castle war" is enabled yet.')
				end
				return true
			end
		]]>
	</talkaction>
	
	<talkaction words='!castleowner' access='5' event='script'>
		<![CDATA[
			domodlib('castle_config')
			domodlib('castle_lib')

			function onSay(cid, words, param)
				if getGuildId(param) then
					db.executeQuery("UPDATE `castle` SET `owner` = 0 WHERE `owner` > 0")
					doSetCastleOwner(getGuildId(param))
				else
					doPlayerSendCancel(cid, 'Wrong name. Can not find guild.')
				end
				return true
			end
		]]>
	</talkaction>

	<globalevent name="castleWarStart" interval="1000" event="script">
		<![CDATA[
			domodlib('castle_config')
			domodlib('castle_lib')

			local daysOpen = {}

			for k, v in pairs(castleCfg.days) do
				table.insert(daysOpen, k)
			end

			function onThink(interval)
				if isInArray(daysOpen, os.date('%A')) then
					if isInArray(castleCfg.days[os.date('%A')], os.date('%X', os.time())) then
						if getStorage(castleCfg.storage.event) ~= 1 then
							doCleanCastleFighters()
							doSetStorage(castleCfg.storage.event, 1)
						
							addEvent(castleOpen, castleCfg.timeToStartJoinToCastleWar * 60 * 1000)
							doBroadcastMessage('[CASTLE WAR]\n\nCastle war will start in ' .. castleCfg.timeToStartJoinToCastleWar .. ' mins.', MESSAGE_EVENT_ADVANCE)

							for _, pid in ipairs(getPlayersOnline()) do
								if getCreatureStorage(pid, castleCfg.storage.winner) > 0 then
									doCreatureSetStorage(pid, castleCfg.storage.winner, -1)
									doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)), true)
								end
							end
						end
					end
				end
				
				if getStorage(castleCfg.storage.event) == 1 then
					if getStorage(castleCfg.storage.time) == os.time() then
						doCloseCastleWar()
					end
				end
				return true
			end
		]]>
	</globalevent>
	
	<globalevent name="castleWarBroadcast" interval="300000" event="script">
		<![CDATA[
			domodlib('castle_config')

			function onThink(interval)
				if getStorage(castleCfg.storage.event) == 1 then
					doBroadcastMessage('If you want to back to castle type "!castleback", if you want to check time to end castle war type "!castleinfo". Map Clean every 5 minutes!', MESSAGE_INFO_DESCR)
					doCleanMap()
				end
				return true
			end
		]]>
	</globalevent>

	<event type='death' name='castleDeathKing' event='script'>
		<![CDATA[
			domodlib('castle_lib')

			function onDeath(cid, corpse, deathList)
				if isMonster(cid) then
					if getCreatureName(cid) == 'King' then
						doCloseCastleWar()
					end
				end
				return true
			end
		]]>
	</event>

	<event type='death' name='castleDeathPlayer' event='script'>
		<![CDATA[
			domodlib('castle_config')

			function onDeath(cid, corpse, deathList)
				if getCreatureStorage(cid, castleCfg.storage.playersEvent) == 1 then
					doCreatureSetStorage(cid, castleCfg.storage.playersEvent, -1)
				end
				return true
			end
		]]>
	</event>

	<event type='login' name='castleLogin' event='script'>
		<![CDATA[
			domodlib('castle_config')
			domodlib('castle_lib')

			function onLogin(cid)
				if getStorage(castleCfg.storage.event) == 1 then
					if getCreatureStorage(cid, castleCfg.storage.winner) > 0 then
						doCreatureSetStorage(cid, castleCfg.storage.winner, -1)
						doCreatureSetStorage(cid, castleCfg.storage.playersEvent, -1)
						doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), true)
					end
				else
					if getCastleOwner() ~= '' then
						if getPlayerGuildName(cid) == getCastleOwner() then
							doCreatureSetStorage(cid, castleCfg.storage.winner, 1)
							doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, 'Your guild won a Castle War.')
						end
						
						if getCreatureStorage(cid, castleCfg.storage.winner) > 0 then
							if getPlayerGuildName(cid) ~= getCastleOwner() then
								doCreatureSetStorage(cid, castleCfg.storage.winner, -1)
							end
						end
					end
					
					if getCreatureStorage(cid, castleCfg.storage.playersEvent) == 1 then
						doCreatureSetStorage(cid, castleCfg.storage.playersEvent, -1)
						doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), true)
					end
				end

				registerCreatureEvent(cid, 'castleDeathPlayer')
				return true
			end
		]]>
	</event>

	<event type='statschange' name='castleDmgKing' event='script'>
		<![CDATA[
			domodlib('castle_config')
			domodlib('castle_lib')

			function onStatsChange(cid, attacker, type, combat, value)
				if isMonster(cid) and isPlayer(attacker) then
					if getCreatureName(cid) == 'King' then
						if value > 0 then
							doSetCastleDmg(value, getPlayerGuildId(attacker))
						end
					end
				end
				return true
			end
		]]>
	</event>

	<action actionid='4992' event='script'>
		<![CDATA[
			domodlib('castle_config')
			domodlib('castle_lib')

			function onUse(cid, item, fromPosition, itemEx, toPosition)
				if castleCfg.castleGetReward ~= false then
					if getPlayerGuildName(cid) == getCastleOwner() then
						if getPlayerLevel(cid) >= castleCfg.levelToGetReward then
							if getCreatureStorage(cid, item.actionid) <= os.time() then
								local cash, rewardItem = math.random(castleCfg.cash.min, castleCfg.cash.max), castleCfg.itemsToGive[math.random(#castleCfg.itemsToGive)]

								doPlayerAddItem(cid, 2160, cash)
								doPlayerAddItem(cid, rewardItem, 1)
								doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You get ' .. cash .. ' crystal coins and ' .. getItemNameById(rewardItem) .. ' from your king!')
								doCreatureSetStorage(cid, item.actionid, os.time() + 60 * 60 * 24)
							else
								doPlayerSendCancel(cid, 'You have already get your gift! You can get it again in ' ..  secondsToClock(math.abs(os.difftime(getCreatureStorage(cid, item.actionid), os.time())))  .. '.')
							end
						else
							doPlayerSendCancel(cid, 'Your level is to low. You should have ' .. castleCfg.levelToGetReward .. '.')
						end
					else
						doPlayerSendCancel(cid, 'You have no acces to get this reward!')
						doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), true)
						doCreatureSetStorage(cid, castleCfg.storage.winner, -1)
						doCreatureSetStorage(cid, castleCfg.storage.playersEvent, -1)
					end
				end
				return true
			end
		]]>
	</action>

	<movement type='StepIn' actionid='4991' event='script'>
		<![CDATA[
			domodlib('castle_config')
			domodlib('castle_lib')

			function onStepIn(cid, item, position)
				if getPlayerGuildName(cid) ~= getCastleOwner() then
					doPlayerSendCancel(cid, 'You have no acces to go thereget this reward!')
					doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), true)
					return false
				end
				return true
			end
		]]>
	</movement>
	
	<globalevent name='Castle_start' type='startup' event='script'>
		<![CDATA[
			domodlib('castle_config')

			function onStartup()
				doSetStorage(castleCfg.storage.event, -1)
				doSetStorage(castleCfg.storage.joinEvent, -1)
				doSetStorage(castleCfg.storage.time, 0)
				return true
			end
		]]>
	</globalevent>
</mod>

The monsters (gate and king) are added and I've tested them too and they are working just fine.

What to do?
 
Cut it into normal .lua files., much stable than mods ^_^.

But if you want to fix this sick MOD just read errors:

[Error - TalkAction Interface]
(LuaInterface::luaDoCreateMonster) Monster with name '' not found

Yeah well wth does that errors mean? The monsters are on the map at the right cords, and they are named just as in the script.
 
as i see the server can't find the monster gate try putting it in data/monsters not in data/mods and try using " not '
 
as i see the server can't find the monster gate try putting it in data/monsters not in data/mods and try using " not '

I have it in the data/monsters.

I'll try using " instead of ' then report back with results.

- - - Updated - - -

Is this correct?

Code:
doCreateMonster("King", castleCfg.kingPos)

- - - Updated - - -

Okey I've changed it all and it's giving me the exact same error....
 
Back
Top Bottom