Jump to content

Make this more effective and compact


micheal1230

Recommended Posts

How can I make this script more compact because it is very long. It uses a shaders to replace paintjobs but since there is 3 paintjobs for each 5 cars so it I will make the script bloody huge. Is there anyway I could use a table to make the script smaller, could you maybe make it for me if not could you explain how I could make it. Thanks

Script:

  
-------------------------------------Sultan---------------------------------------------- 
addEventHandler( "onClientResourceStart", resourceRoot, 
    function() 
    
        texture = dxCreateTexture ( "sultan1.txd" ) 
        shader, tec = dxCreateShader( "shader.fx" ) 
        
        --bit of sanity checking 
        if not shader then 
            outputConsole( "Could not create shader. Please use debugscript 3" ) 
            destroyElement( texture ) 
            return 
        elseif not texture then 
            outputConsole( "loading texture failed" ) 
            destroyElement ( shader ) 
            tec = nil 
            return 
        else 
            engineApplyShaderToWorldTexture ( shader, "internalfilenamewithoutextension" ) 
            dxSetShaderValue ( shader, "gTexture", texture ) 
        end 
        
    end 
) 
addEventHandler( "onClientResourceStart", resourceRoot, 
    function() 
    
        texture = dxCreateTexture ( "sultan2.txd" ) 
        shader, tec = dxCreateShader( "shader.fx" ) 
        
        --bit of sanity checking 
        if not shader then 
            outputConsole( "Could not create shader. Please use debugscript 3" ) 
            destroyElement( texture ) 
            return 
        elseif not texture then 
            outputConsole( "loading texture failed" ) 
            destroyElement ( shader ) 
            tec = nil 
            return 
        else 
            engineApplyShaderToWorldTexture ( shader, "internalfilenamewithoutextension" ) 
            dxSetShaderValue ( shader, "gTexture", texture ) 
        end 
        
    end 
) 
addEventHandler( "onClientResourceStart", resourceRoot, 
    function() 
    
        texture = dxCreateTexture ( "sultan3.txd" ) 
        shader, tec = dxCreateShader( "shader.fx" ) 
        
        --bit of sanity checking 
        if not shader then 
            outputConsole( "Could not create shader. Please use debugscript 3" ) 
            destroyElement( texture ) 
            return 
        elseif not texture then 
            outputConsole( "loading texture failed" ) 
            destroyElement ( shader ) 
            tec = nil 
            return 
        else 
            engineApplyShaderToWorldTexture ( shader, "internalfilenamewithoutextension" ) 
            dxSetShaderValue ( shader, "gTexture", texture ) 
        end 
        
    end 
) 
-------------------------------------End Sultan---------------------------------------------- 

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...