qbcore-framework / qb-weathersync

Weather System Used With QB-Core :sun_behind_rain_cloud:
GNU General Public License v3.0
23 stars 142 forks source link

optimize(server): fix slow loop #75

Closed EinS4ckZwiebeln closed 11 months ago

EinS4ckZwiebeln commented 1 year ago

Describe Pull request

  1. The code now waits for 1 second (1000 milliseconds) using Wait(1000). This reduces the number of iterations in the loop and makes the code more efficient.

  2. Instead of using *os.time(os.date("!t")) to calculate the current time, we can directly use os.time()**.

  3. Instead of dividing os.time() by 2 and adding 360 to get newBaseTime, we divide it by 2 and add 180. This achieves the same effect since os.time() returns the number of seconds elapsed since January 1, 1970.

  4. We update the previous variable with the current seconds (os.date("%S")) to track the change in seconds.

These optimizations make the code more streamlined and efficient while achieving the same functionality.

Questions (please complete the following information):

github-actions[bot] commented 12 months ago

This PR has had 60 days of inactivity & will close within 7 days