Here is a skeleton that can be used in 2 different ways.
1. You can make it ban (I've added this functionality by default)
2. You can remove the ban and add an exp system to it. (this will basically prevent exp from being granted to player that bypass the kill limit)
I have added some extra stuff and commented it out for people who wish to use it, this script is tested on 0.4
Sorry that it is so bare-bones but I do not have the time to make a war server exp system from scratch.
Tldr on what this script does:
It is based on IP, if player A kills player B 3 times within 10 minutes (default) the next kill will ban for 30 minutes. If you so chose to disable the ban function and add your own exp system then this script will give exp for the first 3 kills (default) and prevent all exp gain thereafter until the 10 minute timer (default) expires.
I DO STRONGLY RECOMMEND MAKING YOUR OWN EXP SYSTEM INSTEAD OF JUST BANNING PEOPLE AS INNOCENT PLAYERS COULD BE BANNED IF THEY ACCIDENTALLY KILL THE SAME PLAYER MORE THAN 3 TIMES IN 10 MINUTES!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Code:
local killLimit = 3 -- How many kills before the player will no longer gain exp
local timerLength = 10*60 -- how long before a player can gain exp from the same player after reaching the limit (time is in seconds, 10*60 = 10 minutes)
local ipTables = {
-- This is an example of what the table will look like after it is populated in-game (you do not edit anything inside this table ever!)
-- [player ip] = {
-- [victim ip] = {kills = 0, timer = os.time()}
-- }
}
function onKill(cid, target, damage, flags)
if(not isPlayer(target)) then return true end
local cidIp = getPlayerIp(cid)
if(not ipTables[cidIp]) then
ipTables[cidIp] = {}
end
local targetIp = getPlayerIp(target)
if(not ipTables[cidIp][targetIp]) then
ipTables[cidIp][targetIp] = {kills = 1, timer = os.time()+timerLength}
else
local targetInfo = ipTables[cidIp][targetIp]
if(targetInfo.timer < os.time()) then
targetInfo.kills = 0
targetInfo.timer = os.time()+timerLength
end
if(targetInfo.kills >= killLimit) then
-- do not give exp (possible ban script goes here if you want)
doAddAccountBanishment(getPlayerAccountId(cid), 3, os.time()+(30*60), 11, 2, "Free Exping (30 minute ban)")
doRemoveCreature(cid)
else
-- give exp script goes here(you will have to figure out a way to calculate exp gain here...)
-- This will add a kill to the count
targetInfo.kills = targetInfo.kills+1
-- This will refresh the timer after each kill pre-limit
-- targetInfo.timer = os.time()+timerLength
end
end
return true
end