--[[
Master-m
&
Colandus
]]--
local PZ = createConditionObject(CONDITION_INFIGHT)
setConditionParam(PZ, CONDITION_PARAM_TICKS, getConfigInfo('whiteSkullTime'))
function onKill(cid, target, lastHit)
if isPlayer(cid) == TRUE and isPlayer(target) == TRUE then
local GUID = getPlayerGUID(cid)
local namec = getPlayerName(cid)
local namet = getPlayerName(target)
local skull = getCreatureSkullType(cid)
local skullend = getPlayerSkullEnd(cid)
local cidd = cid
local timeA = os.time()
local timesA = {today = (timeA - 86400), week = (timeA - (7 * 86400))}
local contentsA, resultA = {day = {}, week = {}, month = {}}, db.getResult("SELECT `pd`.`date`, `pd`.`level`, `p`.`name` FROM `player_killers` pk LEFT JOIN `killers` k ON `pk`.`kill_id` = `k`.`id` LEFT JOIN `player_deaths` pd ON `k`.`death_id` = `pd`.`id` LEFT JOIN `players` p ON `pd`.`player_id` = `p`.`id` WHERE `pk`.`player_id` = " .. getPlayerGUID(cid) .. " AND `k`.`unjustified` = 1 AND `pd`.`date` >= " .. (timeA - (30 * 86400)) .. " ORDER BY `pd`.`date` DESC")
if(resultA:getID() ~= -1) then
repeat
local contentA = {
name = resultA:getDataString("name"),
level = resultA:getDataInt("level"),
date = resultA:getDataInt("date")
}
if(contentA.date > timesA.today) then
table.insert(contentsA.day, contentA)
elseif(contentA.date > timesA.week) then
table.insert(contentsA.week, contentA)
else
table.insert(contentsA.month, contentA)
end
until not resultA:next()
resultA:free()
end
local sizeA = {
day = table.maxn(contentsA.day),
week = table.maxn(contentsA.week),
month = table.maxn(contentsA.month)
}
local function removeFrag(cid)
local timeB = os.time()
local timesB = {today = (timeB - 86400), week = (timeB - (7 * 86400))}
local contentsB, resultB = {day = {}, week = {}, month = {}}, db.getResult("SELECT `pd`.`date`, `pd`.`level`, `p`.`name` FROM `player_killers` pk LEFT JOIN `killers` k ON `pk`.`kill_id` = `k`.`id` LEFT JOIN `player_deaths` pd ON `k`.`death_id` = `pd`.`id` LEFT JOIN `players` p ON `pd`.`player_id` = `p`.`id` WHERE `pk`.`player_id` = " .. GUID .. " AND `k`.`unjustified` = 1 AND `pd`.`date` >= " .. (timeB - (30 * 86400)) .. " ORDER BY `pd`.`date` DESC")
if(resultB:getID() ~= -1) then
repeat
local contentB = {
name = resultB:getDataString("name"),
level = resultB:getDataInt("level"),
date = resultB:getDataInt("date")
}
if(contentB.date > timesB.today) then
table.insert(contentsB.day, contentB)
elseif(contentB.date > timesB.week) then
table.insert(contentsB.week, contentB)
else
table.insert(contentsB.month, contentB)
end
until not resultB:next()
resultB:free()
end
local sizeB = {
day = table.maxn(contentsB.day),
week = table.maxn(contentsB.week),
month = table.maxn(contentsB.month)
}
if sizeB.day > sizeA.day or sizeB.week > sizeA.week or sizeB.month > sizeA.month then
db.executeQuery("UPDATE `killers` SET `unjustified` = 0 WHERE `id` IN (SELECT `kill_id` FROM `player_killers` WHERE `player_id` = "..GUID..") ORDER BY `death_id` DESC LIMIT 1;")
doPlayerSendTextMessage(cidd, 21, "Frag from "..namet.." wasn't counted.")
end
if skull == SKULL_RED then
if getCreatureSkullType(cidd) == SKULL_BLACK then
doPlayerSetSkullEnd(cidd, skullend, SKULL_RED)
doCreatureSetSkullType(cidd, SKULL_RED)
end
elseif skull == SKULL_WHITE then
if getCreatureSkullType(cidd) == SKULL_RED then
doPlayerSetSkullEnd(cidd, timeB, SKULL_RED)
doCreatureSetSkullType(cidd, SKULL_WHITE)
end
end
end
local myGuild = getPlayerGuildId(cid)
local enemyGuild = getPlayerGuildId(target)
if myGuild ~= 0 and enemyGuild ~= 0 then
if enemyGuild == getGuildWarInfo(myGuild).With then
local guildc = getPlayerGuildName(cid)
local guildt = getPlayerGuildName(target)
doAddCondition(cid, PZ)
if lastHit == TRUE then
if getShowInfo(myGuild) == 1 then
registerDeathOne(myGuild, enemyGuild, cid, target)
else
registerDeathTwo(myGuild, enemyGuild, cid, target)
end
end
addEvent(removeFrag, 150)
local guildcKills = getKills(guildc)
local guildtKills = getKills(guildt)
local resulta, resultb = getMinMax(guildcKills, guildtKills)
local players = getOnlinePlayers()
for i,playerName in ipairs(players) do
local player = getPlayerByName(playerName);
if getPlayerGuildId(player) == myGuild then
doPlayerSendChannelMessage(player, "", "Opponent "..namet.." of the "..guildt.." was killed by "..namec..". The new score is "..resulta..":"..resultb.." frags.", TALKTYPE_CHANNEL_W, CHANNEL_GUILD)
end
end
end
end
end
return TRUE
end