self:addValidator("lagcompensation", function(context)
if context.action ~= "shoot" then
return {success = true}
end
if not context.data.targethit or not context.data.hitpos or not context.data.time then
return {success = true} -- Not a lag comp hit, skip validation
end
local playerData = context.playerData
if not playerData then
return {
success = false,
reason = "PLAYER_NOT_FOUND",
validator = "lagcompensation"
}
end
local targethit = context.data.targethit
local clientHitPos = context.data.hitpos
local shotTime = context.data.time
-- Get server's version of target position at shot time
local serverTargetPos = self.playermanager:getMovementData(targethit, shotTime)
if not serverTargetPos then
return {
success = false,
reason = "NO_MOVEMENT_DATA",
validator = "lagcompensation",
data = {
target = targethit.Name,
time = shotTime
}
}
end
local positionDifference = (serverTargetPos - clientHitPos).Magnitude
local maxTolerance = 0.15
if positionDifference > maxTolerance then
return {
success = false,
reason = "LAG_COMPENSATION_POSITION_MISMATCH",
validator = "lagcompensation",
data = {
clientPos = clientHitPos,
serverPos = serverTargetPos,
difference = positionDifference,
tolerance = maxTolerance,
target = targethit.Name
}
}
end
return {success = true}
end,true)```
im making fps system, incase theres a network latency, it validate this . i cant test it because theres low network latency in studio. it runs the validator incase it hits on the client and no on the server, yall think this will work?
#network latency
1 messages · Page 1 of 1 (latest)