Lua wrapper | Value clamp script

Hey, i need a wrapper that clamp values.
because i have problems, with people that crash our server

they set Thruster force to 9999999999999999999999
or Repositioning stuff to X=48324582357237582735 Y=…

now i will try to clamp these values **before **it reach the engine, to prevent from crash
but have no idea how…

i tried a Script from a friend… that uses Metatable to override the SetPos Function…
but after that, SetPos doesnt work anymore…


[lua]math.Clamp(val, mix, max)[/lua]

… I know how to clamp values…
but i want to clamp meta functions like SetPos ApplyForceCenter

Thats the script from my friend, it still not work…

local clamp = math.Clamp
local RSetPos = _R.Entity.SetPos
_R.Entity.SetPos = function(pos)
    local MinMax = 16384

    pos.x = clamp(pos.x,-MinMax,MinMax)
    pos.y = clamp(pos.y,-MinMax,MinMax)
    pos.z = clamp(pos.z,-MinMax,MinMax)