[HELP] Custom Plates Script lua file

Hi guys my server keeps crashing im trying to make a custom plates script i dont remember where i got the template i used to build this together but im trying to learn. can someone tell me what ive done wrong or can change for this to work.

here is my code below.

– Custom Cali Plates FiveM script

– Author/edited by CHAPPiE/ Hunter Reece (FiveM) ( Original other unknown >.< )

— IMAGE CONFIG HERE —

imageUrl1 = “https://i.imgur.com/TQaiSrS.png” – Custom Plate link 1.

imageUrl2 = “https://i.imgur.com/KL0In2Y.png” – Custom Plate link 2.

imageUrl3 = “https://i.imgur.com/3bp5RHP.png” – Custom Plate link 3.

imageUrl4 = “https://i.imgur.com/uEK1M5H.png” – Custom Plate link 4.

imageUrl5 = “https://i.imgur.com/utAAZoN.png” – Custom Plate link 5.

– Plate 1 –

local textureDic = CreateRuntimeTxd(‘duiTxd’)

for i = 1, 10 do

local object = CreateDui(imageUrl1, 540, 300)

_G.object = object

local handle = GetDuiHandle(object)

local tx = CreateRuntimeTextureFromDuiHandle(textureDic, 'duiTex', handle)

AddReplaceTexture('vehshare', 'plate01', 'duiTxd', 'duiTex')

end

local textureDic = CreateRuntimeTxd(‘duiTxd’)

for i = 1, 10 do

local object = CreateDui('https://i.imgur.com/Y55stjJ.png', 540, 300)-- this URL doesn't need to be edited, its the 3d texture/model for the plate.

_G.object = object

local handle = GetDuiHandle(object)

local tx = CreateRuntimeTextureFromDuiHandle(textureDic, 'duiTex', handle)

AddReplaceTexture('vehshare', 'plate01_n', 'duiTxd', 'duiTex')

end

– Plate 2 –

local textureDic = CreateRuntimeTxd(‘duiTxd’)

for i = 1, 10 do

local object = CreateDui(imageUrl2, 540, 300)

_G.object = object

local handle = GetDuiHandle(object)

local tx = CreateRuntimeTextureFromDuiHandle(textureDic, 'duiTex', handle)

AddReplaceTexture('vehshare', 'plate02', 'duiTxd', 'duiTex')

end

local textureDic = CreateRuntimeTxd(‘duiTxd’)

for i = 1, 10 do

local object = CreateDui('https://i.imgur.com/WgwZuKT.png', 540, 300)-- this URL doesn't need to be edited, its the 3d texture/model for the plate.

_G.object = object

local handle = GetDuiHandle(object)

local tx = CreateRuntimeTextureFromDuiHandle(textureDic, 'duiTex', handle)

AddReplaceTexture('vehshare', 'plate02_n', 'duiTxd', 'duiTex')

end

– Plate 3 –

local textureDic = CreateRuntimeTxd(‘duiTxd’)

for i = 1, 10 do

local object = CreateDui(imageUrl3, 540, 300)

_G.object = object

local handle = GetDuiHandle(object)

local tx = CreateRuntimeTextureFromDuiHandle(textureDic, 'duiTex', handle)

AddReplaceTexture('vehshare', 'plate03', 'duiTxd', 'duiTex')

end

local textureDic = CreateRuntimeTxd(‘duiTxd’)

for i = 1, 10 do

local object = CreateDui('https://i.imgur.com/INIaWgn.png', 540, 300)-- this URL doesn't need to be edited, its the 3d texture/model for the plate.

_G.object = object

local handle = GetDuiHandle(object)

local tx = CreateRuntimeTextureFromDuiHandle(textureDic, 'duiTex', handle)

AddReplaceTexture('vehshare', 'plate03_n', 'duiTxd', 'duiTex')

end

– Plate 4 –

local textureDic = CreateRuntimeTxd(‘duiTxd’)

for i = 1, 10 do

local object = CreateDui(imageUrl4, 540, 300)

_G.object = object

local handle = GetDuiHandle(object)

local tx = CreateRuntimeTextureFromDuiHandle(textureDic, 'duiTex', handle)

AddReplaceTexture('vehshare', 'plate04', 'duiTxd', 'duiTex')

end

local textureDic = CreateRuntimeTxd(‘duiTxd’)

for i = 1, 10 do

local object = CreateDui('https://i.imgur.com/ory14hp.png', 540, 300)-- this URL doesn't need to be edited, its the 3d texture/model for the plate.

_G.object = object

local handle = GetDuiHandle(object)

local tx = CreateRuntimeTextureFromDuiHandle(textureDic, 'duiTex', handle)

AddReplaceTexture('vehshare', 'plate04_n', 'duiTxd', 'duiTex')

end

– Plate 5 –

local textureDic = CreateRuntimeTxd(‘duiTxd’)

for i = 1, 10 do

local object = CreateDui(imageUrl5, 540, 300)

_G.object = object

local handle = GetDuiHandle(object)

local tx = CreateRuntimeTextureFromDuiHandle(textureDic, 'duiTex', handle)

AddReplaceTexture('vehshare', 'plate05', 'duiTxd', 'duiTex')

end

local textureDic = CreateRuntimeTxd(‘duiTxd’)

for i = 1, 10 do

local object = CreateDui('https://i.imgur.com/Q3uw6V7.png', 540, 300)-- this URL doesn't need to be edited, its the 3d texture/model for the plate.

_G.object = object

local handle = GetDuiHandle(object)

local tx = CreateRuntimeTextureFromDuiHandle(textureDic, 'duiTex', handle)

AddReplaceTexture('vehshare', 'plate05_n', 'duiTxd', 'duiTex')

end

what have i dont wrong…

Anyone have any ideas why this code dont work?. help with explanation would be great!

Hello HunterReece, you need to specify the real image size and not a random size (your image is in 512*256 and you specified 540*300). Have a nice day !

This seems to not work anymore. I had it for almost two years just fine. Any idea why it broke?

Because it’s a VERY bad and inefficient way to do it. Which likely causes player performance issues. It was never meant to be done. It was a bug. Here is the right way to do it;

1 Like

Thank you! Just switched over and got it working.

This is only replacing the existing 6 plates right? No more can be added than that? @Smallo