UKnowMe?
Messages : 51 Joined/Date d'inscription : 2012-10-08 Location/Localisation : Germany
Gema stats farthest jump:
| Subject: [Lua] Working Anti-Cheat script Sun Jan 03, 2016 2:04 pm | |
| So today I wrote a little script which detects some basic cheats (nadehack and ammohack, to be specific) Just put it into the lua/scripts directory and reload the server. - Code:
-
PLUGIN_NAME = "Basic Anti-Cheat for AssaultCube" PLUGIN_AUTHOR = "UKnowMe?" PLUGIN_VERSION = "1.0.1"
local configuration = { ban_time = 1200000 } -- values taken from server.h.cpp, will probably break in next release -- format: refill_size, max_reserve, magsize local guninfo = { [GUN_KNIFE] = { 1, 1, 1}, [GUN_PISTOL] = { 20,100, 10}, [GUN_CARBINE] = { 15, 30, 10}, [GUN_SHOTGUN] = { 14, 21, 7}, [GUN_SUBGUN] = { 60, 90, 30}, [GUN_SNIPER] = { 10, 15, 5}, [GUN_ASSAULT] = { 40, 60, 20}, [GUN_CPISTOL] = { 30, 75, 15}, [GUN_GRENADE] = { 1, 3, 1}, [GUN_AKIMBO] = {100,100, 20} } local player_information = {}
-- helper functions
function banclient(cn, reason) clientprint(-1, "\f3Player " .. getname(cn) .. " has " .. reason .. ", auto-banning " .. getip(cn)) logline(ACLOG_INFO, reason .. " detected on player " .. getname(cn) .. " auto-banning...") ban(cn, configuration['ban_time'], BAN_AUTO) end
-- handlers
function onInit() for cn in players(true) do onPlayerSpawn(cn) onPlayerWeaponChange(cn, getweapon(cn)) player_information[cn]['nades'] = getammo(GUN_GRENADE) end end
function onPlayerSpawn(cn) player_information[cn] = { nades = 0, akimbo = false, ammo = {} } end
function onPlayerWeaponChange(cn, weapon) if weapon ~= GUN_KNIFE and weapon ~= GUN_GRENADE then if player_information[cn]['ammo'][weapon] == nil or next(player_information[cn]['ammo'][weapon]) == nil then player_information[cn]['ammo'][weapon] = {} player_information[cn]['ammo'][weapon]['reserve'], player_information[cn]['ammo'][weapon]['mag'] = getammo(cn, weapon) end end end
function onPlayerShoot(cn, gun, to) if gun == GUN_GRENADE then if player_information[cn]['nades'] == 0 then banclient(cn, 'nadehack') else player_information[cn]['nades'] = player_information[cn]['nades'] - 1 end end end
function onPlayerShootAfter(cn, gun, to) if gun ~= GUN_KNIFE and gun ~= GUN_GRENADE then local reserve, mag = getammo(cn, gun) if player_information[cn]['ammo'][gun]['mag'] == 0 then banclient(cn, 'ammohack') else player_information[cn]['ammo'][gun]['mag'] = player_information[cn]['ammo'][gun]['mag'] - 1 end end end
function onPlayerItemPickup(cn, item_type, item_id) if item_type == I_GRENADE then player_information[cn]['nades'] = math.min(player_information[cn]['nades'] + (getgamemode() == GM_LSS and 2 or 1), guninfo[GUN_GRENADE][2]) elseif item_type == I_AMMO then local gun = getprimary(cn) local info = guninfo[gun] player_information[cn]['ammo'][gun]['reserve'] = math.min(player_information[cn]['ammo'][gun]['reserve'] + info[1], info[2]) elseif item_type == I_CLIPS then local gun = player_information[cn]['akimbo'] and GUN_AKIMBO or GUN_PISTOL local info = guninfo[gun] player_information[cn]['ammo'][gun]['reserve'] = math.min(player_information[cn]['ammo'][gun]['reserve'] + info[1], info[2]) end end
function onPlayerWeaponReload(cn, gun) if player_information[cn]['ammo'][gun]['reserve'] == 0 then banclient(cn, 'ammohack') end
local current = player_information[cn]['ammo'][gun]['mag'] local info = guninfo[gun] local fill = math.min(info[3] - current, player_information[cn]['ammo'][gun]['reserve']) player_information[cn]['ammo'][gun]['mag'] = player_information[cn]['ammo'][gun]['mag'] + fill player_information[cn]['ammo'][gun]['reserve'] = player_information[cn]['ammo'][gun]['reserve'] - fill end
function clearAkimbo(timerid) player_information[timerid]['akimbo'] = false end
function onPlayerGetAkimbo(cn) player_information[cn]['akimbo'] = true tmr.after(cn, 30000, clearAkimbo) end
function onPlayerDisconnect(cn, reason) player_information[cn] = nil tmr.remove(cn) end
Last edited by UKnowMe? on Sat Jan 09, 2016 7:27 am; edited 1 time in total (Reason for editing : Fixed nadehack detection after reload) | |
|
|HP| Admin
Messages : 226 Joined/Date d'inscription : 2010-06-01
Gema stats farthest jump: MAX
| Subject: Re: [Lua] Working Anti-Cheat script Mon Jan 04, 2016 2:24 pm | |
| | |
|
Sponsored content
Messages : 56 Joined/Date d'inscription : 2014-12-06
| Subject: Re: [Lua] Working Anti-Cheat script Fri Jan 15, 2016 8:51 pm | |
| | |
|
JagArNoob!!!
Messages : 48 Joined/Date d'inscription : 2015-06-28 Age : 28 Location/Localisation : Rio de Janeiro - Brazil
Gema stats farthest jump: almost 6 cubes
| Subject: Re: [Lua] Working Anti-Cheat script Sun Jan 31, 2016 4:57 pm | |
| | |
|
vahe
Messages : 4 Joined/Date d'inscription : 2016-08-24 Age : 36 Location/Localisation : Armenia
| Subject: Re: [Lua] Working Anti-Cheat script Sun Aug 28, 2016 9:53 pm | |
| | |
|
Sponsored content
| Subject: Re: [Lua] Working Anti-Cheat script | |
| |
|