[HELP] Need help with AddReplaceTexture

Hi everyone, i’m trying to do a thing with AddReplaceTexture. I’m currently creating a menu to swap between various Esc Map textures (Atlas, satellite ecc). The problem is that after the textures have been replaced (Working without problem), after a while (random, it can be 2 seconds or 10 minutes) the textures will be replaced with the basic one (In this case the atlas with was streamed with the name minimap_0_0.ytd, …). I tried everything, even removing all the other resources and leaving this one only, but the problem is still here. I also opted for a while loop replacing textures every 500ms, but apparently the textures are replaced when the user opens the Esc Map, so for like 500ms you can still see the base map. Another negative point of the while loop is that it will cost resources talking about resmon. So my questions are:

  • Is this a common problem with AddReplaceTextures?
  • Is there a way to fix the problem with other natives or with a specific parameter?
  • Are there other ways or solutions to change the current texture during runtime without having this problem?

Stream directory structure

[stream] -|
|-[Atlas]-|
|---minimap_0_0.ytd
|---minimap_0_1.ytd
|---minimap_1_0.ytd
|---minimap_1_1.ytd
|---minimap_2_0.ytd
|---minimap_2_1.ytd
|-[Satellite]-|
|---minimap_0_0_satellite.ytd
|---minimap_0_1_satellite.ytd
|---minimap_1_0_satellite.ytd
|---minimap_1_1_satellite.ytd
|---minimap_2_0_satellite.ytd
|---minimap_2_1_satellite.ytd

client.lua

function replace_escmap(dict_type, HideNotify)
    local file_list = {
        'minimap_0_0',
        'minimap_0_1',
        'minimap_1_0',
        'minimap_1_1',
        'minimap_2_0',
        'minimap_2_1',
        'minimap_sea_0_0',
        'minimap_sea_0_1',
        'minimap_sea_1_0',
        'minimap_sea_1_1',
        'minimap_sea_2_0',
        'minimap_sea_2_1',
    }

    if not dict_type or dict_type == '' then
        for k, v in pairs(file_list) do
            local dict = v
            wait_for_texture_dict(dict)
            AddReplaceTexture(v, v, dict, v)
            if debug then
                print("[ESCMAP] Replacing texture (" .. dict .. " -> " .. v .. "): " .. v)
            end
        end
    else
        for k, v in pairs(file_list) do
            local dict = v .. '_' .. dict_type
            wait_for_texture_dict(dict)
            AddReplaceTexture(v, v, dict, v)
            if debug then
                print("[ESCMAP] Replacing texture (" .. dict .. " -> " .. v .. "): " .. v)
            end
        end
    end

    if not HideNotify then
        -- Map loaded successfully notification
        ESX.ShowNotification("Mappa caricata con successo!", 'success')
    end
end

Thanks in advance for the help!

1 Like

I managed to solve it with other types of replacetexture but unfortunately there doesn’t seem to be a solution for the minimap

1 Like