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

CreatureEvent [War System] Who are your enemies onLogin

Lua:
local guild, enemy, guildFrags, enemyFrags = getPlayerGuildId(cid)
local fightingGuilds = {}
local tmp = db.getResult("SELECT `guild_id`, `enemy_id`, `guild_kills`, `enemy_kills`, `frags` FROM `guild_wars` WHERE `guild_id` = "..guild.." OR `enemy_id` = "..guild.." AND `status` = 1;")
if tmp:getID() ~= -1 then
	i = 1
	repeat
		if tmp:getDataInt("guild_id") == guild then
			enemy = tmp:getDataInt("enemy_id")
			guildFrags = tmp:getDataInt("guild_kills")
			enemyFrags = tmp:getDataInt("enemy_kills")
		else
			enemy = tmp:getDataInt("guild_id")
			guildFrags = tmp:getDataInt("enemy_kills")
			enemyFrags = tmp:getDataInt("guild_kills")
		end
		local enemyName, _tmp = "", db.getResult("SELECT `name` FROM `guilds` WHERE `id` = " .. enemy)
		if(_tmp:getID() ~= -1) then
			enemyName = _tmp:getDataString("name")
			_tmp:free()
 
		end
 
		fightingGuilds[i] = {}
		fightingGuilds[i].name = enemyName
		fightingGuilds[i].guildFrags = guildFrags
		fightingGuilds[i].enemyFrags = enemyFrags
		fightingGuilds[i].limit = tmp:getDataInt("frags")
 
		i = i + 1
	until not(tmp:next())
	tmp:free()
 
	table.sort(fightingGuilds, function (a, b)
		return (a.name < b.name)
	end)
 
	local warString = ""
 
	for k, v in pairs(fightingGuilds) do
		
		if ((v.guildFrags < v.limit) or (v.enemyFrags < v.limit)) then
			if  (warString == "") then
				warString = "Your guild is currently in war with the " .. v.name .. " (" .. v.guildFrags .. ":" .. v.enemyFrags .. " frags, limit ".. v.limit ..")"
			else
				warString = warString .. " and with the " .. v.name .. " (" .. v.guildFrags .. ":" .. v.enemyFrags.." frags, limit ".. v.limit .. ")"
			end
		end
	end
	
	if (warString ~= "") then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, warString .. ".")
	end
end
if still it doesn't work i'll try to download a server when i back to my home with war system to try to fix that
 
I will try it out later today when I'm at home :p

Edit: The text is only disappearing for the winners, still showing the text even if the war is over for the losers.
 
Last edited:
Ok, I will try to fix this script but I will accept some help.
Lua:
local guild, enemy, guildFrags, enemyFrags = getPlayerGuildId(cid)
local fightingGuilds = {}
local tmp = db.getResult("SELECT `guild_id`, `enemy_id`, `guild_kills`, `enemy_kills`, `frags` FROM `guild_wars` WHERE `guild_id` = "..guild.." OR `enemy_id` = "..guild.." AND `status` = 1;")
if tmp:getID() ~= -1 then
	i = 1
	repeat
		if tmp:getDataInt("guild_id") == guild then
			enemy = tmp:getDataInt("enemy_id")
			guildFrags = tmp:getDataInt("guild_kills")
			enemyFrags = tmp:getDataInt("enemy_kills")
		else
			enemy = tmp:getDataInt("guild_id")
			guildFrags = tmp:getDataInt("enemy_kills")
			enemyFrags = tmp:getDataInt("guild_kills")
		end
		local enemyName, _tmp = "", db.getResult("SELECT `name` FROM `guilds` WHERE `id` = " .. enemy)
		if(_tmp:getID() ~= -1) then
			enemyName = _tmp:getDataString("name")
			_tmp:free()
 
		end
 
		fightingGuilds[i] = {}
		fightingGuilds[i].name = enemyName
		fightingGuilds[i].guildFrags = guildFrags
		fightingGuilds[i].enemyFrags = enemyFrags
		fightingGuilds[i].limit = tmp:getDataInt("frags")
 
		i = i + 1
	until not(tmp:next())
	tmp:free()
 
	table.sort(fightingGuilds, function (a, b)
		return (a.name < b.name)
	end)
 
	local warString
 
	for k, v in pairs(fightingGuilds) do
		if not warString then
			warString = "Your guild is currently in war with the " .. v.name .. " (" .. v.guildFrags .. ":" .. v.enemyFrags .. " frags, limit ".. v.limit ..")"
		else
			warString = warString .. " and with the " .. v.name .. " (" .. v.guildFrags .. ":" .. v.enemyFrags.." frags, limit ".. v.limit .. ")"
		end
	end
 
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, warString .. ".")
end
 
