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

Problem With Castle War System. [MOD]

thegood

New Member
Joined
Jan 20, 2012
Messages
28
Reaction score
0
Hi, I have this castle war system:
Lua:
<?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 = 10.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 = 200,
				minMembers = {p = 200, first = 5, second = 10}, 
				-- p = ilosc playerow na ktorej nastepuje zmiana; 
				-- first (jezeli playerow jest mniej niz "p"); second (jezeli playerow jest wiecej niz "p");

				guildsMinMax = {min = 2, max = 4},
				days = {['Monday'] = {'18:00:20'}, 
					['Tuesday'] = {'18:00:20'}, 
					['Wednesday'] = {'18:00:20'}, 
					['Thursday'] = {'18:00:20'}, 
					['Friday'] = {'18:00:20'}, 
					['Saturday'] = {'15:00:20'}, 
					['Sunday'] = {'15:00:20'}
				},

				-- POZYCJE --
				kingPos = {x = 1598, y = 1120, z = 3},

				gates = {
					{pos = {x = 1581, y = 1132, z = 6}},
					{pos = {x = 1610, y = 1144, z = 6}},
					{pos = {x = 1580, y = 1146, z = 6}},
					{pos = {x = 1582, y = 1119, z = 6}},
					{pos = {x = 1627, y = 1134, z = 5}},
					{pos = {x = 1605, y = 1130, z = 5}},
					{pos = {x = 1593, y = 1112, z = 6}},
					{pos = {x = 1615, y = 1117, z = 6}}
				},
				
				telePositions = {
					{x = 1569, y = 1136, z = 6},
					{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 = 1634, y = 1134, z = 5}, --
					-- {x = 1580, y = 1151, z = 6}, --
					{x = 1616, y = 1150, z = 6}
				},

				-- REWARD --
				castleGetReward = true, -- true lub false
				levelToGetReward = 200,
				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
					2346  -- 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
			
			function doStartCountingCastleEvent(x)
				if castleCfg.timeToStartJoinToCastleWar-x > 0 then
					doBroadcastMessage('[CASTLE WAR]\n\nCastle War Event is going to start in '..castleCfg.timeToStartJoinToCastleWar+castleCfg.timeToStartCastleWar-x..' minutes.')
					addEvent(doStartCountingCastleEvent, 60*1000, x+1)
				else
					castleOpen()
				end
			end
		]]>
	</lib>
	
	<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()
					doStartCountingCastleEvent(0)

					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='!castleback' log="yes" 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' log="yes" 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='!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
							doSetStorage(castleCfg.storage.event, 1)
							doCleanCastleFighters()
							doStartCountingCastleEvent(0)

							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 "!castle info". 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>

	<monster name='King' file='castle/king.xml'/>
	<monster name='Gate' file='castle/gate.xml'/>
	
	<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>

