Open DBotThePony opened 4 years ago
Also this should be removed https://github.com/RafaelDeJongh/cap/blob/master/lua/autorun/swep_fix.lua
Client calls :PrimaryAttack() until it works out all prediction issues. It is called once or two times with low ping, and multiple times with high ping. Such "fix" applied by file above almost completely ruin prediction.
Isn't this issue only with CAP SWEP's? Or affect others? Anyway it is pretty old code and maybe someone can review it, removing is bad idea because we might got much more issues.
it affects ALL SWEPs installed on server.
I think if we will remove that then it will break most of cap weapons, unless this bug was fixed in gmod. So i'm not sure what to do.
This is not a bug, this is how things are supposed to be (server call predicted hooks once, client call them as much as needed to close gap between server and client state).
From my own testing i found out that only some weapons are lacking proper prediction, most notably wraith hands.
If you want your logic to be executed only once on clientside realm on primary/secondary fire, use IsFirstTimePredicted() global function.
Can you please say me if its caused by exactly math.randomseed usages in cap or sbep_fix.lua file? How you are checking this?
I mean which command you used to display those cubes like on screen, because i tried some from this page, but didn't got anything like this.
local sv_showimpacts = CreateConVar("sv_showimpacts", 0, FCVAR_REPLICATED, "Shows client (red) and server (blue) bullet impact point", 0, 3)
local sv_showimpacts_time = CreateConVar("sv_showimpacts_time", 4, FCVAR_REPLICATED, "How long to show bullet impact points for.", 1, 10)
local colorServer = Color(0, 0, 255, 127)
local colorClient = Color(255, 0, 0, 127)
local mins, maxs = Vector(-2, -2, -2), Vector(2, 2, 2)
if CLIENT then
net.Receive("sv_showimpacts", function()
debugoverlay.Box(Vector(net.ReadDouble(), net.ReadDouble(), net.ReadDouble()), mins, maxs, sv_showimpacts_time:GetFloat(), colorServer, true)
end)
else
util.AddNetworkString("sv_showimpacts")
end
hook.Add("EntityFireBullets", "showimpacts", function(pEntity, bulletInfo)
if !IsFirstTimePredicted() then
return
end
if sv_showimpacts:GetBool() then
local originalCallback = bulletInfo.Callback
bulletInfo.Callback = function(entity, trace, dmgInfo)
if originalCallback then
originalCallback(entity, trace, dmgInfo)
end
local impacts = sv_showimpacts:GetInt()
if SERVER and (impacts == 1 or impacts == 3) then
if game.SinglePlayer() then
debugoverlay.Box(trace.HitPos, mins, maxs, sv_showimpacts_time:GetFloat(), colorServer, true)
else
net.Start("sv_showimpacts", true)
net.WriteDouble(trace.HitPos.x)
net.WriteDouble(trace.HitPos.y)
net.WriteDouble(trace.HitPos.z)
net.Broadcast()
end
elseif CLIENT and (impacts == 1 or impacts == 2) then
debugoverlay.Box(trace.HitPos, mins, maxs, sv_showimpacts_time:GetFloat(), colorClient)
end
end
return true
end
end)
in autorun
I think if we will remove that then it will break most of cap weapons, unless this bug was fixed in gmod. So i'm not sure what to do.
Cause complete desync between client and server With CAP installed:
Without CAP installed:
https://wiki.facepunch.com/gmod/math.randomseed
Please use
util.SharedRandom
: https://wiki.facepunch.com/gmod/util.SharedRandom