h4x7o0r Posted January 5, 2013 Author Posted January 5, 2013 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)
Castillo Posted January 5, 2013 Posted January 5, 2013 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 )
h4x7o0r Posted January 5, 2013 Author Posted January 5, 2013 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.
Castillo Posted January 5, 2013 Posted January 5, 2013 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 )
h4x7o0r Posted January 6, 2013 Author Posted January 6, 2013 thank you so much it's working perfect. I'm getting some random mta crashed idk what's the cause. Is there any way how can i find what exactly it's causing the crash ?
Sex* Posted January 23, 2013 Posted January 23, 2013 With this i can load the original infernus.dff and infernus.txd at OnclientResourceStart also?
Castillo Posted January 23, 2013 Posted January 23, 2013 Yes, the same functions are used for skins/weapons/vehicles.
h4x7o0r Posted January 28, 2013 Author Posted January 28, 2013 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.
Sex* Posted February 10, 2013 Posted February 10, 2013 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)
Castillo Posted February 10, 2013 Posted February 10, 2013 You can't load a file outside resources folder.
Sex* Posted February 10, 2013 Posted February 10, 2013 You can't load a file outside resources folder. Why not? FFS server and some other servers load my custom GTA infernus.dff and infernus.txd wheels on map starting.
Castillo Posted February 10, 2013 Posted February 10, 2013 Well, they didn't load it, they restored the original model ( in this case, your modded one ).
Sex* Posted February 11, 2013 Posted February 11, 2013 Well, why not this doesnt work? function ResetModel ( ) engineRestoreModel ( 411 ) end addEvent ( "restoreClientModel", true ) addEventHandler ( "restoreClientModel", getRootElement(), ResetModel ) addEventHandler("onClientMapStarting",getRootElement(), ResetModel)
Castillo Posted February 11, 2013 Posted February 11, 2013 You set it as client side? what's the problem?
Sex* Posted February 12, 2013 Posted February 12, 2013 You set it as client side? what's the problem? clientside yeah, problem is that it just doesnt work.
Castillo Posted February 12, 2013 Posted February 12, 2013 Try checking if the function is actually being executed by adding an outputChatBox.
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