Jump to content

[Help] Vehicle Custom Paintjob


Recommended Posts

Hello, I am trying to make a custom paintjobs system for each vehicle but I have a problem, when loading it with the following event it is placed in all vehicles, how could I make it only be put the one with number 3 in a table of the database.


Client side : 

function applyTexturesVeh(customtextureveh,vehicle)
if customtextureveh == -1 then
    myTexture = dxCreateTexture( "texturescustom/-1.png" )
    elseif customtextureveh == 1 then
    myTexture = dxCreateTexture( "texturescustom/1.png" )
    elseif customtextureveh == 2 then
    myTexture = dxCreateTexture( "texturescustom/2.png" )
    elseif customtextureveh == 3 then
    myTexture = dxCreateTexture( "texturescustom/3.png" )
    elseif customtextureveh == 4 then
    myTexture = dxCreateTexture( "texturescustom/4.png" )
    else
    return
    end
    engineRemoveShaderFromWorldTexture ( shader_cars, "vehiclegrunge256", vehicle )
    shader_cars, tec = dxCreateShader ( "texturescustom/Paintjob.fx" )
    engineApplyShaderToWorldTexture ( shader_cars, "vehiclegrunge256", vehicle )
    dxSetShaderValue ( shader_cars, "import_texture", myTexture ) 
end
addEvent( "texturesVeh", true )
addEventHandler( "texturesVeh", getLocalPlayer(), applyTexturesVeh )


 



Server side : 

function applyTexturesVeh(vehicle)

   

    local sql = exports.sql:query_assoc_single("SELECT customtexturevehicles FROM vehicles WHERE vehicleID = "..tostring(getElementData(vehicle, "idveh")))
    if sql then
        if sql.customtexturevehicles and tonumber(sql.customtexturevehicles) >= 0 then
            triggerClientEvent (getRootElement(),"texturesVeh", getRootElement(),tonumber(sql.customtexturevehicles) )
        end
    end
    return true
end


 

It works, but it applys to all cars, help please, and thank you in advance guys

(I want to apply the shader to the car what it have the number 3 in the database)
 

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