Jupiter_Hortenzievich Posted December 25, 2019 Share Posted December 25, 2019 This is my code, which works perfectly. It time-lapses the in-game time to the given hours and minutes, with the given speed multiplier. eg. TimeLapseAdvanceToTime(4, 45, 500) means, it will time-lapse the time to 4:45 AM, with 500x faster, than the the normal speed of game clock. It is fool-proof! procedure TimeLapseAdvanceToTime(hrs, mins, speed: cint); var wait_time: ULONG; i, j: cint; begin {Limit timelapse speed - maximum is 100x multiplier} if (speed < 1) then speed := 1 else if (speed > 1000) then speed := 1000; {Fix input data - prevent errors} if (mins > 59) then while (mins > 59) do begin dec(mins, 60); inc(hrs); end else if (mins < 0) then while (mins < 0) do begin inc(mins, 60); dec(hrs); end; if (hrs > 23) then while (hrs > 23) do dec(hrs, 24) else if (hrs < 0) then while (hrs < 0) do inc(hrs, 24); {Everything is OK - Now do the timelapse} wait_time := 2000 div speed; // In GTA V, one in-game minute is TWO seconds! i := GET_CLOCK_HOURS; j := GET_CLOCK_MINUTES; while (i <> hrs) or (j <> mins) do begin if (j > 59) then begin j := 0; inc(i); end else inc(j); if (i > 23) then begin i := 0; j := 0; end; SET_CLOCK_TIME(i, j, 0); ScriptHookVWait(wait_time); end; end; It is in Pascal. You can easily convert it into C, (cint -> int, procedure -> void. ScriptHookVWait just calls the ScriptHookV scriptWait function. inc is increase, dec is decrease) Any opinions? You can use it anywhere you want! (The ADVANCE_CLOCK_TIME_TO does not do the time-lapse!) 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