Jump to content

[Help] Disable and Enable txd


Recommended Posts

Posted

So I created some vgncarshade1 (road) textures and landjump (ramp)

The thing is, I want to put a option ''When the player press a button, lets say ''F3'' and then, the Texture should be disabled

I tried with

bindKey( 'F3', 'down', 
    function( ) 
        state = not state 
        if state then 
            destroyElement( txd ) 
            outputChatBox( '#ffcc00[MSG]: #c0c0c0Road texture disabled!', 255,255,255,true ) 
        else 
            txd = engineLoadTXD( 'vgncarshade1.txd', 3458 ) 
            engineImportTXD( txd, 3458 ) 
            outputChatBox( '#ffcc00[MSG]: #c0c0c0Road texture enabled!', 255,255,255,true ) 
        end 
    end 
)   

It's not disabling the txd, only restarting it. ;c

Posted

Try this:

local state = false 
bindKey( 'F3', 'down', 
    function( ) 
        state = not state 
        local value = _G[ "engine" .. (state and "RestoreModel" or "LoadTXD") ]( (state and 3458 or 'vgncarshade1.txd'), not state and 3458 ) 
        if isElement(value) then engineImportTXD( value, 3458 ) end 
        outputChatBox( '#ffcc00[MSG]: #c0c0c0Road texture '.. (state and "disabled" or "enabled")..'!', 255,255,255,true ) 
    end 
) 

Please do not PM me with scripting related question nor support, use the forums instead.

Posted
Try this:
local state = false 
bindKey( 'F3', 'down', 
    function( ) 
        state = not state 
        local value = _G[ "engine" .. (state and "RestoreModel" or "LoadTXD") ]( (state and 3458 or 'vgncarshade1.txd'), not state and 3458 ) 
        if isElement(value) then engineImportTXD( value, 3458 ) end 
        outputChatBox( '#ffcc00[MSG]: #c0c0c0Road texture '.. (state and "disabled" or "enabled")..'!', 255,255,255,true ) 
    end 
) 

Well It's not working As it should, It disables and enables the roads when I turn 2 roads on and disable one, But after I reconnect it's only restarting the roads. It types '''road texture disabled and ''road ''texture enabled'' but It's not working :cc*

Posted

Replace destroyElement() with engineRestoreModel()

local state = false 
  
bindKey( 'F3', 'down', 
    function( ) 
        if state then 
            engineRestoreModel (3458) 
            outputChatBox( '#ffcc00[MSG]: #c0c0c0Road texture disabled!', 255,255,255,true ) 
            state = false 
        else 
            txd = engineLoadTXD( 'vgncarshade1.txd', 3458 ) 
            engineImportTXD( txd, 3458 ) 
            state = true 
            outputChatBox( '#ffcc00[MSG]: #c0c0c0Road texture enabled!', 255,255,255,true ) 
        end 
    end 
)   
  
  

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

It's still not removing. Sry, I'm noob scripter but Is that lua file correct?

function replace () 
txd = engineLoadTXD ("vgncarshade1.txd") 
engineImportTXD( txd , 3458) 
  
dff = engineLoadDFF ("vgncarshade1.dff", 0 ) 
engineReplaceModel( dff ,3458) 
  
end 
addEventHandler("onClientResourceStart",getRootElement(), replace) 
  
local state = false 
  
bindKey( 'F3', 'down', 
    function( ) 
        if state then 
            engineRestoreModel (3458) 
            outputChatBox( '#ffcc00[MSG]: #c0c0c0Road texture disabled!', 255,255,255,true ) 
            state = false 
        else 
            txd = engineLoadTXD( 'vgncarshade1.txd', 3458 ) 
            engineImportTXD( txd, 3458 ) 
            state = true 
            outputChatBox( '#ffcc00[MSG]: #c0c0c0Road texture enabled!', 255,255,255,true ) 
        end 
    end 
)   
  

I got only this, and the meta.xml

Posted

try this:

local state = true     
bindKey( 'F3', 'down', 
    function( ) 
        if state then 
            engineRestoreModel (3458); 
            outputChatBox( '#ffcc00[MSG]: #c0c0c0Road texture disabled!', 255,255,255,true ); 
            state = false; 
        else 
            dff = engineLoadDFF("vgncarshade1.dff", 3458); -- dff file. 
            engineReplaceModel(dff, 3458); 
            txd = engineLoadTXD( 'vgncarshade1.txd', 3458 ); 
            engineImportTXD( txd, 3458 ); 
            state = true; 
            outputChatBox( '#ffcc00[MSG]: #c0c0c0Road texture enabled!', 255,255,255,true ); 
        end 
    end 
)   

Inactivo.

Posted
try this:
local state = true     
bindKey( 'F3', 'down', 
    function( ) 
        if state then 
            engineRestoreModel (3458); 
            outputChatBox( '#ffcc00[MSG]: #c0c0c0Road texture disabled!', 255,255,255,true ); 
            state = false; 
        else 
            dff = engineLoadDFF("vgncarshade1.dff", 3458); -- dff file. 
            engineReplaceModel(dff, 3458); 
            txd = engineLoadTXD( 'vgncarshade1.txd', 3458 ); 
            engineImportTXD( txd, 3458 ); 
            state = true; 
            outputChatBox( '#ffcc00[MSG]: #c0c0c0Road texture enabled!', 255,255,255,true ); 
        end 
    end 
)   

Still the same

Posted

engineLoadTXD and engineImportTXD must be called before.

Also, engineLoadTXD and engineLoadDFF has only the first argument.

  
local state 
addEventHandler( "onClientResourceStart", resourceRoot, 
    function() 
        replaceTexture() 
        state = true 
    end 
) 
  
function replaceTexture() 
    engineImportTXD( engineLoadTXD("vgncarshade1.txd"), 3458 ) 
    engineReplaceModel( engineLoadDFF("vgncarshade1.dff"), 3458 ) 
end 
  
bindKey( 'F3', 'down', 
    function( ) 
        if state then 
            engineRestoreModel(3458) 
        else 
            replaceTexture() 
        end 
        outputChatBox( '#ffcc00[MSG]: #c0c0c0Road texture '..(state and 'disabled' or 'enabled')..'!', 255,255,255,true ) 
        state = not state 
    end 
) 
  

Try it.

Please do not PM me with scripting related question nor support, use the forums instead.

Posted
engineLoadTXD and engineImportTXD must be called before.

Also, engineLoadTXD and engineLoadDFF has only the first argument.

  
local state 
addEventHandler( "onClientResourceStart", resourceRoot, 
    function() 
        replaceTexture() 
        state = true 
    end 
) 
  
function replaceTexture() 
    engineImportTXD( engineLoadTXD("vgncarshade1.txd"), 3458 ) 
    engineReplaceModel( engineLoadDFF("vgncarshade1.dff"), 3458 ) 
end 
  
bindKey( 'F3', 'down', 
    function( ) 
        if state then 
            engineRestoreModel(3458) 
        else 
            replaceTexture() 
        end 
        outputChatBox( '#ffcc00[MSG]: #c0c0c0Road texture '..(state and 'disabled' or 'enabled')..'!', 255,255,255,true ) 
        state = not state 
    end 
) 
  

Try it.

It didn't workd. But I found a function that worked

function() 
if ( guiCheckBoxGetSelected (txdModCheckBox) ) then 
txd = engineLoadTXD ( "RoadTexture/vgncarshade1.txd" ) 
engineImportTXD ( txd, 3458 ) 
else 
destroyElement(txd, 3458)    

Thanks for the spending time. :)

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