You need to add something that compare the total frags amount with the limit... If it is equal to the limit, then don't show it and that's how you will fix your problem when the war is finished.
 
Change:
Lua:
for k, v in pairs(fightingGuilds) do
		if not warString then
			warString = "Your guild is currently in war with the " .. v.name .. " (" .. v.guildFrags .. ":" .. v.enemyFrags .. " frags, limit ".. v.limit ..")"
		else
			warString = warString .. " and with the " .. v.name .. " (" .. v.guildFrags .. ":" .. v.enemyFrags.." frags, limit ".. v.limit .. ")"
		end
	end

To:
Lua:
for k, v in pairs(fightingGuilds) do
		if (v.guildFrags ~= v.limit and v.enemyFrags ~= v.limit) then
			if not warString then
				warString = "Your guild is currently in war with the " .. v.name .. " (" .. v.guildFrags .. ":" .. v.enemyFrags .. " frags, limit ".. v.limit ..")"
			else
				warString = warString .. " and with the " .. v.name .. " (" .. v.guildFrags .. ":" .. v.enemyFrags.." frags, limit ".. v.limit .. ")"
			end
		end	
	end

Not tested, but as I see, if there hasn't reached the limit it won't show any text about that war.
 
Change:
Lua:
for k, v in pairs(fightingGuilds) do
		if not warString then
			warString = "Your guild is currently in war with the " .. v.name .. " (" .. v.guildFrags .. ":" .. v.enemyFrags .. " frags, limit ".. v.limit ..")"
		else
			warString = warString .. " and with the " .. v.name .. " (" .. v.guildFrags .. ":" .. v.enemyFrags.." frags, limit ".. v.limit .. ")"
		end
	end

To:
Lua:
for k, v in pairs(fightingGuilds) do
		if (v.guildFrags ~= v.limit and v.enemyFrags ~= v.limit) then
			if not warString then
				warString = "Your guild is currently in war with the " .. v.name .. " (" .. v.guildFrags .. ":" .. v.enemyFrags .. " frags, limit ".. v.limit ..")"
			else
				warString = warString .. " and with the " .. v.name .. " (" .. v.guildFrags .. ":" .. v.enemyFrags.." frags, limit ".. v.limit .. ")"
			end
		end	
	end

Not tested, but as I see, if there hasn't reached the limit it won't show any text about that war.

Can someone test?
 
everything works fine, now only the last player left in the war, if I come and go when I finished my war and fails. and does not let

dibujoajd.jpg
http://img266.imageshack.us/img266/2060/dibujoajd.png

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, warString .. ".")

The bug only happens to the player who invited wars ..

using this..

Code:
	local guild, enemy, guildFrags, enemyFrags = getPlayerGuildId(cid)
