Mos

Replacing textures dynamically

Recommended Posts

I'm trying to replace the texture of the decals (created using addDecal), for example: blood, mud, dirt decals. and replace these with custom images i have in a .ytd in a dlc file. i can draw the images to screen. but not on decals.
I'am creating the decals, but when i change decal texture, it disappears. So it makes me think if changing textures in rage requires restarting the game? if that's the case, is there any other ways of achieving this ?

my code:

if (!mp.game.graphics.hasStreamedTextureDictLoaded("myCustomDecals"))
  mp.game.graphics.requestStreamedTextureDict("myCustomDecals", true)

function addDecal (pos, decalType,  width = 1, height = 1, R = 1,G = 1,B = 1,A = 1, timeout = 50) {
  return mp.game.graphics.addDecal(decalType, pos.x, pos.y, pos.z, 0,0,-1, 0,1,0, width, height, R,G,B,A, timeout, false, false, false)
}
// pos = Vector in front of the player
let decal = addDecal(pos, 1010, 100, 100, 0.1,0.1,0.1,1)
// CHANGE_DECAL_TEXTURE native
mp.game.invoke('0x8A35C742130C6080', 1010, 'myCustomDecals', 'decal1')
mp.gui.chat.push('Decal Added: '+ decal)
mp.gui.chat.push('is decal alive: ' +mp.game.invoke('0xC694D74949CAFD0C', decal))

// marker for reference
marker = mp.markers.new(0, pos, 0.15, {
  direction: new mp.Vector3(),
  rotation: new mp.Vector3(),
  color: [255,255,255,255],
  visible: true,
  dimension: player.dimension
})

 

Share this post


Link to post
Share on other sites

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.