[B]Simple Anti-Speedhack[/B]
Usage: Make a lua file (just name it sv_antispeed.lua or something) in lua/autorun/server, then c&p the code in the code tags into the file, restart the server, and you're done!
Description: Makes sure people can't speedhack on your server.
Why it's better than the rest: 100% serversided, changing timescale doesn't affect it, not shittily coded or pasted, and it detects all forms of CLIENTSIDE speedhack, meaning using a serverside speedhack won't affect it (setting player movement speed/velocity and such)
Convars:
antispeed (1/0) - Enables/disables the anti-speedhack.
Source:
[CODE]local next = next;
local cvCreate = CreateConVar;
local bBor = bit.bor;
local hkAdd = hook.Add;
local timCreate = timer.Create;
local plyGetAll = player.GetAll;
local flTimerTick = engine.TickInterval() * 3;
local cvEnabled = cvCreate("antispeed", "1", bBor(FCVAR_ARCHIVE, FCVAR_SERVER_CAN_EXECUTE), "Is Simple Anti-Speedhack enabled? 1 = true && 0 = false");
local function hkStartCommand(pEntity, pUserCmd)
if (!pEntity.iSASBadTicks) then
pEntity.iSASBadTicks = 0;
end
if (!pEntity.iSASTicks) then
pEntity.iSASTicks = 1;
elseif (pEntity.iSASTicks) then
pEntity.iSASTicks = pEntity.iSASTicks + 1;
end
end
local function hkTick()
for iIndex, pEntity in next, plyGetAll() do
if (!pEntity.iSASBadTicks || !pEntity.iSASTicks) then
continue; // i put return here sorry for triggering you ley
end
if (pEntity.iSASTicks >= 2) then
pEntity.iSASBadTicks = pEntity.iSASBadTicks + 1;
end
if (pEntity.iSASBadTicks == 1) then
pEntity.vecSASOldPos = pEntity:GetPos();
end
if (pEntity.iSASBadTicks >= 2 && cvEnabled:GetBool()) then
if (pEntity.vecSASOldPos) then
pEntity:SetPos(pEntity.vecSASOldPos);
end
pEntity:SetVelocity(-pEntity:GetVelocity());
end
pEntity.iSASTicks = 0;
end
end
local function timResetTicks()
for iIndex, pEntity in next, plyGetAll() do
pEntity.iSASBadTicks = 0;
end
end
hkAdd("StartCommand", "AntiSpeed.StartCommand", hkStartCommand);
hkAdd("Tick", "AntiSpeed.Tick", hkTick);
timCreate("AntiSpeed.ResetTicks", flTimerTick, 0, timResetTicks);[/CODE]
[B]Without SAS[/B] (sorry for 5fps gif, as you can see i'm speedhacking):
[img]http://i.imgur.com/Owm1ITA.gif[/img]
[B]With SAS[/B] (sorry for 5fps gif, as you can see i'm attempting to speedhack but the anti-speed is making it so i can't):
[img]http://i.imgur.com/93DXfVf.gif[/img]
[quote]if i ever get a pig, i'm going to name it Hammable Licktor and feed it pork[/quote]
No offense but most people will probably just use other anti-cheats that have that and a lot of other things..
Can't tell this is Styles anti speed (did the exact same effect) pasted or you decided to write your own even though all anti speeds (working non buggy) are the same other than the coder
[QUOTE=PaX_;49457858][B]Simple Anti-Speedhack[/B]
Usage: Make a lua file (just name it sv_antispeed.lua or something) in lua/autorun/server, then c&p the code in the code tags into the file, restart the server, and you're done!
Description: Makes sure people can't speedhack on your server.
Why it's better than the rest: 100% serversided, changing timescale doesn't affect it, not shittily coded or pasted, and it detects all forms of CLIENTSIDE speedhack, meaning using a serverside speedhack won't affect it (setting player movement speed/velocity and such)
Convars:
antispeed (1/0) - Enables/disables the anti-speedhack.
Source:
[CODE]local next = next;
local cvCreate = CreateConVar;
local bBor = bit.bor;
local hkAdd = hook.Add;
local timCreate = timer.Create;
local plyGetAll = player.GetAll;
local flTimerTick = engine.TickInterval() * 3;
local cvEnabled = cvCreate("antispeed", "1", bBor(FCVAR_ARCHIVE, FCVAR_SERVER_CAN_EXECUTE), "Is Simple Anti-Speedhack enabled? 1 = true && 0 = false");
local function hkStartCommand(pEntity, pUserCmd)
if (!pEntity.iSASBadTicks) then
pEntity.iSASBadTicks = 0;
end
if (!pEntity.iSASTicks) then
pEntity.iSASTicks = 1;
elseif (pEntity.iSASTicks) then
pEntity.iSASTicks = pEntity.iSASTicks + 1;
end
end
local function hkTick()
for iIndex, pEntity in next, plyGetAll() do
if (!pEntity.iSASBadTicks || !pEntity.iSASTicks) then
return;
end
if (pEntity.iSASTicks >= 2) then
pEntity.iSASBadTicks = pEntity.iSASBadTicks + 1;
end
if (pEntity.iSASBadTicks == 1) then
pEntity.vecSASOldPos = pEntity:GetPos();
end
if (pEntity.iSASBadTicks >= 2 && cvEnabled:GetBool()) then
if (pEntity.vecSASOldPos) then
pEntity:SetPos(pEntity.vecSASOldPos);
end
pEntity:SetVelocity(-pEntity:GetVelocity());
end
pEntity.iSASTicks = 0;
end
end
local function timResetTicks()
for iIndex, pEntity in next, plyGetAll() do
pEntity.iSASBadTicks = 0;
end
end
hkAdd("StartCommand", "AntiSpeed.StartCommand", hkStartCommand);
hkAdd("Tick", "AntiSpeed.Tick", hkTick);
timCreate("AntiSpeed.ResetTicks", flTimerTick, 0, timResetTicks);[/CODE]
[B]Without SAS[/B] (sorry for 5fps gif, as you can see i'm speedhacking):
[img]http://i.imgur.com/Owm1ITA.gif[/img]
[B]With SAS[/B] (sorry for 5fps gif, as you can see i'm attempting to speedhack but the anti-speed is making it so i can't):
[img]http://i.imgur.com/93DXfVf.gif[/img][/QUOTE]
Yet it is shittily coded and maybe pasted?
If a single player doesn't have one of the variables set once, the whole check does nothing for that turn.
All kinds of variables are localized, yet it gives a 0% performance boost.
It uses FCVAR_SERVER_CAN_EXECUTE, even though it still would only be changeable by the server without it.
It uses hungarian notation even though lua is a dynamically typed language.
This script is like the embodiment of premature optimization
[QUOTE=Leystryku;49468085]Yet it is shittily coded and maybe pasted?
If a single player doesn't have one of the variables set once, the whole check does nothing for that turn.
All kinds of variables are localized, yet it gives a 0% performance boost.
It uses FCVAR_SERVER_CAN_EXECUTE, even though it still would only be changeable by the server without it.
It uses hungarian notation even though lua is a dynamically typed language.
This script is like the embodiment of premature optimization[/QUOTE]
1. Not pasted, might be shittily coded, depends on your definition.
2. It should set all the variables on the first usercmd sent.
3. Didn't know that :v
4. It looks prettier + i'm used to it.
[QUOTE=PaX_;49474200]1. Not pasted, might be shittily coded, depends on your definition.
2. It should set all the variables on the first usercmd sent.
3. Didn't know that :v
4. It looks prettier + i'm used to it.[/QUOTE]
[code]
local next = next;
local cvCreate = CreateConVar;
local bBor = bit.bor;
local hkAdd = hook.Add;
local timCreate = timer.Create;
local plyGetAll = player.GetAll;
local flTimerTick = engine.TickInterval() * 3;
local cvEnabled = cvCreate("antispeed", "1", bBor(FCVAR_ARCHIVE, FCVAR_SERVER_CAN_EXECUTE), "Is Simple Anti-Speedhack enabled? 1 = true && 0 = false");
[/code]
those variables/localizations don't even give you a 0% performance boost and just make your code even uglier.
[code]
local function hkTick()
for iIndex, pEntity in next, plyGetAll() do
if (!pEntity.iSASBadTicks || !pEntity.iSASTicks) then
return;
end
[/code]
you still stop checking all others when 1 guy doesn't get checked.
[QUOTE=Leystryku;49474504][code]
local next = next;
local cvCreate = CreateConVar;
local bBor = bit.bor;
local hkAdd = hook.Add;
local timCreate = timer.Create;
local plyGetAll = player.GetAll;
local flTimerTick = engine.TickInterval() * 3;
local cvEnabled = cvCreate("antispeed", "1", bBor(FCVAR_ARCHIVE, FCVAR_SERVER_CAN_EXECUTE), "Is Simple Anti-Speedhack enabled? 1 = true && 0 = false");
[/code]
those variables/localizations don't even give you a 0% performance boost and just make your code even uglier.
[code]
local function hkTick()
for iIndex, pEntity in next, plyGetAll() do
if (!pEntity.iSASBadTicks || !pEntity.iSASTicks) then
return;
end
[/code]
you still stop checking all others when 1 guy doesn't get checked.[/QUOTE]
1. ok, i just like localizing everything
2. fixed, meant to put continue
now i have to tell my mom that somebodies code on a forum gave me an std
[QUOTE=Leystryku;49474504]you still stop checking all others when 1 guy doesn't get checked.[/QUOTE]
It makes me wonder if people write out what they're trying to do in psuedo-code or plain English before starting. I think it helps alleviate some of those hiccups, at least for me.
Trash addon
Sorry, you need to Log In to post a reply to this thread.