• 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

Status
Not open for further replies.

marcinek99097

Banned User
Joined
Feb 6, 2010
Messages
588
Reaction score
4
Location
Poland/Dg
witam czy ten castle system

Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Castle System" version="1.0" author="Maniucza i Karpio" contact="http://tibia.net.pl/members/maniucza.html" enabled="yes">
<config name="CastleSystem Lib"><![CDATA[
castle = {}
 
castle.wallid = 7594
castle.wall = {{x = 587,y = 675,z = 7, stackpos = 1}, {x = 587,y = 676,z = 7, stackpos = 1}, {x = 587,y = 677,z = 7, stackpos = 1}}
castle.fromx = 583
castle.tox = 586
castle.fromy = 675
castle.toy = 677
castle.z = 7
castle.kick = {x = 583,y = 670,z = 7}
castle.teams = 0
castle.pos = {x = 583,y = 670,z = 7}
castle.mostdamage = 0
castle.winnerteam = 0
castle.monster = {x = 585, y = 673, z = 7}
castle.msg = true
castle.gary = true
castle.garypos =
{
	[1] = {x = x, y = y, z = z},
	[2] = {x = x, y = y, z = z},
	[3] = {x = x, y = y, z = z},
	[4] = {x = x, y = y, z = z}
 
}
 
function castle:firstTimer()
 
	if(os.date("%A") == "Thursday") then
		setGlobalStorageValue(1, 1)
		setGlobalStorageValue(2, os.time())
		if(castle.gary) then
			setGlobalStorageValue(1, 1)
		end
		doBroadcastMessage("Attention! Immediately register to Castle Wars. Leaders of the guild can enter your guild command:! Castle", MESSAGE_STATUS_WARNING)
	end
return true
end
 
function castle:secondTimer()
 
	if(os.date("%A") == "Thursday") then
		if(getGlobalStorageValue(1) == 1) then
			setGlobalStorageValue(1, 2)
		end
		if(castle.teams == 0) then
			local result = db.getResult("SELECT * FROM castles WHERE id=1;")
			local winner = result:getDataString("owner")
			result:free()
			doBroadcastMessage("Gilds"..winner.." defended castle. Congratulations!", MESSAGE_STATUS_WARNING)
			setGlobalStorageValue(1, 3)
		end
		doBroadcastMessage("Fight for Castle has begun!", MESSAGE_STATUS_WARNING)
		for i = 1, #castle.mur do
			doRemoveItem(getThingFromPos(castle.mur[i]).uid, 1)
		end
		local mon = doSummonCreature("King", castle.monster)
		registerCreatureEvent(mon, "hit")
	end
return true
end
 
function castle:thirdTimer()
 
	if(os.date("%A") == "Thursday" and getGlobalStorageValue(1) == 2) then
		for i = 1, #castle.mur do
			doCreateItem(castle.murid, 1, castle.mur[i])
		end
		castle:kickLosers()
		local result = db.getResult("SELECT * FROM castles WHERE id=1;")
		local winner = result:getDataString("owner")
		result:free()
		doBroadcastMessage("he struggle for the castle came to an end. Guilds "..winner.." defended castle. Congratulations!", MESSAGE_STATUS_WARNING)
		setGlobalStorageValue(1, 3)
	end
return true
end
 
function castle:kickLosers(id)
 
	if(id == nil) then
		local result = db.getResult("SELECT * FROM castles WHERE id=1;")
		id = result:getDataInt("ownerid")
		result:free()
	end
	if(id == "all") then
		for x = castle.fromx, castle.tox do
		for y = castle.fromy, castle.toy do
			local player = getThingFromPos({x=x, y=y, z=castle.z, stackpos = 253})
			if(player.itemid > 0) then
				if(isPlayer(player) == true) then
					doTeleportThing(player, castle.kick)
					if(castle.msg == true) then
						return doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "Przegral"..(getPlayerSex(player) == 0 and "as" or "es")..".")
					end
				end
			end
		end
		end
	elseif(isNumber(id) == true) then
		for x = castle.fromx, castle.tox do
		for y = castle.fromy, castle.toy do
			local player = getThingFromPos({x=x, y=y, z=castle.z, stackpos = 253})
			if(player.itemid > 0) then
				if(isPlayer(player) == true) then
					if(getPlayerGuildId(player) ~= id) then
						doTeleportThing(player, castle.kick)
						if(castle.msg == true) then
							return doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "Przegral"..(getPlayerSex(player) == 0 and "as" or "es")..".")
						end
					end
				end
			end
		end
		end
	end
	return true
