irinel1996

[HELP]Replace car paintjobs?

Recommended Posts

Hi!

I have some txd files, with paintjobs.

But I don't know how to replace them because I don't know the IDs of the PJs.

For example jester1.txd is a paintjob, but how replace it. What's the model (ID) of it? :roll:

Well...

Thanks all!

Share this post


Link to post

You need the ID of the vehicle in this case, which for the Jester is 559. You can use this link to look up vehicle IDs. You can use the examples on the wiki such as the ones explaining EngineLoadTXD to create your script.

You may also want to look at the Introduction to Scripting if you haven't already.

Share this post


Link to post

I am not sure if it is possible to modify paintjobs though, i tried it sometime back; I THINK.

Share this post


Link to post

I suppose it depends if the existing DFF has the right mapping to allow the paintjob to be applied directly (thus you'd need to add the other vehicle textures to the paintjob TXD) or if GTA has some special inbuilt support for it. If not, you could probably change the DFF to accept that, although paintjobs might then become universal since you'd be forcing the same modified DFF for everyone. I've never tried modifying paintjobs for vehicles in MTA.

Share this post


Link to post

You would have to apply the paintjobs manually. So you would have to load the paintjob txds all at once at the beginning, and later on import the txd when your paintjob changes. Since I just realised paintjobs are nothing more than just another texture for the same vehicle.

Share this post


Link to post

Yes, but a paintjob TXD only contains the paintjob, not any of the other stuff. So if you forced a TXD replacement of the paintjob over the vehicle's existing TXD, indeed the paintjob may become visible but all of the other textures (seats, dashboard, engine compartment, underside etc) would be white. That was why I suggested that it may be necessary to add all those textures to the paintjob TXD. And that still wouldn't change universal replacement.

Share this post


Link to post

Oh ok ^_^ I thought it contained all the other stuff (seats, dashboard, engine compartment, underside etc [yes i copied from ur post]) too... You could use dxCreateTexture and apply stuff through images..but that is kinda advanced.. I don't know how to use it.

Share this post


Link to post

Replacing the paintjobs does work, subenji99 did it. HOWEVER the paintjob id's are NOT the vehicle ID's.

You need to use the new replacing shader functions.

for the life of me i dont know how its done, (benji did it) but i do know our textures are just .png images.

For example "elegy2.txd" as its called in the gta3.img, with just the texture extracted to .png is: elegy2body256.png

then you replace "elegy2body256" with that somehow in shaders (someone who knows will be able to help you with that)

and TADA! custom paintjob.

Doing it this way ONLY replaces the SINGLE paintjob. Not all 3.

t_mta-screen_2011-09-05_20-55-05.png

tn_mta-screen_2011-09-13_00.jpg

  • Thanks 1

Share this post


Link to post

Yes, it's possible by way of shaders in MTA 1.1. Here is the shader fx code you need (provided with no restrictions by Gamesnert):

texture gTexture; 
  
technique TexReplace 
{ 
    pass P0 
    { 
        Texture[0] = gTexture; 
    } 
} 

As you can see, all it does is substitute the texture it would have used for the one you provide.

In lua, you use it like so:

addEventHandler( "onClientResourceStart", resourceRoot, 
    function() 
     
        texture = dxCreateTexture ( "path/to/imagename.png/.jpg/.bmp" ) 
        shader, tec = dxCreateShader( "texturereplaceshader.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 
) 

dxCreateTexture is quite versatile for what filetypes it will take, but it will not accept txd files, and the files given should be in sizes of a power of 2. (1,2,4,8,16,32,64,128,256...) If you don't want a texture to be stretched/cropped, it should match the size of the texture you're replacing.

You can call the shader file whatever you want, as long as it's referenced correctly in the code and the meta.xml. Use the tag.

The internal texture file name can be retrieved in one of 2 ways: the 'hard' way of calling http://wiki.multitheftauto.com/wiki/Eng ... xtureNames and trying to identify which one in the list you are after,

or how DazzaJay hinted at above, open the relevant TXD file in an editor and see what the filename is for the texture you want to replace. Don't append an extension.

The dxSetShaderValue line actually passes the texture data to the shader. If you want an animated texture, you can keep calling this function. (this is what Gamesnert's nyancat resource does) the "gTexture" string is a reference to the texture variable defined in the shader file.

Remember to also send your clients the image file! Again, use the tag.

common names for car paintjobs:

body256

e.g.:

elegy2body256

flash3body256

jester1body256

stratum2body256

sultan2body256

Share this post


Link to post

You can use shader_tex_names (thanks ccw) to find texture names to use with engineApplyShaderToWorldTexture.

You can download it from the wiki.

Share this post


Link to post

in theory this doesnt even replace a single paintjob, ~100(probably less)lines of script, and you could make infinite ammount of paintjobs qunique for each vehicle, without replacing a single PJ id.

some more fancy scripting and nfs style strechable/cropable/zoomable stickers could be made.

probably even bump mapping textures(bump mapping shader isn't that advanced) could make infinite ammount of possible body tuning.

Share this post


Link to post

Indeed, the shader can be applied/unapplied at will to control whether the texture is replaced or not, and shaders can do a whole lot more than just basic texture replacement!

Share this post


Link to post
probably even bump mapping textures(bump mapping shader isn't that advanced)

*Waits to see someone make a rusty car script, where the rust is actually rough by way of bumpmapping :-P

Share this post


Link to post
Is there any paintjob for cheetah, turismo, infernus ?

Not by default, but there are mods about, some on gtaworldmods.de that have paintjobable cars, but thats a dff replacement.

Share this post


Link to post

Thanks for your reply guys, yeah i know that i can modify using dff /txd but that's no good for players because they need to download some huge packs of data when they come for the first time.

Edited by Guest

Share this post


Link to post

You want huge chunk, the Initial D server we have yet to update, now that's a huge download, 14 custom high poly cars, 2 ENTIRE MOUNTIAN racetracks, that's 130MB.

Some people can download it in a matter of seconds, some people cant.

Don't worry about the size, well, do worry about the size, but try to keep it under 5MB. - even then some impatient 13 year old ADHD sufferers will still bitch about it taking so long, but that's their problem.

Share this post


Link to post

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.