Created
October 15, 2015 14:12
-
-
Save dbjorkholm/bfff7c06123134966636 to your computer and use it in GitHub Desktop.
war ~
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Guild | |
local guild = player:getGuild() | |
guild = guild and guild:getId() or 0 | |
if guild ~= 0 then | |
-- Display Active Wars | |
local resultId = db.storeQuery("SELECT `guild_wars`.*, `g`.`name` AS `guild_name`, `e`.`name` AS `enemy_name`, (SELECT COUNT(1) FROM `guildwar_kills` WHERE `guildwar_kills`.`warid` = `guild_wars`.`id` AND `guildwar_kills`.`killerguild` = `guild_wars`.`guild1`) guild1_kills, (SELECT COUNT(1) FROM `guildwar_kills` WHERE `guildwar_kills`.`warid` = `guild_wars`.`id` AND `guildwar_kills`.`killerguild` = `guild_wars`.`guild2`) guild2_kills FROM `guild_wars` LEFT JOIN `guilds` AS `g` ON `g`.`id` = `guild_wars`.`guild1` LEFT JOIN `guilds` AS `e` ON `e`.`id` = `guild_wars`.`guild2` WHERE (`guild1` = " .. guild .. " OR `guild2` = " .. guild .. ") AND `status` = 1") | |
if resultId ~= false then | |
repeat | |
local guild1 = result.getNumber(resultId, "guild1") | |
local isGuild1 = guild1 == guild | |
local enemyName = result.getString(resultId, isGuild1 and "enemy_name" or "guild_name") | |
local guildKills = result.getNumber(resultId, isGuild1 and "guild1_kills" or "guild2_kills") | |
local enemyKills = result.getNumber(resultId, isGuild1 and "guild2_kills" or "guild1_kills") | |
local limit = result.getNumber(resultId, "limit") | |
player:sendTextMessage(MESSAGE_INFO_DESCR, string.format("Your guild is currently in war with %s (%d:%d frags, limit: %d).", enemyName, guildKills, enemyKills, limit)) | |
until not result.next(resultId) | |
result.free(resultId) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment