Improving performance of resources

Hello guys,

currently I run a server with about 50 resources. Some of them very poorly scripted by myself. And therefor I guess I am experiencing some heavy spikes every now and then, mostly noticeable while driving.
Is there a resource that helps identifying which of the server’s resources have a huge impact on the game’s performance?
I’d like to keep the server as tidy and smooth as possible.

Thanks :wave:

You can open the performance tools for both client-side (F8 > Tools > Performance > Resource Monitor) or server-side (on ‘svgui’, Tools > Performance > Resource Monitor).

This will show you the time and memory it takes to run every resource.

When creating resources, make sure that you don’t run loop unless necessary. For example, infinite loop that check if a player is in range of…something… don’t need to run every frame, if the player is in the complete opposite side of the map.

Hi CritteR,

thanks for your reply :slight_smile:
Such a resource monitor would be perfect!
Unfortunately I use a very old and deprecated server version (citizenMP) and fiveM client out of 2017 which don’t seem to have these commands build in. The ‘resmon’ command doesn’t work also in the F8 console.

Therefor it would be great if there was a plugin resource monitor or something which I could start as a resource.
Other suggestions appreciated :leaves:

Cheers

Citizen.CreateThread( function()
	while true do
		Citizen.Wait(500)
		ResetPlayerStamina(PlayerId())
	end
end)

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(120000)
		local ped = PlayerPedId()
		local vehid = GetVehiclePedIsUsing(ped)
		local vehmodel = GetEntityModel(vehid)
		if vehmodel == -1066334226 or vehmodel == 771711535 or vehmodel == 1033245328 or vehmodel == 276773164 or vehmodel == 509498602 or vehmodel == 867467158 then
		SetEnableScuba(ped, true)
		SetPedMaxTimeUnderwater(ped, 400.00)
		end
	end
end)

Do you think loops like these could impair performance?

Why the hell are you even using these still? Use the newest version - those old ones can cause lag spikes, too.

I run the server in LAN only and the versions are much more convenient to set up for quick local matches with friends.
No mandatory updates and perfect portability are just two key aspects why I’m using these old versions.
I don’t recognize any spike with only the standard resources enabled so it must be a custom one that causes performance issues.
Sure, I could disable one by one to see if there’s a noticeable improvement but that’s not the most elegant and ironclad way I suppose.

Here’s a useful forum thread to read.

Thanks for the link. It provides a good summary on how to improve code. I also already came across this thread a view years ago.

What I am trying to do is to identify which resources take most of the performance. That’s the question of this thread.
How to improve these would be the next step :slight_smile:

I mean, if you FiveM version does not have resmon, it wont have the profiler, so you’re in the dark. I really, really fail to understand why you run such an old build of both the server and FiveM - there’s a whole heap of stuff that wont work on those, not to mention the lack of tools (such as resmon). IMO, you should definitely install the newest FiveM and server versions and go from there.

And you can do that with profiler and resmon. If you’re intentionally avoiding using those for whatever reason, well, that’s your issue.

Okay. Got it :handshake: