Jump to content

[HELP] How to fix FPS drops what the script causes?


Turbesz

Recommended Posts

I have a paintjob system, and when a player choose a paintjob from the panel and then he put on the car, the all players FPS drops 10-20 always for a few seconds...

How can i fix that?

This is the add paintjob part of my code:

function addVehiclePaintjob(vehicle, paintjobID)
	if vehicle and paintjobID then
		local availablePaintjobs = getAvailablePaintjobs(getElementModel(vehicle))
		
		if availablePaintjobs[paintjobID] then
			removeVehiclePaintjob(vehicle)
			
			vehiclesWithPaintjob[vehicle] = {}
			vehiclesWithPaintjob[vehicle][1] = dxCreateShader("textureChanger.fx", 0, 100, false, "vehicle")
			vehiclesWithPaintjob[vehicle][2] = dxCreateTexture("textures/" .. availablePaintjobs[paintjobID][2])
			
			if vehiclesWithPaintjob[vehicle][1] and vehiclesWithPaintjob[vehicle][2] then
				dxSetShaderValue(vehiclesWithPaintjob[vehicle][1], "TEXTURE", vehiclesWithPaintjob[vehicle][2])
				engineApplyShaderToWorldTexture(vehiclesWithPaintjob[vehicle][1], availablePaintjobs[paintjobID][1], vehicle)
			end
		end
	end
end

 

Edited by Turbesz
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...