But when i add it i see this error in engine:
mysql_real_query(): SELECT `guild_name` FROM `castle` WHERE `owner` > 0 - MYSQL ERROR: Table 'tfs.castle' doesn't exist (1146)
[10/04/2013 12:11:54] mysql_real_query(): UPDATE `castle_dmg` SET `dmg` = `dmg` + 74987 WHERE `guild` = 0 - MYSQL ERROR: Table 'tfs.castle_dmg' doesn't exist (1146)
[10/04/2013 12:11:56] mysql_real_query(): UPDATE `castle_dmg` SET `dmg` = `dmg` + 238870 WHERE `guild` = 0 - MYSQL ERROR: Table 'tfs.castle_dmg' doesn't exist (1146)
[10/04/2013 12:11:58] mysql_real_query(): UPDATE `castle_dmg` SET `dmg` = `dmg` + 1 WHERE `guild` = 0 - MYSQL ERROR: Table 'tfs.castle_dmg' doesn't exist (1146)
[10/04/2013 12:12:00] mysql_real_query(): UPDATE `castle_dmg` SET `dmg` = `dmg` + 1 WHERE `guild` = 0 - MYSQL ERROR: Table 'tfs.castle_dmg' doesn't exist (1146)
[10/04/2013 12:12:02] mysql_real_query(): UPDATE `castle_dmg` SET `dmg` = `dmg` + 1 WHERE `guild` = 0 - MYSQL ERROR: Table 'tfs.castle_dmg' doesn't exist (1146)
[10/04/2013 12:12:04] mysql_real_query(): UPDATE `castle_dmg` SET `dmg` = `dmg` + 1 WHERE `guild` = 0 - MYSQL ERROR: Table 'tfs.castle_dmg' doesn't exist (1146)
[10/04/2013 12:12:05] mysql_real_query(): UPDATE `castle_dmg` SET `dmg` = `dmg` + 643160 WHERE `guild` = 0 - MYSQL ERROR: Table 'tfs.castle_dmg' doesn't exist (1146)
[10/04/2013 12:12:06] mysql_real_query(): UPDATE `castle_dmg` SET `dmg` = `dmg` + 1 WHERE `guild` = 0 - MYSQL ERROR: Table 'tfs.castle_dmg' doesn't exist (1146)
[10/04/2013 12:12:08] mysql_real_query(): UPDATE `castle_dmg` SET `dmg` = `dmg` + 1 WHERE `guild` = 0 - MYSQL ERROR: Table 'tfs.castle_dmg' doesn't exist (1146)
[10/04/2013 12:12:10] mysql_real_query(): UPDATE `castle_dmg` SET `dmg` = `dmg` + 1 WHERE `guild` = 0 - MYSQL ERROR: Table 'tfs.castle_dmg' doesn't exist (1146)
[10/04/2013 12:12:12] mysql_real_query(): UPDATE `castle_dmg` SET `dmg` = `dmg` + 1 WHERE `guild` = 0 - MYSQL ERROR: Table 'tfs.castle_dmg' doesn't exist (1146)
[10/04/2013 12:12:14] mysql_real_query(): UPDATE `castle_dmg` SET `dmg` = `dmg` + 1 WHERE `guild` = 0 - MYSQL ERROR: Table 'tfs.castle_dmg' doesn't exist (1146)
[10/04/2013 12:12:16] mysql_real_query(): UPDATE `castle_dmg` SET `dmg` = `dmg` + 1 WHERE `guild` = 0 - MYSQL ERROR: Table 'tfs.castle_dmg' doesn't exist (1146)
[10/04/2013 12:12:18] mysql_real_query(): UPDATE `castle_dmg` SET `dmg` = `dmg` + 1 WHERE `guild` = 0 - MYSQL ERROR: Table 'tfs.castle_dmg' doesn't exist (1146)
[10/04/2013 12:12:20] mysql_real_query(): UPDATE `castle_dmg` SET `dmg` = `dmg` + 1 WHERE `guild` = 0 - MYSQL ERROR: Table 'tfs.castle_dmg' doesn't exist (1146)
[10/04/2013 12:12:22] mysql_real_query(): UPDATE `castle_dmg` SET `dmg` = `dmg` + 1 WHERE `guild` = 0 - MYSQL ERROR: Table 'tfs.castle_dmg' doesn't exist (1146)
[10/04/2013 12:12:24] mysql_real_query(): UPDATE `castle_dmg` SET `dmg` = `dmg` + 1 WHERE `guild` = 0 - MYSQL ERROR: Table 'tfs.castle_dmg' doesn't exist (1146)
[10/04/2013 12:12:26] mysql_real_query(): UPDATE `castle_dmg` SET `dmg` = `dmg` + 1 WHERE `guild` = 0 - MYSQL ERROR: Table 'tfs.castle_dmg' doesn't exist (1146)
[10/04/2013 12:12:27] mysql_real_query(): SELECT `guild_name` FROM `castle` WHERE `owner` > 0 - MYSQL ERROR: Table 'tfs.castle' doesn't exist (1146)
[10/04/2013 12:12:28] mysql_real_query(): UPDATE `castle_dmg` SET `dmg` = `dmg` + 1 WHERE `guild` = 0 - MYSQL ERROR: Table 'tfs.castle_dmg' doesn't exist (1146)
[10/04/2013 12:12:30] mysql_real_query(): UPDATE `castle_dmg` SET `dmg` = `dmg` + 1 WHERE `guild` = 0 - MYSQL ERROR: Table 'tfs.castle_dmg' doesn't exist (1146)
[10/04/2013 12:12:32] mysql_real_query(): UPDATE `castle_dmg` SET `dmg` = `dmg` + 1 WHERE `guild` = 0 - MYSQL ERROR: Table 'tfs.castle_dmg' doesn't exist (1146)

