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

onlogn war points

Mauzim

Member
Joined
Jan 3, 2011
Messages
568
Reaction score
9
how to make msg on login with guild war
example.
Your guild is currently at war with the Perfect Insanity (522:309 frags, limit 1000).
 
This script is working, missing only display in alphabetic order if more than 1 enemies.
Lua:
local guild, enemy, guildFrags, enemyFrags = getPlayerGuildId(cid)
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
	local msg, enemyName, _tmp = ""
	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
		enemyName, _tmp = "", db.getResult("SELECT `name` FROM `guilds` WHERE `id` = " .. enemy)
		if(_tmp:getID() ~= -1) then
			enemyName = _tmp:getDataString("name")
			_tmp:free()
		end
		if msg == "" then
			msg = "Your guild is currently in war with the ".. enemyName.." ("..guildFrags..":"..enemyFrags.." frags, limit "..tmp:getDataInt("frags")..")"
		else
			msg = msg.. " and " .. enemyName.." ("..guildFrags..":"..enemyFrags.." frags, limit "..tmp:getDataInt("frags")..")"
		end
	until not tmp:next()
        msg = msg .. "."
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, msg)
	tmp:free()

EDIT: Bug found, when war finish (Guild X win) then Guild Y(losers) still get message on login that are in fight.
 
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 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

Here is script with alphabetic sort. Not sure about working.
 
Working fine, just one problem:
When war finish then everytime losers login they receive message that are in war with (winers).(It must be fixed)
Winers do not receive(It's 100%)
 
I'm agree with Mauzim, I think that you must restart ur server or do that query (after war ends).
db.executeQuery("UPDATE `guild_wars` SET `status` = 5, `end` = " .. os.time() .. " WHERE `status` = 1 AND `end` > 0 AND `end` < " .. os.time() .. ";")
It's propably bug in war system
 
Are you sure that you have war system by elf?



PS.:
Wymietek,

Where I have to add this?
Lua:
db.executeQuery("UPDATE `guild_wars` SET `status` = 5, `end` = " .. os.time() .. " WHERE `status` = 1 AND `end` > 0 AND `end` < " .. os.time() .. ";")
PS.: It's already in globalevents/script/init.lua
 
Back
Top