function getKillExpRatio(cid, target) local ratio = 1000 local msges = {} local playerGUID = getPlayerGUID(cid) local targetIP = getPlayerIp(target) local targetAccountID = getPlayerAccountId(target) if(killsIpCounter[playerGUID] == nil) then killsIpCounter[playerGUID] = {} end if(killsIpCounter[playerGUID][targetIP] == nil) then killsIpCounter[playerGUID][targetIP] = {} end if(killsAccountCounter[playerGUID] == nil) then killsAccountCounter[playerGUID] = {} end if(killsAccountCounter[playerGUID][targetAccountID] == nil) then killsAccountCounter[playerGUID][targetAccountID] = {} end local killsIp = killsIpCounter[playerGUID][targetIP] local killsAccount = killsAccountCounter[playerGUID][targetAccountID] local killsInLastHourPerIp = 0 local killsInLastFiveMinutesPerIp = 0 local killsInLastHourPerAccount = 0 local killsInLastFiveMinutesPerAccount = 0 local timeNow = os.time() local toRemoveFromTable = {} for _, killIpTime in pairs(killsIp) do if(killIpTime + 3600 > timeNow) then killsInLastHourPerIp = killsInLastHourPerIp + 1 if(killIpTime + 300 > timeNow) then killsInLastFiveMinutesPerIp = killsInLastFiveMinutesPerIp + 1 end else table.insert(toRemoveFromTable, _) end end for _, removeID in pairs(toRemoveFromTable) do table.remove(killsIpCounter[playerGUID][targetIP], removeID) end if(#killsIpCounter[playerGUID][targetIP] == 0) then table.remove(killsIpCounter[playerGUID], targetIP) end toRemoveFromTable = {} for _, killAccountTime in pairs(killsAccount) do if(killAccountTime + 3600 > timeNow) then killsInLastHourPerAccount = killsInLastHourPerAccount + 1 if(killAccountTime + 300 > timeNow) then killsInLastFiveMinutesPerAccount = killsInLastFiveMinutesPerAccount + 1 end else table.insert(toRemoveFromTable, _) end end for _, removeID in pairs(toRemoveFromTable) do table.remove(killsAccountCounter[playerGUID][targetAccountID], removeID) end if(#killsAccountCounter[playerGUID][targetAccountID] == 0) then table.remove(killsAccountCounter[playerGUID], targetAccountID) end if(not isBot(target)) then -- check rules if((not isBot(cid) and getPlayerIp(cid) == 0) or getPlayerIp(target) == 0) then ratio = 0 table.insert(msges, "offline kill block") end if(getPlayerIp(cid) == getPlayerIp(target)) then ratio = 0 table.insert(msges, "MC kill block") end if(killsInLastHourPerIp > killsPerHourPerIp) then ratio = 0 table.insert(msges, "IP hour limit") end if(killsInLastFiveMinutesPerIp > killsPerFiveMinutesPerIp) then ratio = 0 table.insert(msges, "IP five minutes limit") end if(killsInLastHourPerAccount > killsPerHourPerAccount) then ratio = 0 table.insert(msges, "account hour limit") end if(killsInLastFiveMinutesPerAccount > killsPerFiveMinutesPerAccount) then ratio = 0 table.insert(msges, "account five minutes limit") end end if(not isBot(target)) then ratio = ratio * (10 / (10 +((killsInLastFiveMinutesPerIp + killsInLastFiveMinutesPerAccount) / 2))) end ratio = ratio * math.min(getPlayerLevel(target) / getPlayerLevel(cid), 1.2) if(getDeaths(target) > getFrags(target) * 5 or getFrags(target) < 3) then ratio = ratio * 0.4 table.insert(msges, "newbie or very bad player") elseif(getDeaths(target) > getFrags(target) * 4) then ratio = ratio * 0.6 table.insert(msges, "bad player") elseif(getDeaths(target) * 2 < getFrags(target) and getTmpFrags(target) > 15 and getLastFrags(target) > 5) then ratio = ratio * 1.4 table.insert(msges, "very good player") elseif(getDeaths(target) < getFrags(target) and getTmpFrags(target) > 5 and getLastFrags(target) > 0) then ratio = ratio * 1.2 table.insert(msges, "good player") end if(#msges > 0) then return ratio / 1000, table.concat(msges, ", ") else return ratio / 1000, "" end end