Please help, I think that I have to add some tables in my database, but i don't know what I have to add.
Thx to all ;)))
 
Last edited by a moderator:
Add this query into ur database:

PHP:
CREATE TABLE IF NOT EXISTS `castles` (
 `id` int(11) NOT NULL auto_increment,
 `castle_name` varchar(255) NOT NULL,
 `owner_guild` varchar(255) NOT NULL,
 `castle_war` varchar(255) NOT NULL,
 `last_conqueror` varchar(255) NOT NULL,
 PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1
 
PHP:
CREATE TABLE IF NOT EXISTS `castles_war` (
  `castle_id` int(5) NOT NULL,
  `guild_id` int(5) NOT NULL,
  `damage` int(20) NOT NULL,
  `time` int(50) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
 
OK, but now when players login i see this error in engine:
[10/04/2013 12:49:11] GOD Villalba has logged in.
[10/04/2013 12:49:11] mysql_real_query(): SELECT `guild_name` FROM `castle` WHERE `owner` > 0 - MYSQL ERROR: Table 'tfs.castle' doesn't exist (1146)
 
OK, with your script all are good, but this error..:
[10/04/2013 13:25:00] > Broadcasted message: "Attention! Immediately register to Castle Wars. Leaders of the guild can enter your guild command:! Castle".

[10/04/2013 13:27:00] [Error - GlobalEvent Interface]
[10/04/2013 13:27:00] buffer:eek:nTimer
[10/04/2013 13:27:00] Description:
[10/04/2013 13:27:00] data/lib/004-database.lua:76: [Result:getDataString] Result not set!
[10/04/2013 13:27:00] stack traceback:
[10/04/2013 13:27:00] [C]: in function 'error'
[10/04/2013 13:27:00] data/lib/004-database.lua:76: in function 'getDataString'
[10/04/2013 13:27:00] [string "castle = {}..."]:47: in function 'secondTimer'
[10/04/2013 13:27:00] [string "loadBuffer"]:3: in function <[string "loadBuffer"]:2>
[10/04/2013 13:27:00] [Error - GlobalEvents::timer] Couldn't execute event: timer2
 
hm.. what tfs are you using?

test:
creaturescripts\scripts\login.lua". Add:
Lua:
registerCreatureEvent(cid, "CastleKingDeath")
registerCreatureEvent(cid, "CastleKingDamage")

and in \creaturescripts\creaturescripts.xml. Add/edit:
Lua:
<!-- Castle System -->
<event type="death" name="CastleKingDeath" event="script" value="castle_kill.lua"/>
<event type="statschange" name="CastleKingDamage" event="script" value="castle_damage.lua"/>

looks like another problem tho, but you can always test..
 
Mmmm.... I use tfs 0.4.1.0
This scripts don't work because don't have the lua scripts, but if i use a [MOD] i think that i don't have to add nothing in data.
 
Test this system instead:
Creds to kawon.

In creaturescripts,
Castle_Damage.lua
Lua:
damages = {0,0,0} -- don`t touch

function onStatsChange(cid, attacker, type, combat, value)
	if (not isPlayer(attacker)) then
		return true
	end
	-- dont sure
	if getCreatureMaxHealth(cid) == getCreatureHealth(cid) then
		damages = {0,0,0}
	end
	if (getCreatureName(cid) == getCastleConfig("monster") and value > 0 and isInArray(Castle_getAttackers(), getPlayerGuildId(attacker))) then 
		local pos = Castle_getGuildPos(getPlayerGuildId(attacker))
		damages[pos] = damages[pos] + value
		return true
	else
		doPlayerSendCancel(attacker, "Don`t attack your own King!")
		return false
	end
end

Creaturescripts,
castle_kill.lua
Lua:
function onDeath(cid, corpse, killer)
	if (getCreatureName(cid) == getCastleConfig("monster")) then
		Castle_endEvent(true, damages)
	end
	-- cleanup
	damages = {0,0,0}
	return true
end

In globalevents,
castle.lua
Lua:
function onTimer()
	if not(isInArray(CASTLE_DAYS, tonumber(os.date("%w")))) then
		return true
	else
		Castle_enableSaving()
	end
return true
end

in lib,
102-castle.lua
Lua:
local castleConfig = {
	days = {2, 5},
	time_1 = 10*60*1000, -- time from start event to fight
	time_2 = 30*60*1000, -- time from fight to end event
	guildOwnStorage = 17000,
	attackersStorage = 17002,
	enabledStorage = 17006,
	endedStorage = 17007,
	leaderLevel = 50000,
	membersNeeded = 5,
	monster = "Tiberia King",
	monsterSpawn = {x = 2470, y = 2477, z = 3},
	startAttackers = {
		[1] = {x = 2444, y = 2491, z = 6},
		[2] = {x = 2494, y = 2503, z = 6},
		[3] = {x = 2488, y = 2464, z = 6}
	},
	gates = {
		[1] = {pos = {x = 2456, y = 2487, z = 6}, itemid = 9533},
		[2] = {pos = {x = 2456, y = 2488, z = 6}, itemid = 9533},
		
		[3] = {pos = {x = 2486, y = 2498, z = 6}, itemid = 9485},
		[4] = {pos = {x = 2487, y = 2498, z = 6}, itemid = 9485},
		
		[5] = {pos = {x = 2490, y = 2471, z = 6}, itemid = 9486},
		[6] = {pos = {x = 2491, y = 2471, z = 6}, itemid = 9486},
		[7] = {pos = {x = 2492, y = 2471, z = 6}, itemid = 9486},
		
		-- new 
		[8] = {pos = {x = 2452, y = 2480, z = 6}, itemid = 9533},
		[9] = {pos = {x = 2452, y = 2481, z = 6}, itemid = 9533},
		[10] = {pos = {x = 2452, y = 2482, z = 6}, itemid = 9533},
		
		[11] = {pos = {x = 2485, y = 2498, z = 6}, itemid = 9485},	
		
		[12] = {pos = {x = 2498, y = 2502, z = 6}, itemid = 9533},
		[13] = {pos = {x = 2498, y = 2503, z = 6}, itemid = 9533},
		
		[14] = {pos = {x = 2485, y = 2468, z = 6}, itemid = 9486},
		[15] = {pos = {x = 2486, y = 2468, z = 6}, itemid = 9486},
		[16] = {pos = {x = 2487, y = 2468, z = 6}, itemid = 9486},
	

		
	},
}
CASTLE_DAYS = {3,6}

function getCastleConfig(value)
	if (value ~= nil) then
		return castleConfig[value] or false 
	else
		return false
	end
end

function removeNotKilledKing(cid)
	if isMonster(cid) and getCreatureName(cid) == castleConfig.monster then
		doRemoveCreature(cid)
	end
	return true
end


-- it sux but don`t have idea how to make it better, attackers Index
function Castle_getGuildPos(guildId)
	local attackers = Castle_getAttackers()
	for i,value in ipairs(attackers) do
		if (tonumber(guildId) == tonumber(value)) then
			ret = i
		end
	end
	return ret
end

function Castle_enableSaving()
	doBroadcastMessage("[ Castle Event Enabled! ]\n\nIf you're a guild leader and you have at least ".. castleConfig.membersNeeded .." members you can sign in your guild by saying !castle in default channel.", MESSAGE_INFO_DESCR)
	setGlobalStorageValue(castleConfig.enabledStorage, 1)
	--setGlobalStorageValue(castleConfig.endedStorage, 0)
	Castle_cleanUp()
	addEvent(Castle_startEvent, castleConfig.time_1)
	return true
end

function Castle_getAttackers()
	local ret = {}
	local query = string.explode(getGlobalStorageValue(castleConfig.attackersStorage), ",")
	for _,value in ipairs(query) do
		if isNumber(value) then
			table.insert(ret, value)
		end
	end
	return ret
end

function Castle_startEvent()
	setGlobalStorageValue(castleConfig.enabledStorage, 0)
	setGlobalStorageValue(castleConfig.endedStorage, 0)
	if(#Castle_getAttackers() == 0) then
		doBroadcastMessage("[ Castle Event Failed! ]\n\nWe have not attackers!", MESSAGE_INFO_DESCR)
		return true
	end
	doBroadcastMessage("[ Castle Event Fight! ]\n\nEvent has been started. Kill Tiberia King !!!", MESSAGE_INFO_DESCR)
	local monster = doSummonCreature(castleConfig.monster, castleConfig.monsterSpawn)
	for _, gate in pairs(castleConfig.gates) do
		doRemoveItem(getTileItemById(gate.pos, gate.itemid).uid)
	end
	addEvent(Castle_endEvent, castleConfig.time_2, false)
	addEvent(removeNotKilledKing, castleConfig.time_2, monster)
	return true
end

function Castle_endEvent(killed, damages)
	local playersOnline = getPlayersOnline()
	local dmgCount = 0
	local message = ""
	local winner = 0
	
	if (getGlobalStorageValue(castleConfig.endedStorage) ~= 1) then
		if (killed) then
			for _,value in ipairs(Castle_getAttackers()) do
				message = message.."\n"..getGuildName(value)..":"..damages[Castle_getGuildPos(value)].." dmg"
				if damages[Castle_getGuildPos(value)] > dmgCount then
					winner = value
					dmgCount = damages[Castle_getGuildPos(value)]
				end
			end
			doBroadcastMessage("[ Castle Event End! ]\n\n> Statistics " .. message .."\nWINNER:"..getGuildName(winner), MESSAGE_INFO_DESCR)
			
			local attackers = Castle_getAttackers()
			table.insert(attackers, getGlobalStorageValue(castleConfig.guildOwnStorage))
			for _, pid in ipairs(playersOnline) do
				if ((isInArray(attackers, getPlayerGuildId(pid)) or getGlobalStorageValue(castleConfig.guildOwnStorage) == getPlayerGuildId(pid)) and not(tonumber(getPlayerGuildId(pid)) == tonumber(winner))) then
					doRemoveCondition(pid, CONDITION_INFIGHT)
					doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)))
				end
			end
			setGlobalStorageValue(castleConfig.guildOwnStorage, winner)
		else
			doBroadcastMessage("[ Castle Event End! ]\n\n> Castle has been saved by owner.", MESSAGE_INFO_DESCR)
		end
		setGlobalStorageValue(castleConfig.endedStorage, 1)
	end
	Castle_cleanUp()
	return true
end

function Castle_cleanUp()
	setGlobalStorageValue(castleConfig.attackersStorage, ",")
	return true
end

function Castle_getGuildMembers(guildId)
	local playersOnline = getPlayersOnline()
	local members = {}
	for _, pid in ipairs(playersOnline) do
		if (getPlayerGuildId(pid) == guildId) then
			table.insert(members, pid)
		end
	end
	return members
end


function Castle_trySave(cid)
	if not(getPlayerGuildLevel(cid) == GUILDLEVEL_LEADER) then
		doPlayerSendCancel(cid, "Sorry, but you have to be a leader of guild.")
		return true
	end

	if (getGlobalStorageValue(castleConfig.enabledStorage) ~= 1) then
		doPlayerSendCancel(cid, "Sorry, but it's not time yet.")
		return true
	end

	if (getPlayerLevel(cid) < castleConfig.leaderLevel) then
		doPlayerSendCancel(cid, "Sorry, but your level is too low.")
		return true
	end

	local players = Castle_getGuildMembers(getPlayerGuildId(cid))
	if (#players == 1) then
		doPlayerSendCancel(cid, "Sorry, but you haven't any online members in guild.")
		return true
	end

	if (#players < castleConfig.membersNeeded) then
		doPlayerSendCancel(cid, "Sorry, but you need at least ".. castleConfig.membersNeeded .." guild members online.")
		return true
	end
	if (tonumber(getGlobalStorageValue(castleConfig.guildOwnStorage)) == tonumber(getPlayerGuildId(cid))) then
		doPlayerSendCancel(cid, "Your guild should protect Castle, not attack.")
		return true
	end

	if (#Castle_getAttackers() == 3) then
		doPlayerSendCancel(cid, "Sorry, we have already 3 attacking guilds.")
		return true
	end
	if (isInArray(Castle_getAttackers(), getPlayerGuildId(cid))) then
		doPlayerSendCancel(cid, "Be patient, war will start in a few minutes.")
		return true
	end

	setGlobalStorageValue(castleConfig.attackersStorage, getGlobalStorageValue(castleConfig.attackersStorage)..getPlayerGuildId(cid)..",")
	doBroadcastMessage("[ Castle Event Info ]\n\nGuild ".. getPlayerGuildName(cid) .." will fight for Castle.\nAttackers: ".. #Castle_getAttackers() .." / 3", MESSAGE_INFO_DESCR)

	for i, pid in ipairs(getPlayersOnline()) do
		if (isInArray(getPlayerGuildId(cid), getPlayerGuildId(pid))) then
			doTeleportThing(pid, castleConfig.startAttackers[#Castle_getAttackers()])
		end
	end
	return true
end
In talkactions,
castlewar.lua
Lua:
function onSay(cid, words, param, channel)
	Castle_trySave(cid)
	return true
end
Monsters,
Tibiera King.xml
XML:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="Tiberia King" nameDescription="an tiberia king" race="blood" experience="1200" speed="0" manacost="0">
  <health now="2200000000" max="2200000000"/>
  <look type="332" />
  <targetchange interval="5000" chance="0"/>
  <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="0"/>
    <flag canpushcreatures="1"/>
    <flag targetdistance="1"/>
    <flag staticattack="90"/>
    <flag runonhealth="100"/>
  </flags>
  <attacks>
    <attack name="melee" interval="2000" skill="1" attack="1"/>
  </attacks>
  <defenses armor="1" defense="1"/>
  <script> 
	<event name="CastleKingDeath"/> 
	<event name="CastleKingDamage"/> 
  </script>
  <immunities>
    <immunity fire="1"/>
    <immunity poison="1"/>
    <immunity lifedrain="1"/>
    <immunity invisible="1"/>
  </immunities>
</monster>

Cred to: mateuszal3
data\creaturescripts\scripts\login.lua". Add:
Code:
[B]registerCreatureEvent(cid, "CastleKingDeath")
registerCreatureEvent(cid, "CastleKingDamage")[/B]

Copy: "Castle System\creaturescripts\castle_damage.lua" and "Castle System\creaturescripts\castle_kill.lua" to "data\creaturescripts\scripts\"
File: "data\creaturescripts\creaturescripts.xml". Add (or edit):
Code:
<!-- Castle System -->
<event type="[B]death[/B]" name="CastleKingDeath" event="script" value="castle_kill.lua"/>
<event type="[B]statschange[/B]" name="CastleKingDamage" event="script" value="castle_damage.lua"/>

Copy: "Castle System\talkactions\castlewar.lua" to "data\talkactions\scripts\"
File: "data\creaturescripts\creaturescripts.xml". Add:
Code:
<!-- Castle System -->
<talkaction words="!zamek;!castle" hide="yes" event="script" value="castlewar.lua"/>

Create Folder: "data\monster\Tiberia King\"
Copy: "Castle System\monster\tiberia king.xml" to "data\monster\Tiberia King\"

File: "data\monsters\monsters.xml". Add:
Code:
<!-- Castle System -->
<monster name="Tiberia King" file="Tiberia King/tiberia king.xml"/>

Copy: "Castle System\lib\102-castle.lua" to "data\lib\"

Copy: "Castle System\globalevents\castle.lua" to "data\globalevents\scripts\"
File: "data\globalevents\globalevents.xml". Add:
Code:
<!-- Castle Mod -->
<globalevent name="CastleTimer" time="00:06" event="script" value="castle.lua"/>
 
Last edited:
I don't understand some things, i can send to you a map, and if you can configurate it for me please :( Because i don't speak english and I have a lot of errors
 
Back
Top