p-kuen / PatchProtect

A Prop Protection for Garry's Mod
12 stars 10 forks source link

Returns nil on CPPICanPhysgun #126

Closed ReturnEnd closed 7 years ago

ReturnEnd commented 7 years ago

The function CPPICanPhysgun returns nil even when someone is able to pick up the prop. https://github.com/Patcher56/PatchProtect/blob/9b83f274fd2ded9f5f7eef6d1f9334c3b4a092ca/lua/autorun/cppi.lua#L87

d-kuen commented 7 years ago

Hi, as you can see at https://github.com/Patcher56/PatchProtect/blob/9b83f274fd2ded9f5f7eef6d1f9334c3b4a092ca/lua/patchprotect/server/propprotection.lua#L89 the function sv_pprotect.CanTouch only returns nil, if the player is allowed to touch the prop, if it is an admin or if he is the owner or buddy of the owner of the prop. If we would return true here, every further check by the hook "PhysgunPickup" would be ignored.

I have not the CPPI-reference in mind, but if we would be forced to return true or false, a simple or true would fix the problem.

EDIT: It actually is, so I will change it.

d-kuen commented 7 years ago

Should be fixed with https://github.com/Patcher56/PatchProtect/commit/8b6b63975d4f9969e68c7accb09ff2e3f18cd9e4, but feel free to report any further issues.

ReturnEnd commented 7 years ago

Thanks for fixing it; but the code you implemented doesn't seem to be working in Lua ( I know it is in JAVA :) ) see http://lua-users.org/wiki/TernaryOperator

Fixed it : https://github.com/Patcher56/PatchProtect/compare/master...ReturnEnd:patch-2

d-kuen commented 7 years ago

Haha, I've checked the internet for the ternary operator, but it seems that I've gone through the post too fast. This operator is not only used in Java, it's used in C and some other languages too :D

But thanks for fixing the if conditions.