JC-MP

Scripting => Releases => Topic started by: MrQWERTYU on July 10, 2019, 08:54:36 pm

Title: [Release] Basic Anti-Cheat
Post by: MrQWERTYU on July 10, 2019, 08:54:36 pm
* At the moment, it protects only from invulnerable players.
Basic Anti-Cheat
Basic Anti-Cheat for your server.

WARNING: Anti-cheat will trigger on events ply.invulnerable and ply.makeinvulnerable, please read the information for server developers from below. Do not use this plugin if you don't know what to do.

Download:
- GitHub (https://github.com/Hallkezz/BasicAntiCheat)

For server developers:
Use this event to enable/disable Anti-Cheat:
Code: Lua
  1. Events:Fire( "AntiCheat", {acActive = true/false} )

Use this event to enable/disable Anti-Cheat Bullet hit check:
Code: Lua
  1. Events:Fire( "AntiCheat", {acBulletCheck = true/false} )

Use this event to enable/disable Anti-Cheat Explosion hit check:
Code: Lua
  1. Events:Fire( "AntiCheat", {acExplosionCheck = true/false} )


Example:
For example ProperPassive (https://www.jc-mp.com/forums/index.php/topic,5254.0.html) plugin...
Code: Lua
  1. function Passive:NetworkObjectValueChange(args)
  2.   if args.key == "Passive" and args.object.__type == "LocalPlayer" then
  3.     if args.value then
  4.       Game:FireEvent("ply.invulnerable")
  5.       Events:Fire( "AntiCheat", {acActive = false} )
  6.     else
  7.       Game:FireEvent("ply.vulnerable")
  8.       Events:Fire( "AntiCheat", {acActive = true} )
  9.     end
  10.   end
  11. end
Title: Re: [Release] Basic Anti-Cheat
Post by: keeri on September 16, 2019, 03:22:27 pm
the server module runs in a single instance (not per player like the client modules do), so having
Code: [Select]
self.phealth = 1on the server means it will get overwritten by each player; if you want to store values per-player, use sender:SetValue(key, value) and sender:GetValue(key). you can also use a table of player values:
Code: [Select]
self.phealth = {}

self.phealth[ sender:GetId() ] = sender:GetHealth()
but you will need to manually clear them on PlayerQuit event by setting their value to nil.

Code: [Select]
function GodCheck:CheckThisPlayer( args, sender )
self.phealth = sender:GetHealth()
if sender:GetHealth() >= self.phealth then
that's equivalent to "if true then", since you overwrite the previous value with current value before performing the checks