StefanKsV Posted May 31, 2015 Share Posted May 31, 2015 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 Link to comment
Enargy, Posted May 31, 2015 Share Posted May 31, 2015 destroyElement not work with that. replace engineRestoreModel instead. Link to comment
StefanKsV Posted May 31, 2015 Author Share Posted May 31, 2015 destroyElement not work with that. replace engineRestoreModel instead. Sry I'm new scripter. Can u explain me how to do it please? Link to comment
DNL291 Posted May 31, 2015 Share Posted May 31, 2015 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 ) Link to comment
StefanKsV Posted May 31, 2015 Author Share Posted May 31, 2015 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* Link to comment
StefanKsV Posted May 31, 2015 Author Share Posted May 31, 2015 There are some screenshots http://i.imgur.com/YDIHEaC.jpg http://i.imgur.com/CzF4Beh.jpg Please If someone know how to fix it, to reply.. I really need this script :c Link to comment
Walid Posted May 31, 2015 Share Posted May 31, 2015 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 ) Link to comment
StefanKsV Posted May 31, 2015 Author Share Posted May 31, 2015 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 Link to comment
Enargy, Posted May 31, 2015 Share Posted May 31, 2015 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 ) Link to comment
StefanKsV Posted May 31, 2015 Author Share Posted May 31, 2015 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 Link to comment
AboShanab Posted May 31, 2015 Share Posted May 31, 2015 Can u show my pm and add me in your skype Link to comment
DNL291 Posted June 1, 2015 Share Posted June 1, 2015 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. Link to comment
StefanKsV Posted June 1, 2015 Author Share Posted June 1, 2015 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. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now