Jump to content

How to do FPS and CPU optimized script?


Efsane

Recommended Posts

Hello guys, I am Efsane (Legend).

What I'm curious about is as I wrote in the title, but let me open it to you a little bit. In client-side or server-side scripts in MTA, sometimes rendered things decrease fps and increase cpu. I think you understand my example. What I'm wondering is how to write optimized systems without dropping fps and increasing cpu? Even if the server draws 250-300 people, the cpu value of the script should be 3

 

Link to comment
  • Moderators
5 minutes ago, Efsane said:

What I'm wondering is how to write optimized systems without dropping fps and increasing cpu?

That question can only be answered if you know why the FPS is dropping. And there are multiple reasons for.

 

A common reason:

Execution time exceeds the frame time

So even if your computer can run the game at 60 fps, if the execution time takes longer than the frame time the next frame has to wait longer and so your pc will render less frames each second.

 

And how to optimise that? Well, making sure that this does not happen with the total execution time of all render events, as (not so) simple as that.

 


 

By setting priority for 2 addEventHandlers that are attached to render events, 1 super high priority and 1 super low priority, you probably will be able to calculate the total execution time for that event.

addEventHandler( "onClientRender", root, ..., false, "high+1000" )

addEventHandler( "onClientRender", root, ..., false, "low-1000" )

 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...