Jump to content

Replace txd/dff issue


h4x7o0r

Recommended Posts

Posted

I wanna change some txds and some dffs so i'm using the following script :

replaceobjects.lua

function replace () 
txd = engineLoadTXD ("vgncarshade1.txd") 
engineImportTXD(txd, 3458) 
end 
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()), replace) 

and meta.xml:

<meta> 
    <script src="replaceobjects.lua" type="client" /> 
    <file src="vgncarshade1.txd" /> 
</meta> 

This is working very well but i have some problems with wheels. After the resource is starting, on some maps when the modified wheel is present it doesn't show my new wheel. If i'm restarting the map , the wheel is replaced with the new one. I think some maps have some "default" wheels loaded.

Is there any way how can i force the server to show my new wheels when a new map is starting ? What should i modify for that ?

Thanks in advance.

Posted

I've tried to replace it but now it doesn't work anymore. No errors but not loaded.

LE: This way ?

addEventHandler("onClientResourceStart",getRootElement(), replace) 
addEventHandler("onClientMapStarting",getRootElement(), replace) 

Posted
addEvent("onClientMapStarting",true) 
  
function replace () 
txd = engineLoadTXD ("vgncarshade1.txd") 
engineImportTXD(txd, 3458) 
end 
addEventHandler("onClientResourceStart",resourceRoot, replace) 
addEventHandler("onClientMapStarting",root,replace) 

  • 4 weeks later...
Posted

I didn't want to start a new topic so i've edited this one.

How can i modify this script to turn on/off some txd/dff (just like a toggle) ?

For example: to use "M" to turn on / off road texture and model.

Posted
local enabled = false 
  
function replace() 
txd = engineLoadTXD ("vgncarshade1.txd") 
engineImportTXD(txd, 3458) 
enabled = true 
end 
addEventHandler("onClientResourceStart",resourceRoot, replace) 
addEvent("onClientMapStarting",true) 
addEventHandler("onClientMapStarting",root,replace) 
  
bindKey("m", "down", 
function () 
     if (not enabled) then 
          destroyElement(txd) 
          enabled = false 
     else 
          replace() 
          enabled = true 
     end 
end) 

Try that.

Posted
local state = { } 
  
bindKey( "m","down", 
    function( ) 
        local txd 
        state[ localPlayer ] = not state[ localPlayer ] 
        local State = state[ localPlayer ] 
        if State then 
            txd = engineLoadTXD ( "vgncarshade1.txd" ) 
            engineImportTXD( txd, 3458 ) 
        else 
            destroyElement( txd ) 
            txd = nil 
        end  
    end 
)    

Posted

Thank you for reply guys. Solid's script it looks like it's working but when u restart the map 2 times it comes to default. for example : I wanna put this toggle for wheels (dff and txd). If I press "M" i need to restart the map .. to load new wheels. Same if i wanna roll back to the stock model. But when I start again that map it comes back to stock wheels :(

Kenix - it says Bad argument @ destroy element.

LE : I've just seen that it on solid's variant it says something like :

Bad 'element' pointer @ at 'destroy element'(1)

Posted

Oh my bad.I create small mistake :(

Tested

local state = { } 
local txd 
  
bindKey( "m","down", 
    function( ) 
        state[ localPlayer ] = not state[ localPlayer ] 
        local State = state[ localPlayer ] 
        if State then 
            txd = engineLoadTXD ( "vgncarshade1.txd" ) 
            engineImportTXD( txd, 3458 ) 
        else 
            destroyElement( txd ) 
        end  
    end 
)    
  

Posted

There is no need to use a table, since this is client side.

local enabled = false 
local txd 
  
bindKey( "m","down", 
    function( ) 
        if not enabled then 
            txd = engineLoadTXD ( "vgncarshade1.txd" ) 
            engineImportTXD( txd, 3458 ) 
        else 
            destroyElement( txd ) 
        end 
        enabled = not enabled 
    end 
)   
  

Posted

Thank you very much guys. JR10 variant is working very well. I really appreciate your help.

PS. I've also added 2 outputChatBox to show the state (if it's enable or disable). As i know, txd/dff replacement can't be made without starting the next map. Is there any possibility that the change to be applied right after the button was pressed ? (i don't know, maybe the resource to be reloaded or something like this).

Thank you again to all that helped me.

  • 1 month later...
Posted

How can i use multiple txd's, dff's and other stuff like this using a single resource ?

for example

local enabled = false 
  
bindKey( "m","down", 
    function( ) 
        if not enabled then 
         
txd100 = engineLoadTXD("rims.txd", 1075) 
engineImportTXD(txd100, 1075) 
  
dff100 = engineLoadDFF("wheel_sr6.dff", 1073 )  
engineReplaceModel(dff100, 1073) 
  
dff101 = engineLoadDFF("wheel_sr3.dff", 1074 )  
engineReplaceModel(dff101, 1074) 
  
       else 
            destroyElement( txd100 ) 
            destroyElement( dff100 ) 
            destroyElement( dff101 ) 
        end 
        enabled = not enabled 
    end 
)   
  

if I wanna add 15 more dff's how can i group it or how can be modified (sometimes is giving me crash on server )? :/

Posted

Try this:

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 
) 

Posted

I've test it for 5 minutes and it's working very well. Thank you very much again Solidsnake14.

I'll post the feedback (i'm curious if i'll still receive this MTA Crash like before. usually somewhere between 30-45 minutes of playing)

Posted

It looks like the problem with crash still persists. I'm suspecting this resource because if I don't press "M" to activate the new wheels, everything's fine, no crash or other things like this. Very strange.

  • 2 weeks later...
Posted

As i know DKR it's already dead (just tell me if i'm wrong). They keep releasing patches but this problem still persists. I'm really curious if someone else tested this script (for about 30 min) and can tell me if it's crashing or not MTA. (I don't know but could be a .dff problem for some wheel model). Thank you for your reply guys.

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...