end
 
function castle:addTeam(cid, gid)
 
	if(getGlobalStorageValue(1) == 1) then
		local result = db.getResult("SELECT * FROM castles_war WHERE guild_id="..gid.." AND time="..getGlobalStorageValue(2)..";")
		if(result:getID() ~= -1) then
			return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Guild is already written to the fight.")
		end
		db.executeQuery("INSERT INTO `castles_war` (`castle_id` ,`guild_id` ,`damage` ,`time`)VALUES ('1', '"..gid.."', '0', '"..getGlobalStorageValue(2).."');")
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Gilds added.")
		for k, v in pairs(getPlayersOnline()) do
			if(getPlayerGuildId(v) == gid) then
				if(getTilePzInfo(getCreaturePosition(v)) == true) then
					if(castle.gary) then
						doTeleportThing(v, castle.garypos[getGlobalStorageValue(3)])
						if(getGlobalStorageValue(3) < 4) then
							setGlobalStorageValue(3, getGlobalStorageValue(3) + 1)
						end
					else
						doTeleportThing(v, castle.pos)
					end
					if(castle.msg == true) then
						return doPlayerSendTextMessage(v, MESSAGE_INFO_DESCR, "Your guild, she joined the Fight for Castle.")
					end
				end
			end
		end
		castle.teams = castle.teams + 1
	else
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "There are currently no records.")
	end
return true
end
 
function castle:onHit(cid, attacker, type, combat, value)
 
	if(getCreatureName(cid) == "King") then
		if(db.executeQuery("UPDATE `castles_war` SET `damage`=`damage`+"..value.." WHERE `guild_id`="..getPlayerGuildId(attacker).." AND `time`="..getGlobalStorageValue(2)..";") ~= true) then
			return false
		else
			return true
		end
	end
return true
end
 
function castle:onKill(cid, target)
	if(getCreatureName(target) == "King" and getGlobalStorageValue(1) == 2) then
		local result = db.getResult("SELECT * FROM `castles_war` WHERE `time`="..getGlobalStorageValue(2).." ORDER BY `damage` DESC LIMIT 1;")
		castle.mostdamage = result:getDataInt("damage")
		castle.winnerteam = result:getDataInt("guild_id")
		result:free()
		local result2 = db.getResult("SELECT * FROM guilds WHERE id="..castle.winnerteam..";")
		local name = result2:getDataString("name")
		result2:free()
		setGlobalStorageValue(1, 3)
		doBroadcastMessage("Gilds "..name.." injuries inflicted the greatest king and is the winner. The reward is replaced by the castle.")
		db.executeQuery("UPDATE castles SET ownerid="..castle.winnerteam..", owner=\""..name.."\" WHERE id=1;")
		castle:kickLosers(castle.winnerteam)
	end
	return true
end
]]></config>
 
	<event type="login" name="Castle King Kill" event="script"><![CDATA[
		domodlib("CastleSystem Lib")
		function onKill(cid, target, lastHit)
			if(getCreatureName(target) == "King") then
				castle:onKill(cid, target)
				return true
			end
		return true
		end]]></event>
 
	<event type="statschange" name="Hit" event="script"><![CDATA[	
		domodlib("CastleSystem Lib")
		function onStatsChange(cid, attacker, type, combat, value)
			castle:onHit(cid, attacker, type, combat, value)
		return true
		end]]></event>
 
	<globalevent name="timer1" time="18:20" event="script"><![CDATA[
		domodlib("CastleSystem Lib")
		function onTimer()
			castle:firstTimer()
		return true
		end]]></globalevent>
 
	<globalevent name="timer2" time="18:22" event="script"><![CDATA[
		domodlib("CastleSystem Lib")
		function onTimer()
			castle:secondTimer()
		return true
		end]]></globalevent>
 
	<globalevent name="timer3" time="18:24" event="script"><![CDATA[
		domodlib("CastleSystem Lib")
		function onTimer()
			castle:thirdTimer()
		return true
		end]]></globalevent>
 
	<talkaction words="!zamek" event="buffer"><![CDATA[
		domodlib("CastleSystem Lib")
		function onSay(cid, words, param, channel)
			if(getPlayerGuildLevel(cid) == 3) then
				castle:addTeam(cid, getPlayerGuildId(cid))
			return true
			end
 
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Nie jestes liderem gildi.")
		return true
		end
]]></talkaction>
</mod>

