Autor: darkhaos [[http://otland.net/f82/anticheat-pvp-enforced-servers-60569/|klik]]
Licencja: brak
Skrypt do serwerów war lub pvp enfo. Gdy gracz o daje się zabijać graczowi l (gdy gracz o zabije go x razy wciagu x sekund zostaje on zabity przez skrypt.
**Część SQL**
Dodajemy do naszej bazy :
alter table players add lastKill int(11) not null default 0;
alter table players add lastKillTime int(11) not null default 0;
**Część LUA**
Wchodzimy do /data/creaturescripts/scripts/ tworzymy tam plik anticheat.lua a jego zawartość to:
function onKill(cid, target, lastHit)
local timeWithinKill = 300 --in seconds
local killsLimit = 3 --limit to die
local lastKill, lastKillTime = nil, nil
local storage = 65535 --storage to check if player has killed another player 'killsLimit' times
if(isPlayer(target) == false) or (isMonster(cid) == true) then
return true
end
query = db.getResult("select lastKill, lastKillTime from players where id = " .. getPlayerGUID(cid) .. ";")
if(query:getID() ~= -1) then
lastKill, lastKillTime = query:getDataInt("lastKill"), query:getDataInt("lastKillTime")
if(lastKill == getPlayerGUID(target)) then
if(os.clock() - lastKillTime) < timeWithinKill then
if(getPlayerStorageValue(cid, storage) < 0) then
doPlayerSetStorageValue(cid, storage, 0)
end
doPlayerSetStorageValue(cid, storage, getPlayerStorageValue(cid, storage) + 1)
if(getPlayerStorageValue(cid, storage) >= killsLimit) then
doCreatureAddHealth(cid, -getCreatureHealth(cid))
end
else
doPlayerSetStorageValue(cid, storage, 0)
end
end
db.executeQuery("update players set lastKill = " .. getPlayerGUID(target) .. ", lastKillTime = " .. os.clock() .. " where id = " .. getPlayerGUID(cid) .. ";")
else
return LUA_ERROR
end
return true
end
Następnie dodajemy do login.lua linijkę:
registerCreatureEvent(cid, "AntiCheat")
Oraz do /data/creaturescripts/creaturescripts.xml wklejamy linijkę:
Gotowe!