Facepunch / garrysmod-issues

Garry's Mod issue tracker
147 stars 56 forks source link

CurTime() can be inaccurate in the clientside Move hooks #6009

Closed Bonyoze closed 1 month ago

Bonyoze commented 1 month ago

Details

CurTime() will seemingly reset back to 0 at the first calls of clientside SetupMove, Move and FinishMove then jump back to its correct value at some point.

Steps to reproduce

Tested on a local dedicated server with the code loaded from lua/autorun.

if SERVER then return end

print("Initial CurTime: ", CurTime())

local i = 0
hook.Add("SetupMove", "", function()
    print("SetupMove CurTime: ", CurTime())
    i = i + 1
    if i == 100 then
        hook.Remove("SetupMove", "")
    end
end)

Initial CurTime will be correct. First calls in SetupMove will be incorrect then suddenly correct:

image

robotboy655 commented 1 month ago

Related or duplicate: https://github.com/Facepunch/garrysmod-issues/issues/3026

robotboy655 commented 1 month ago

This is just prediction system rolling back the timer. If you want to get the "real" value, you use the aptly named https://wiki.facepunch.com/gmod/Global.UnPredictedCurTime