Narx Posted August 31 Share Posted August 31 (edited) void ScriptMain() { while (true) { // Get Timestamp QueryPerformanceCounter(&EndingTime); ElapsedMicroseconds.QuadPart = EndingTime.QuadPart - StartingTime.QuadPart; ts = ElapsedMicroseconds.QuadPart / 10000.0; // Get Vehicle States in every 10ms if (ts >= 10.0) { GetVehicleStates(); QueryPerformanceCounter(&StartingTime); } WAIT(0) } } This is a pseudocode of my script. I want to get vehicle states in every 10ms (or ~ 100ms). But WAIT(0) function spends at least 7ms or more. So the sampling time becomes fluctuative. GTAMods Wiki says, "Without a wait, the game locks itself into processing the script and cannot process the rest of the game." (0001 - GTAMods Wiki) Is it inevitable to spend the computational time for WAIT() and can't get data from GTA V frequency-accurately in millisec scale? This graph shows the fluctuation of sampling time. (ts=100ms) Edited August 31 by Narx Link to comment Share on other sites More sharing options...
ikt Posted September 5 Share Posted September 5 The physics engine seems to also operate at the same rate as the framerate - so every "tick" (WAIT(0)) is also aligned with a frame. You could fetch information every frame and add a timestamp, or choose a sampling rate where the framerate fluctuations are not significant (10 Hz or something). Or if you fetch data directly from the vehicle object in memory, in a not-ScriptHookV-thread, you aren't limited to framerate with sampling time. But be aware the data still only updates at the framerate rate. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now