Animated Liveries

Hello there,

I am trying to currently make a animated livery for my BMW, problem being that the code i am using won’t work, i have next to no experience in LUA,

Could someone tell me what i am doing wrong?

Here is the code:

local txd = CreateRuntimeTxd(‘duiTxd’)
local duiObj = CreateDui(‘http://i.imgur.com/bvhD7sq.gif’, 640, 360)
_G.duiObj = duiObj
local dui = GetDuiHandle(duiObj)
local tx = CreateRuntimeTextureFromDuiHandle(txd, ‘duiTex’, dui)
AddReplaceTexture(‘635’, ‘635’, ‘duiTxd’, ‘duiTex’)

5 Likes

(BUMP) I’ve tried experimenting with a different vehicle,

Here is the script that i tried

‘’
local loaded = false

function loadTxd()
local txd = CreateRuntimeTxd(‘duiTxd’)
local duiObj = CreateDui(‘http://i.imgur.com/bvhD7sq.gif’, 640, 360)
_G.duiObj = duiObj
local dui = GetDuiHandle(duiObj)
local tx = CreateRuntimeTextureFromDuiHandle(txd, ‘duiTex’, dui)
AddReplaceTexture(‘origTxd’, ‘orginTxn’, ‘duiTxd’, ‘duiTex’)

end

Citizen.CreateThread(function()
while loaded == false do
Wait(0)
local playerCar = GetVehiclePedIsIn(GetPlayerPed(-1))
if playerCar ~= 0 then
if GetEntityModel(playerCar) == GetHashKey(‘lamboMurcielago’) then
loadTxd()
loaded = true
end
end
if not loaded then
local veh = nil
for veh in EnumerateVehicles() do
if GetEntityModel(playerCar) == GetHashKey(‘lamboMurcielago’) then
loadTxd()
loaded = true
break
end
end
end
end
end)
‘’

BUMP still no progress.

You need to replace the texture name inside the .ytd file of your choice. Having the car name is not enough.

For example, I will use a ambulance I have on my server. The ambulance .ytd file is named ‘f450ambo.ytd’.

Open IV .ytd file

Opening it up in OpenIV, I would be looking to replace its livery with a animated file. So I look for its ‘_sign’ file, for me, its sign is ‘f450ambo_sign_1’.

Sign found in OpenIV

In order for my texture to be replaced, the code would be as follows:

    local txd = CreateRuntimeTxd('duiTxd')
    local duiObj = CreateDui('https://media3.giphy.com/media/TJb0yO9rhndYF3RJKi/source.gif', 600, 600)
    _G.duiObj = duiObj
    local dui = GetDuiHandle(duiObj)
    local tx = CreateRuntimeTextureFromDuiHandle(txd, 'duiTex', dui)
    AddReplaceTexture('f450ambo', 'f450ambo_sign_1', 'duiTxd', 'duiTex')

And with that I have a animated livery on my ambulance. Just make sure you open the .ytd and find the name of the texture you want to replace. You cannot just use the name of the .ytd like your example shows. It must be the actual texture name inside the dictionary.

5 Likes

I am going to try this out, and if it works, i am going to cry, Thank you so much john

1 Like

I know it seems like a big ask, but could you send me the resource that makes the animated livery work? Not the car, just the lua or what ever it is?

For testing purposes, just use a command for now. Put this in a client file

RegisterCommand('txanim', function(source, args, raw)
    local txd = CreateRuntimeTxd('duiTxd')
    local duiObj = CreateDui('https://media3.giphy.com/media/TJb0yO9rhndYF3RJKi/source.gif', 600, 600)
    _G.duiObj = duiObj
    local dui = GetDuiHandle(duiObj)
    local tx = CreateRuntimeTextureFromDuiHandle(txd, 'duiTex', dui)
    AddReplaceTexture('carsname', 'carsname_sign_1', 'duiTxd', 'duiTex')
end)

Replace the ‘carsname’ with your variables, and then once you spawn the car and put on its livery, run the command and you should see the change.

Ok done, I’ve loaded the same as what you’ve pasted and obvs changed the name etc, and i am trying it on a police mustang, ill let you know if i get it working, Thank you in advance.

I did it, and it didnt work on my end,


Thats what i did, i went into the YTD and found the sign with the livery, does it have to have more than 1 livery?

My bad i was being dumb, i apologise.

https://gyazo.com/80a2f9b255505de2c5135af222878071 Thank you @Xilophinum

No problem, have fun!

Hey guys. I’m trying to do this and it keeps giving me an error on line 5. Or what seems like one at least. Not sure what I am doing wrong here. This is the car I’m using https://www.lcpdfr.com/downloads/gta5mods/vehiclemodels/28530-non-els-2019-zr1-corvette-rb-bb-fivem-ready/ The all blue lights

Hello can you send me the client.lua and fxmanifest.lua idk what should i put in fxmanifest @Warpoet2272

1 Like

same here please

How can I make it so that everyone can see it? other people don’t see it, just using the / txanim command

Send an event to the server and trigger a -1 client event so all clients see the replaced texture.

--client.lua
RegisterCommand("txanim",function()
    TriggerServerEvent("replace-texture-server")
end)

RegisterNetEvent("replace-texture-client")
AddEventHandler("replace-texture-client",function()
    local txd = CreateRuntimeTxd('duiTxd')
    local duiObj = CreateDui('https://media3.giphy.com/media/TJb0yO9rhndYF3RJKi/source.gif', 600, 600)
    _G.duiObj = duiObj
    local dui = GetDuiHandle(duiObj)
    local tx = CreateRuntimeTextureFromDuiHandle(txd, 'duiTex', dui)
    AddReplaceTexture('f450ambo', 'f450ambo_sign_1', 'duiTxd', 'duiTex')
end)
--server.lua
RegisterServerEvent("replace-texture-server")
AddEventHandler("replace-texture-server", function()
    TriggerClientEvent("replace-texture-client", -1)
end)

Fxmanifest information is in the fivem docs. Search how to set it up.

Im guessing it’ll be

Manifest verion

Games

Client script

Server script

Files

Sorry, i haven’t been on the forums for so long, I will release my version with a text based tutorial sometime today or tomorrow.

How should I apply this file?

Isn’t it written like this?