From 2094b04e2a290767f81310443d93b2f55a63e3c6 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Wed, 13 Nov 2024 17:13:42 +0000 Subject: [PATCH] Lua code format - (Stylua) --- data/scripts/creaturescripts/player/death.lua | 41 ++++++++----------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/data/scripts/creaturescripts/player/death.lua b/data/scripts/creaturescripts/player/death.lua index d89c27eac07..42d143781d4 100644 --- a/data/scripts/creaturescripts/player/death.lua +++ b/data/scripts/creaturescripts/player/death.lua @@ -48,8 +48,7 @@ end local function saveDeathRecord(playerGuid, player, killerName, byPlayer, mostDamageName, byPlayerMostDamage, unjustified, mostDamageUnjustified) local query = string.format( - "INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `is_player`, `mostdamage_by`, `mostdamage_is_player`, `unjustified`, `mostdamage_unjustified`) " .. - "VALUES (%d, %d, %d, '%s', %d, '%s', %d, %d, %d)", + "INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `is_player`, `mostdamage_by`, `mostdamage_is_player`, `unjustified`, `mostdamage_unjustified`) " .. "VALUES (%d, %d, %d, '%s', %d, '%s', %d, %d, %d)", playerGuid, os.time(), player:getLevel(), @@ -96,10 +95,7 @@ local function getDeathRecords(playerGuid) end local function checkForGuildWar(targetGuildId, killerGuildId) - local resultId = db.storeQuery(string.format( - "SELECT `id` FROM `guild_wars` WHERE `status` = 1 AND ((`guild1` = %d AND `guild2` = %d) OR (`guild1` = %d AND `guild2` = %d))", - killerGuildId, targetGuildId, targetGuildId, killerGuildId - )) + local resultId = db.storeQuery(string.format("SELECT `id` FROM `guild_wars` WHERE `status` = 1 AND ((`guild1` = %d AND `guild2` = %d) OR (`guild1` = %d AND `guild2` = %d))", killerGuildId, targetGuildId, targetGuildId, killerGuildId)) local warId = false if resultId then @@ -112,20 +108,21 @@ end local function recordGuildWarKill(killer, player, killerGuildId, targetGuildId, warId) local playerName = player:getName() - db.asyncQuery(string.format( - "INSERT INTO `guildwar_kills` (`killer`, `target`, `killerguild`, `targetguild`, `time`, `warid`) VALUES ('%s', '%s', %d, %d, %d, %d)", - db.escapeString(killer:getName()), db.escapeString(playerName), killerGuildId, targetGuildId, os.time(), warId - )) + db.asyncQuery(string.format("INSERT INTO `guildwar_kills` (`killer`, `target`, `killerguild`, `targetguild`, `time`, `warid`) VALUES ('%s', '%s', %d, %d, %d, %d)", db.escapeString(killer:getName()), db.escapeString(playerName), killerGuildId, targetGuildId, os.time(), warId)) end local function checkAndUpdateGuildWarScore(warId, targetGuildId, killerGuildId, playerName, killerName, mostDamageName) - local resultId = db.storeQuery(string.format( - "SELECT `guild_wars`.`id`, `guild_wars`.`frags_limit`, " .. - "(SELECT COUNT(1) FROM `guildwar_kills` WHERE `guildwar_kills`.`warid` = `guild_wars`.`id` AND `guildwar_kills`.`killerguild` = `guild_wars`.`guild1`) AS guild1_kills, " .. - "(SELECT COUNT(1) FROM `guildwar_kills` WHERE `guildwar_kills`.`warid` = `guild_wars`.`id` AND `guildwar_kills`.`killerguild` = `guild_wars`.`guild2`) AS guild2_kills " .. - "FROM `guild_wars` WHERE (`guild1` = %d OR `guild2` = %d) AND `status` = 1 AND `id` = %d", - killerGuildId, targetGuildId, warId - )) + local resultId = db.storeQuery( + string.format( + "SELECT `guild_wars`.`id`, `guild_wars`.`frags_limit`, " + .. "(SELECT COUNT(1) FROM `guildwar_kills` WHERE `guildwar_kills`.`warid` = `guild_wars`.`id` AND `guildwar_kills`.`killerguild` = `guild_wars`.`guild1`) AS guild1_kills, " + .. "(SELECT COUNT(1) FROM `guildwar_kills` WHERE `guildwar_kills`.`warid` = `guild_wars`.`id` AND `guildwar_kills`.`killerguild` = `guild_wars`.`guild2`) AS guild2_kills " + .. "FROM `guild_wars` WHERE (`guild1` = %d OR `guild2` = %d) AND `status` = 1 AND `id` = %d", + killerGuildId, + targetGuildId, + warId + ) + ) if resultId then local guild1Kills = Result.getNumber(resultId, "guild1_kills") @@ -144,18 +141,12 @@ end local function updateGuildWarScore(killerGuild, targetGuild, playerName, killerName, guild1Kills, guild2Kills, fragsLimit) local members = killerGuild:getMembersOnline() for _, member in ipairs(members) do - member:sendChannelMessage(member, string.format( - "%s was killed by %s. The new score is: %s %d:%d %s (frags limit: %d)", playerName, killerName, - targetGuild:getName(), guild1Kills, guild2Kills, killerGuild:getName(), fragsLimit - ), TALKTYPE_CHANNEL_R1, CHANNEL_GUILD) + member:sendChannelMessage(member, string.format("%s was killed by %s. The new score is: %s %d:%d %s (frags limit: %d)", playerName, killerName, targetGuild:getName(), guild1Kills, guild2Kills, killerGuild:getName(), fragsLimit), TALKTYPE_CHANNEL_R1, CHANNEL_GUILD) end local enemyMembers = targetGuild:getMembersOnline() for _, enemy in ipairs(enemyMembers) do - enemy:sendChannelMessage(enemy, string.format( - "%s was killed by %s. The new score is: %s %d:%d %s (frags limit: %d)", playerName, killerName, - targetGuild:getName(), guild1Kills, guild2Kills, killerGuild:getName(), fragsLimit - ), TALKTYPE_CHANNEL_R1, CHANNEL_GUILD) + enemy:sendChannelMessage(enemy, string.format("%s was killed by %s. The new score is: %s %d:%d %s (frags limit: %d)", playerName, killerName, targetGuild:getName(), guild1Kills, guild2Kills, killerGuild:getName(), fragsLimit), TALKTYPE_CHANNEL_R1, CHANNEL_GUILD) end end