Bedzie działać na 0.4?
A i mogł by ktoś mi przetłumaczyć co te wszystkie cyferki znaczą bo chciałem własną mapke z zamkiem wgrać?
 
Ze wszystkim czego nie wiesz będziesz latał na forum? Zobacz sam czy będzie działał na 0.4 a żeby wiedzieć co oznaczają te cyferki wystarczy sam angielski...
 
nice:
Code:
if(db.executeQuery("UPDATE `castles_war` SET `damage`=`damage`+"..value.." WHERE `guild_id`="..getPlayerGuildId(attacker).." AND `time`="..getGlobalStorageValue(2)..";") ~= true)
 
Dobrze nie znam angielskiego , a pytać się będe bo po to forum jest -.- a Ty po co się udzielasz w moich tematach skoro nic nie umiesz a pieprzysz.
 
To że nie pomagam nie oznacza że nic nie umiem. A według Ciebie na forum wszystko zrobią za Ciebie? Chcesz coś mieć to się tego naucz metodą prób i błędów lub zapierdalaj do poradników tu na otlandzie z google translate.
 
To że nie pomagam nie oznacza że nic nie umiem. A według Ciebie na forum wszystko zrobią za Ciebie? Chcesz coś mieć to się tego naucz metodą prób i błędów lub zapierdalaj do poradników tu na otlandzie z google translate.

Najlepiej się nie udzielaj.

http://otland.net/f163/mod-castle-system-78551/

Napisz w tym temacie, lub do maniuczy napewno Ci powie co i jak.

//myśle, że powinno działać na 0.4, sprawdź a jak nie to pisz.
 
dziękuje , a mogł by ktoś przetłumaczyć te współrzędne? bo angielski to jedna rzecz ale nie których nie czaje wgl.?
 
dziękuje , a mogł by ktoś przetłumaczyć te współrzędne? bo angielski to jedna rzecz ale nie których nie czaje wgl.?


castle.fromx = 583 ->z x
castle.tox = 586 -> do x
castle.fromy = 675 -> z y
castle.toy = 677 -> do y
castle.z = 7 -> pozycja z
castle.kick = {x = 583,y = 670,z = 7} -> gdzie ma kickack
castle.teams = 0 -> to chyba wiesz
castle.pos = {x = 583,y = 670,z = 7} -> pozycja zamku
castle.mostdamage = 0 -> niewiem, chyba Ci co najwiecej obrazen zadali
castle.winnerteam = 0 -> wygrany team
castle.monster = {x = 585, y = 673, z = 7} -> pozycja potworka
castle.msg = true -> wiadomosc
castle.gary = true -> gary xD niewime ocb
castle.garypos =

==))
 
troche po działałem i wgl nie chce wyskoczyć timer1,2,3 ;/ ustawiam ,że w czwartek godziny tak aby teraz to było i nadal nic ,może ktoś miał podobny problem , w konsoli nic się nie dzieje.
 
castle.gary = true -> gary xD niewime ocb
castle.garypos =
wersja sylwestrowa, jak dasz gary = true - pozmywa gary po bajli, tylko pozycje kuchni musisz podać. ; d



#temat
wykonanie chujowe, powinien działac, tylko db.executeQuery powinieneś zmienić na db.query o ile dobrze pamiętam ; d
 
wersja sylwestrowa, jak dasz gary = true - pozmywa gary po bajli, tylko pozycje kuchni musisz podać. ; d



#temat
wykonanie chujowe, powinien działac, tylko db.executeQuery powinieneś zmienić na db.query o ile dobrze pamiętam ; d

Karpio przerabiał ten skrypt pod moje upodobania, stąd też nazwa z części mojego nicku :).
castle.gary - czy chcesz aby skrypt zabierał 4 teamy na 4 różne pozycje.
castle.garypos - podajesz tutaj 4 rozne wspolrzedne na ktore kazdy z teamow bedzie teleportowany.
 
1. Nie może
2. Wtedy to już nie jest ten castle system, on pytał czy TEN zadziała
 
Status
Not open for further replies.
Back
Top