Jump to content

[HELP]Custom paintjob problem.


IMariukas

Recommended Posts

:arrowup: Hi, so I wanted to make a script that there spawns a car and only that car has the custom paintjob, unless I spawn more cars and let them spawn with paintjobs.

Here's my client code-

function triggerelegy() 
    triggerServerEvent(source, "elegy-spawn", source) 
end 
  
addEventHandler("onResourceStart", root, 
    function(thePlayer, theVehicle) 
            if getElementModel(elegyshark) then 
            local shader, tec = dxCreateShader ( "texreplace.fx" ) 
            local tex = dxCreateTexture ( "textures/elegy.png") 
            engineApplyShaderToWorldTexture ( shader, "elegy2body256", elegyshark )  
            engineApplyShaderToWorldTexture ( shader, "elegy2body256lod", elegyshark ) 
            dxSetShaderValue ( shader, "gTexture", tex ) 
            end 
        end 
)    

And server side script-

elegyshark =  createVehicle ( 562, 2485.1001, -1539.5, 23.6) 
setVehiclePaintjob ( elegyshark, 2 ) 
  
addEvent("elegy-spawn", true) 
addEventHandler("elegy-spawn", getRootElement(), responce) 
  

The car spawns but there is no custom paintjob on it and no ERROR shows in debugscript 3.What's the problem?

Link to comment

Actually I wanted to use createVehicle in client-side one, but I can't because the car spawns and it's freezed and you can't enter the car.So I needed to write createVehicle function in server-side.About my script, well example:

I want to make that paintjob2 that only "elegyshark" would have custom paintjob that you select on F1 paintjob the paintjob2.

Link to comment

Try this:

.fx

texture PaintjobTexture; 
  
technique vehiclePaintjobReplace 
{ 
    pass P0 
    { 
        Texture[ 0 ] = PaintjobTexture; 
    } 
} 

Client

local myShader, tec, theTexture; 
  
addEventHandler( 'onClientResourceStart', resourceRoot, 
    function( ) 
  
        -- Version check 
        if getVersion ().sortable < '1.1.0' then 
            outputChatBox( 'Resource is not compatible with this client.' ); 
            return 
        end 
  
        myShader, tec = dxCreateShader ( 'texreplace.fx', 0, 0, true, 'vehicle' ); 
  
        if not myShader then 
            outputChatBox( 'Could not create shader. Please use debugscript 3' ) 
        else 
            outputChatBox( 'Using technique [' . . tec. . ']' ); 
        end 
         
        theTexture = dxCreateTexture( 'textures/elegy.png' ); 
        dxSetShaderValue( myShader, 'PaintjobTexture', theTexture ); 
        engineApplyShaderToWorldTexture( myShader, 'elegy2body256'); 
    end 
); 

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