Jump to content

Replace txd/dff issue


h4x7o0r

Recommended Posts

How can i modify this to be enabled by default (for example when resource starts wheels with new textures to be shown).

In this state, it's working but u need to press the "m" key to toggle it on.

Here's the working script (solidsnake14 variant):

  
    local enabled = false 
      
    local files = 
        { 
            { name = "rims", model = 1075}, 
            { name = "wheel_sr6", model = 1075}, 
            { name = "wheel_sr3", model = 1075}, 
        } 
    local filesLoaded = { } 
      
    bindKey( "m", "down", 
        function ( ) 
            if not enabled then 
                for index, file in ipairs ( files ) do 
                    filesLoaded[index] = { } 
                    
                    filesLoaded[index].txd = engineLoadTXD( file.name ..".txd", file.model ) 
                    engineImportTXD(filesLoaded[index].txd, file.model ) 
      
                    filesLoaded[index].dff = engineLoadDFF( file.name ..".dff", file.model ) 
                    engineReplaceModel(filesLoaded[index].dff, file.model ) 
                end 
           else           
                for index, file in ipairs ( filesLoaded ) do 
                    destroyElement( file.txd ) 
                    destroyElement( file.dff ) 
                end 
            end 
            enabled = not enabled 
        end 
    ) 
  

I think i should add this, but i'm not sure how exactly :

  
   addEventHandler( "onClientResourceStart", resourceRoot, 
        function() 
    end) 
  

Link to comment
local files = 
    { 
        { name = "rims", model = 1075 }, 
        { name = "wheel_sr6", model = 1075 }, 
        { name = "wheel_sr3", model = 1075 }, 
    } 
  
addEventHandler ( "onClientResourceStart", resourceRoot, 
    function ( ) 
        for index, file in ipairs ( files ) do 
            engineImportTXD ( engineLoadTXD ( file.name ..".txd", file.model ), file.model ) 
            engineReplaceModel ( engineLoadDFF ( file.name ..".dff", file.model ), file.model ) 
        end 
    end 
) 

Link to comment

Thank you very much again for all your help.

In your script i've seen that the toggle has been removed. I'm having problem in implementing it back. because i wanna have the toggle but when the resource starts to be activated by default. So if I want to to turn it off, i should press the "m" key.

Thank you again and sorry for not being that explicit.

Link to comment
local enabled = false 
  
local files = 
    { 
        { name = "rims", model = 1075 }, 
        { name = "wheel_sr6", model = 1075 }, 
        { name = "wheel_sr3", model = 1075 }, 
    } 
local filesLoaded = { } 
  
bindKey( "m", "down", 
    function ( ) 
        if not enabled then 
            for index, file in ipairs ( files ) do 
                filesLoaded[index] = { } 
                
                filesLoaded[index].txd = engineLoadTXD( file.name ..".txd", file.model ) 
                engineImportTXD(filesLoaded[index].txd, file.model ) 
  
                filesLoaded[index].dff = engineLoadDFF( file.name ..".dff", file.model ) 
                engineReplaceModel(filesLoaded[index].dff, file.model ) 
            end 
       else           
            for index, file in ipairs ( filesLoaded ) do 
                destroyElement( file.txd ) 
                destroyElement( file.dff ) 
            end 
        end 
        enabled = not enabled 
    end 
) 
  
addEventHandler ( "onClientResourceStart", resourceRoot, 
    function ( ) 
        for index, file in ipairs ( files ) do 
            for index, file in ipairs ( files ) do 
                filesLoaded[index] = { } 
                
                filesLoaded[index].txd = engineLoadTXD( file.name ..".txd", file.model ) 
                engineImportTXD(filesLoaded[index].txd, file.model ) 
  
                filesLoaded[index].dff = engineLoadDFF( file.name ..".dff", file.model ) 
                engineReplaceModel(filesLoaded[index].dff, file.model ) 
            end 
        end 
    end 
) 

Link to comment
  • 3 weeks later...

So yeah looks like now i'm having a really strange problem. The toggle it's working very well, it's autostarting the textures when player connect but the problem is with reconnecting. For example: I log in to the server everything's fine. without pressing the toggle button i'm tryin to reconnect. After resources are loaded , the mta's crashing. I tried different ways to replicate this problem, it's only present at player reconnect. I've noticed that if u are playing on the server and then are u going for some time to another server , when u are coming back to the first server , mta's crashing. I think it's smth with cache or idk. maybe some files remained loaded and when u tryin to reconnect the new/same files tryin to be reloaded.

Link to comment
  • 2 weeks later...

Why this dont work? I want MTA to load infernus.dff and infernus.txd from GTA directory.

function mod() 
  txd = engineLoadTXD("infernus.txd", 411 ) 
  engineImportTXD(txd, 411) 
  dff = engineLoadDFF("infernus.dff", 411 ) 
  engineReplaceModel(dff, 411) 
end 
addEventHandler("onClientMapStarting",getResourceRootElement(getThisResource()), mod) 
addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), mod) 

Link to comment

Well, why not this doesnt work?

function ResetModel ( ) 
    engineRestoreModel ( 411 ) 
end 
  
addEvent ( "restoreClientModel", true ) 
addEventHandler ( "restoreClientModel", getRootElement(), ResetModel ) 
addEventHandler("onClientMapStarting",getRootElement(), ResetModel) 

Link to comment

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.
×
×
  • Create New...