h4x7o0r Posted December 29, 2011 Share Posted December 29, 2011 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. Link to comment
Castillo Posted December 29, 2011 Share Posted December 29, 2011 onClientMapStarting? Link to comment
h4x7o0r Posted December 29, 2011 Author Share Posted December 29, 2011 Thankyou for reply. U mean to replace onClientResourceStart with onClientMapStarting ? Link to comment
Castillo Posted December 29, 2011 Share Posted December 29, 2011 Why not both? replace onClientResourceStart and onClientMapStarting. Link to comment
h4x7o0r Posted December 29, 2011 Author Share Posted December 29, 2011 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) Link to comment
Castillo Posted December 29, 2011 Share Posted December 29, 2011 addEvent("onClientMapStarting",true) function replace () txd = engineLoadTXD ("vgncarshade1.txd") engineImportTXD(txd, 3458) end addEventHandler("onClientResourceStart",resourceRoot, replace) addEventHandler("onClientMapStarting",root,replace) Link to comment
Faw[Ful] Posted December 29, 2011 Share Posted December 29, 2011 You can also disable the pimp car config in the race meta.XML (there is some race config , thanks for those who make them !) Link to comment
h4x7o0r Posted December 29, 2011 Author Share Posted December 29, 2011 Thank you SolidSnake14 for the script, now it's working very well. Thank you Benox.exe, i've also tried that. Link to comment
h4x7o0r Posted January 27, 2012 Author Share Posted January 27, 2012 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. Link to comment
Klesh Posted January 27, 2012 Share Posted January 27, 2012 You must to bind a key to toggle it. function () bindKey("m", "down", replace) end Link to comment
h4x7o0r Posted January 27, 2012 Author Share Posted January 27, 2012 Thank you for the reply. I've tried what u suggested but doesn't work. Link to comment
Castillo Posted January 27, 2012 Share Posted January 27, 2012 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. Link to comment
Kenix Posted January 27, 2012 Share Posted January 27, 2012 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 ) Link to comment
h4x7o0r Posted January 27, 2012 Author Share Posted January 27, 2012 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) Link to comment
Kenix Posted January 28, 2012 Share Posted January 28, 2012 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 ) Link to comment
JR10 Posted January 28, 2012 Share Posted January 28, 2012 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 ) Link to comment
h4x7o0r Posted January 29, 2012 Author Share Posted January 29, 2012 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. Link to comment
h4x7o0r Posted January 31, 2012 Author Share Posted January 31, 2012 Any ideas ? i really appreciate every info. Thank you in advance. Link to comment
h4x7o0r Posted March 9, 2012 Author Share Posted March 9, 2012 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 )? Link to comment
Castillo Posted March 9, 2012 Share Posted March 9, 2012 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 ) Link to comment
h4x7o0r Posted March 9, 2012 Author Share Posted March 9, 2012 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) Link to comment
h4x7o0r Posted March 9, 2012 Author Share Posted March 9, 2012 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. Link to comment
Faw[Ful] Posted March 9, 2012 Share Posted March 9, 2012 The system is unstable, you can try to talk with the scipters of DKR. Link to comment
h4x7o0r Posted March 18, 2012 Author Share Posted March 18, 2012 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. 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