C0nw0nk / Garrys-Mod-Anti-Cheat

Putting Anti back into Anti Cheat by blocking players cheating instead of just detecting what they do. Anti Bhop bunny hopping gmod lua garrysmod
http://www.networkflare.com/
12 stars 9 forks source link

error recoil #3

Closed svensis closed 8 years ago

svensis commented 8 years ago

[ERROR] addons/anticheat/lua/autorun/server/anti-recoil.lua:20: attempt to index field 'Primary' (a nil value)

  1. v - addons/anticheat/lua/autorun/server/anti-recoil.lua:20
    1. unknown - lua/includes/modules/hook.lua:84

it spamming console and its wierd, thanks!

https://i.gyazo.com/5abe24b0158fe4482325e0dab9d41824.png

im running sandbox and i have addons

addon list https://gyazo.com/5a2796804bfaad77975742d19e0b88f5

C0nw0nk commented 8 years ago

Maybe your SWEP's don't have any recoil set meaning the value returned would be nil or empty all i can say is try changing the code to this and let me know if it works for you.

if pl:GetActiveWeapon().Primary.KickUp then
if pl:GetActiveWeapon().Primary.KickDown then
if pl:GetActiveWeapon().Primary.Recoil then

if pl:GetActiveWeapon().Secondary.KickUp then
if pl:GetActiveWeapon().Secondary.KickDown then
if pl:GetActiveWeapon().Secondary.Recoil then

Change those following lines to look like this

if pl:GetActiveWeapon().Primary.KickUp != nil then
if pl:GetActiveWeapon().Primary.KickDown != nil then
if pl:GetActiveWeapon().Primary.Recoil != nil then

if pl:GetActiveWeapon().Secondary.KickUp != nil then
if pl:GetActiveWeapon().Secondary.KickDown != nil then
if pl:GetActiveWeapon().Secondary.Recoil != nil then
svensis commented 8 years ago

Its the default HL2 weapons

C0nw0nk commented 8 years ago

Yeah it is most likely because I forgot to account for the fact some weapons may not have a recoil method set or attached to them via their SWEP.

Make the changes to the code I provided and it should fix your issue or you can go and make a SWEP file / edit the default HL2 weapons and create a recoil method but i think my fix would be better since some weapons recoil is not needed on and it would be weird to have to make every weapon have recoil when allot do not need it.

C0nw0nk commented 8 years ago

I edited my main code anyway should solve it for you https://github.com/C0nw0nk/Garrys-Mod-Anti-Cheat/commit/6cf81de05d86051a1eeae239d68791b6fb6155a3

svensis commented 8 years ago

Infact, I dont think you cant edit the HL2 weapons, as they're inside the .pak files or something along the lines of that. but anyways, thanks your anticheat has saved my server alot

C0nw0nk commented 8 years ago

No problem I recommend Cake Anti Cheat it may not have some things I put into mine like Anti Bhop and Anti Recoil as well as the fix for ladder abuse, Anti Speed Hack etc but you will find it has allot more to offer.

https://scriptfodder.com/scripts/view/460

svensis commented 8 years ago

It helps to catch the skids, if they really really really want to hack, let them. atleast, thats how i think.

C0nw0nk commented 8 years ago

Well Cake, ULX Admin combined with this https://github.com/C0nw0nk/Garrys-Mod-Family-Sharing you can wave goodbye to them.

svensis commented 8 years ago

screencap is the best anticheat, I have serverguard's it is amaizing