!#DesTroyeR_,)

[HELP] Weapon Paintjob

Recommended Posts

Hello everyone , today i'm trying to do weapon paintjob

and i added a custom weapon of m4 

and i wanna to added paintjob with shader substitute for txd

, i have a problem , the weapon paint job is not shows

when i added the shader to object it running , 

but when i trying to added it to my hand is not running !

code :

local myShader_raw_data = [[
    texture tex;
    technique replace {
        pass P0 {
            Texture[0] = tex;
        }
    }
]]

local myShader6 = dxCreateShader(myShader_raw_data) -- create shader from raw data
local myTexture6 = dxCreateTexture("image5.png") -- create texture from image file
engineApplyShaderToWorldTexture(myShader6, "hk416_d")
dxSetShaderValue(myShader6, "tex", myTexture6)

pic :

unknown.png?width=787&height=442

Share this post


Link to post

If I had a resource, then it would be possible to test. And so, most likely, you will have to create weapon objects separately and synchronize the paintjob for each player to an individual weapon object.

Share this post


Link to post

You have to apply the shader to the player element.

local myShader_raw_data = [[
    texture tex;
    technique replace {
        pass P0 {
            Texture[0] = tex;
        }
    }
]]

local myShader6 = dxCreateShader(myShader_raw_data, 0, 0, false, "ped") -- create shader from raw data
local myTexture6 = dxCreateTexture("image5.png") -- create texture from image file
engineApplyShaderToWorldTexture(myShader6, "hk416_d", localPlayer)
dxSetShaderValue(myShader6, "tex", myTexture6)

 

Share this post


Link to post

I made script a long time ago. I've tried to apply shader on weapon in different ways but got nothing. Weapons you holding are not actually objects (for some reason) and that's pretty annoying sometimes. Anyway i solved that problem:

1. I replace weapon with custom dff and txd with transparent texture. (You can see it in video below at the beginning. Replacing provides correct muzzle offset for custom weapon);
2. I replace 1 random object (not weapon) with my weapon's dff and txd normally;
3. When ped gets ak47 (weapon) i create shader with texture replacement, apply it on my object (not ped) and use render target as texture;
4. When i switch to ak47 i attach weapon to player's hand (using bone_attach resource) and remove it if i switch to another weapon;
5. I use render targets so i can easily redraw the texture and that's it.

 

Edited by JeViCo
more details added

Share this post


Link to post
13 hours ago, Castillo said:

You have to apply the shader to the player element.


local myShader_raw_data = [[
    texture tex;
    technique replace {
        pass P0 {
            Texture[0] = tex;
        }
    }
]]

local myShader6 = dxCreateShader(myShader_raw_data, 0, 0, false, "ped") -- create shader from raw data
local myTexture6 = dxCreateTexture("image5.png") -- create texture from image file
engineApplyShaderToWorldTexture(myShader6, "hk416_d", localPlayer)
dxSetShaderValue(myShader6, "tex", myTexture6)

 

how can i type command in F8 

and the shader start to only me

and all players can saw it ?

Share this post


Link to post
1 hour ago, !#DesTroyeR_,) said:

how can i type command in F8 

and the shader start to only me

and all players can saw it ?

You need to deal with arrays.

Share this post


Link to post

@JeViCo The weapon somehow belongs to the ped, so you can just apply the shader to the ped element using the weapon texture name, here's an example of this working:
bdls6H8.png

 

@!#DesTroyeR_,) You will have to make a system which syncs the paintjob equipped on each player, then apply it when the player streams in, and remove it when the player streams out.
You can use either element data or events to sync each player's paintjob.

Share this post


Link to post
1 minute ago, Castillo said:

@JeViCo The weapon somehow belongs to the ped, so you can just apply the shader to the ped element using the weapon texture name, here's an example of this working:
bdls6H8.png

 

@!#DesTroyeR_,) You will have to make a system which syncs the paintjob equipped on each player, then apply it when the player streams in, and remove it when the player streams out.
You can use either element data or events to sync each player's paintjob.

yep , i wanna to do like this

but i can't do it because I don't understand the Shaders

Share this post


Link to post

You already have the shader code above, all you have to do now is create a system to sync which paintjob(s) the player has currently equipped.

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.