Jump to content

Adding mutiple skins on one model


hyomin

Recommended Posts

I wrote a simple script which loads txd and replaces textures using shaders. Right now I'm going to sleep, in morning I'll post it here.

Here it is:

  
  
addEventHandler( "onClientResourceStart", resourceRoot, 
    function() 
     
local txd = engineLoadTXD ( "main.txd" ) 
engineImportTXD ( txd, 12990) 
  
        t_shader, tec = dxCreateShader ( "uv_scripted.fx" ) 
  
        -- Create texture and add to shader 
        if t_shader then 
        local myTexture = dxCreateTexture ( "example.png" ); 
        dxSetShaderValue ( t_shader, "CUSTOMTEX0", myTexture ); 
            else  
            return outputChatBox ("Failed to create shader!") 
        end  
         
         
        local x,y,z = getElementPosition ( localPlayer ) 
        local obj = createObject (12990,x+5,y+5,z ) -- create the object 
         
        engineApplyShaderToWorldTexture ( t_shader, "wall2", obj ) 
end 
) 
  

NOTE: This is just an example. I didn't include the dff file which is a custom object and it has a texture named "wall2". This example won't work because I have not included the dff file so replace this:

  
   engineApplyShaderToWorldTexture ( t_shader, "wall2", obj ) 
  

to

  
 engineApplyShaderToWorldTexture ( t_shader, "sw_jetty", obj )  -- this is the default txd name of this object 
  

If you're wondering if that's the case then you won't be able to use a txd file? the answer is no, YOU CAN USE IT only if you use the same TXD name for the image as default ones. If default txd name of the object is sw_jetty then you must name it to sw_jetty in txd file which you will create in TXD workshop.

Remember wall2 is the texture name I used in the main.txd file

If you're not loading a custom txd file but you simply want to replace the texture with a png or jpg texture then

check objects ide ( txd and dff names) here: https://wiki.multitheftauto.com/wiki/IDE_List

If you want try without using the main.txd file then simply remove wall2 form second arguement replace it with this: sw_jetty

This is how it should look like: engineApplyShaderToWorldTexture ( t_shader, "sw_jetty", obj )

Also remember that image you are going to insert in txd file, its size should be 256x256 or 512x512 otherwise txd file will not work

You can make your own txd file using TXD workshop, I bet you will find lots of tutorials in youtube for TXD workshop especially for MTA

I uploaded the resource to mediafire. You can download it here: http://www.mediafire.com/download/ox08p ... tatest.rar

EDIT: I forgot to add these lines in the resource but I hope you understand how it works.

  
local txd = engineLoadTXD ( "main.txd" ) 
engineImportTXD ( txd, 12990) 
  

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