local fightingGuilds = {}
local tmp = db.getResult("SELECT `guild_id`, `enemy_id`, `guild_kills`, `enemy_kills`, `frags` FROM `guild_wars` WHERE `guild_id` = "..guild.." OR `enemy_id` = "..guild.." AND `status` = 1;")
if tmp:getID() ~= -1 then
	i = 1
	repeat
		if tmp:getDataInt("guild_id") == guild then
			enemy = tmp:getDataInt("enemy_id")
			guildFrags = tmp:getDataInt("guild_kills")
			enemyFrags = tmp:getDataInt("enemy_kills")
		else
			enemy = tmp:getDataInt("guild_id")
			guildFrags = tmp:getDataInt("enemy_kills")
			enemyFrags = tmp:getDataInt("guild_kills")
		end
		local enemyName, _tmp = "", db.getResult("SELECT `name` FROM `guilds` WHERE `id` = " .. enemy)
		if(_tmp:getID() ~= -1) then
			enemyName = _tmp:getDataString("name")
			_tmp:free()
 
		end
 
		fightingGuilds[i] = {}
		fightingGuilds[i].name = enemyName
		fightingGuilds[i].guildFrags = guildFrags
		fightingGuilds[i].enemyFrags = enemyFrags
		fightingGuilds[i].limit = tmp:getDataInt("frags")
 
		i = i + 1
	until not(tmp:next())
	tmp:free()
 
	table.sort(fightingGuilds, function (a, b)
		return (a.name < b.name)
	end)
 
	local warString
 
	for k, v in pairs(fightingGuilds) do
		if (v.guildFrags ~= v.limit and v.enemyFrags ~= v.limit) then
			if not warString then
				warString = "Your guild is currently in war with the " .. v.name .. " (" .. v.guildFrags .. ":" .. v.enemyFrags .. " frags, limit ".. v.limit ..")"
			else
				warString = warString .. " and with the " .. v.name .. " (" .. v.guildFrags .. ":" .. v.enemyFrags.." frags, limit ".. v.limit .. ")"
			end
		end	
	end
 
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, warString .. ".")
end
 
Last edited:
Lua:
local guild, enemy, guildFrags, enemyFrags = getPlayerGuildId(cid)
local fightingGuilds = {}
local tmp = db.getResult("SELECT `guild_id`, `enemy_id`, `guild_kills`, `enemy_kills`, `frags` FROM `guild_wars` WHERE `guild_id` = "..guild.." OR `enemy_id` = "..guild.." AND `status` = 1;")
if tmp:getID() ~= -1 then
	i = 1
	repeat
		if tmp:getDataInt("guild_id") == guild then
			enemy = tmp:getDataInt("enemy_id")
			guildFrags = tmp:getDataInt("guild_kills")
			enemyFrags = tmp:getDataInt("enemy_kills")
		else
			enemy = tmp:getDataInt("guild_id")
			guildFrags = tmp:getDataInt("enemy_kills")
			enemyFrags = tmp:getDataInt("guild_kills")
		end
		local enemyName, _tmp = "", db.getResult("SELECT `name` FROM `guilds` WHERE `id` = " .. enemy)
		if(_tmp:getID() ~= -1) then
			enemyName = _tmp:getDataString("name")
			_tmp:free()
 
		end
 
		fightingGuilds[i] = {}
		fightingGuilds[i].name = enemyName
		fightingGuilds[i].guildFrags = guildFrags
		fightingGuilds[i].enemyFrags = enemyFrags
		fightingGuilds[i].limit = tmp:getDataInt("frags")
 
		i = i + 1
	until not(tmp:next())
	tmp:free()
 
	table.sort(fightingGuilds, function (a, b)
		return (a.name < b.name)
	end)
 
	local warString = ""
 
	for k, v in pairs(fightingGuilds) do
		if (v.guildFrags < v.limit and v.enemyFrags < v.limit) then
			if not warString then
				warString = "Your guild is currently in war with the " .. v.name .. " (" .. v.guildFrags .. ":" .. v.enemyFrags .. " frags, limit ".. v.limit ..")"
			else
				warString = warString .. " and with the " .. v.name .. " (" .. v.guildFrags .. ":" .. v.enemyFrags.." frags, limit ".. v.limit .. ")"
			end
		end
	end
 
	if (warString ~= "") then 
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, warString .. ".")
	end
end
 
Last edited:
is that the full massage? when it shows ... might be cuz the guild doesnt exist. check on database for that war
 
Back
Top