Charlie_Jefferson Posted January 2, 2012 Share Posted January 2, 2012 function replacevehs () dustertxd = engineLoadTXD ( "txd/rancher.txd" ) engineImportTXD ( dustertx, 489 ) dusterdff = engineLoadDFF ( "dff/rancher.dff", 489 ) engineReplaceModel ( dusterdff, 489 ) d1310txd = engineLoadTXD( "txd/admiral.txd" ) engineImportXD ( d1310txd, 445 ) d1310dff = engineLoadDFF ( "dff/admiral.dff", 445 ) engineReplaceModel ( d1310dff, 445 ) bmwm5e34txd = engineLoadTXD ( "txd/sentinel.txd" ) engineImportTXD ( bmwm5e34txd, 405 ) bmwm5e34dff = engineLoadDFF ( "dff/sentinel.dff", 405 ) engineReplaceModel ( bmwm5e34dff, 405 ) trabant601txd = engineLoadTXD ( "txd/stallion.txd" ) engineImportTXD ( trabant601txd, 439 ) trabant601dff = engineLoadDFF ( "dff/stallion.dff", 439 ) engineReplaceModel ( trabant601dff, 439 ) rangerovertxd = engineLoadTXD ( "txd/huntley.txd" ) engineImportTXD ( rangerovertxd, 579 ) rangeroverdff = engineLoadDFF ( "dff/huntley.dff", 579 ) engineReplaceModel ( rangeroverdff, 579 ) reginatxd = engineLoadTXD ( "txd/regina.txd" ) engineImportTXD ( reginatxd, 479 ) reginadff = engineLoadDFF ( "dff/regina.dff", 479 ) engineReplaceModel ( reginadff, 479 ) perentxd = engineLoadTXD ( "txd/peren.txd" ) engineImportTXD ( perentxd, 404 ) perendff = engineLoadDFF ( "dff/peren.dff", 404 ) engineReplaceModel ( perendff, 404 ) comettxd = engineLoadTXD ( "txd/comet.txd" ) engineImportTXD ( comettxd, 480 ) cometdff = engineLoadDFF ( "dff/comet.dff", 480 ) engineReplaceModel ( cometdff, 480 ) clubtxd = engineLoadTXD ( "txd/club.txd" ) engineImportTXD ( clubtxd, 589 ) clubdff = engineLoadDFF ( "dff/club.dff", 589 ) engineReplaceModel ( clubdff, 589 ) buffalotxd = engineLoadTXD ( "txd/buffalo.txd" ) engineImportTXD ( buffalotxd, 402 ) buffalodff = engineLoadDFF ( "dff/buffalo.dff", 402 ) engineReplaceModel ( buffalodff, 402 ) end addEventHandler("onClientPlayerJoin", root, replacevehs) I've got a problem with this code. I want to replace some vehicles dff's and txd's, but unfortunately it won't work. The sources are added in the meta.xml(file src="blabla"), so I've got no idea why it won't work. Link to comment
Castillo Posted January 2, 2012 Share Posted January 2, 2012 "onClientPlayerJoin" is triggered when a player joins, but doesn't work for the player who just joined ( the client ), use "onClientResourceStart" instead. function replacevehs () dustertxd = engineLoadTXD ( "txd/rancher.txd" ) engineImportTXD ( dustertx, 489 ) dusterdff = engineLoadDFF ( "dff/rancher.dff", 489 ) engineReplaceModel ( dusterdff, 489 ) d1310txd = engineLoadTXD( "txd/admiral.txd" ) engineImportXD ( d1310txd, 445 ) d1310dff = engineLoadDFF ( "dff/admiral.dff", 445 ) engineReplaceModel ( d1310dff, 445 ) bmwm5e34txd = engineLoadTXD ( "txd/sentinel.txd" ) engineImportTXD ( bmwm5e34txd, 405 ) bmwm5e34dff = engineLoadDFF ( "dff/sentinel.dff", 405 ) engineReplaceModel ( bmwm5e34dff, 405 ) trabant601txd = engineLoadTXD ( "txd/stallion.txd" ) engineImportTXD ( trabant601txd, 439 ) trabant601dff = engineLoadDFF ( "dff/stallion.dff", 439 ) engineReplaceModel ( trabant601dff, 439 ) rangerovertxd = engineLoadTXD ( "txd/huntley.txd" ) engineImportTXD ( rangerovertxd, 579 ) rangeroverdff = engineLoadDFF ( "dff/huntley.dff", 579 ) engineReplaceModel ( rangeroverdff, 579 ) reginatxd = engineLoadTXD ( "txd/regina.txd" ) engineImportTXD ( reginatxd, 479 ) reginadff = engineLoadDFF ( "dff/regina.dff", 479 ) engineReplaceModel ( reginadff, 479 ) perentxd = engineLoadTXD ( "txd/peren.txd" ) engineImportTXD ( perentxd, 404 ) perendff = engineLoadDFF ( "dff/peren.dff", 404 ) engineReplaceModel ( perendff, 404 ) comettxd = engineLoadTXD ( "txd/comet.txd" ) engineImportTXD ( comettxd, 480 ) cometdff = engineLoadDFF ( "dff/comet.dff", 480 ) engineReplaceModel ( cometdff, 480 ) clubtxd = engineLoadTXD ( "txd/club.txd" ) engineImportTXD ( clubtxd, 589 ) clubdff = engineLoadDFF ( "dff/club.dff", 589 ) engineReplaceModel ( clubdff, 589 ) buffalotxd = engineLoadTXD ( "txd/buffalo.txd" ) engineImportTXD ( buffalotxd, 402 ) buffalodff = engineLoadDFF ( "dff/buffalo.dff", 402 ) engineReplaceModel ( buffalodff, 402 ) end addEventHandler("onClientResourceStart", resourceRoot, replacevehs) Link to comment
Kenix Posted January 2, 2012 Share Posted January 2, 2012 Charlie_Jefferson,You can also replace with timer: function replacevehs () dustertxd = engineLoadTXD ( "txd/rancher.txd" ) engineImportTXD ( dustertx, 489 ) dusterdff = engineLoadDFF ( "dff/rancher.dff", 489 ) engineReplaceModel ( dusterdff, 489 ) d1310txd = engineLoadTXD( "txd/admiral.txd" ) engineImportXD ( d1310txd, 445 ) d1310dff = engineLoadDFF ( "dff/admiral.dff", 445 ) engineReplaceModel ( d1310dff, 445 ) bmwm5e34txd = engineLoadTXD ( "txd/sentinel.txd" ) engineImportTXD ( bmwm5e34txd, 405 ) bmwm5e34dff = engineLoadDFF ( "dff/sentinel.dff", 405 ) engineReplaceModel ( bmwm5e34dff, 405 ) trabant601txd = engineLoadTXD ( "txd/stallion.txd" ) engineImportTXD ( trabant601txd, 439 ) trabant601dff = engineLoadDFF ( "dff/stallion.dff", 439 ) engineReplaceModel ( trabant601dff, 439 ) rangerovertxd = engineLoadTXD ( "txd/huntley.txd" ) engineImportTXD ( rangerovertxd, 579 ) rangeroverdff = engineLoadDFF ( "dff/huntley.dff", 579 ) engineReplaceModel ( rangeroverdff, 579 ) reginatxd = engineLoadTXD ( "txd/regina.txd" ) engineImportTXD ( reginatxd, 479 ) reginadff = engineLoadDFF ( "dff/regina.dff", 479 ) engineReplaceModel ( reginadff, 479 ) perentxd = engineLoadTXD ( "txd/peren.txd" ) engineImportTXD ( perentxd, 404 ) perendff = engineLoadDFF ( "dff/peren.dff", 404 ) engineReplaceModel ( perendff, 404 ) comettxd = engineLoadTXD ( "txd/comet.txd" ) engineImportTXD ( comettxd, 480 ) cometdff = engineLoadDFF ( "dff/comet.dff", 480 ) engineReplaceModel ( cometdff, 480 ) clubtxd = engineLoadTXD ( "txd/club.txd" ) engineImportTXD ( clubtxd, 589 ) clubdff = engineLoadDFF ( "dff/club.dff", 589 ) engineReplaceModel ( clubdff, 589 ) buffalotxd = engineLoadTXD ( "txd/buffalo.txd" ) engineImportTXD ( buffalotxd, 402 ) buffalodff = engineLoadDFF ( "dff/buffalo.dff", 402 ) engineReplaceModel ( buffalodff, 402 ) end setTimer( replacevehs,1000,1 ) Link to comment
Charlie_Jefferson Posted January 2, 2012 Author Share Posted January 2, 2012 I thought so, about the event, thanks. I'll test it soon. Edit: It doesn't work. The script loads fine, but the cars won't change to the DFF's and TXD's defined by the script. Link to comment
JR10 Posted January 2, 2012 Share Posted January 2, 2012 Any errors shown in /debugscript 3? Link to comment
Charlie_Jefferson Posted January 2, 2012 Author Share Posted January 2, 2012 No. None there, none in console. Link to comment
mjau Posted January 3, 2012 Share Posted January 3, 2012 trigger it with a timer to delay it a bit... Link to comment
Charlie_Jefferson Posted January 5, 2012 Author Share Posted January 5, 2012 This is the meta. <meta> <info author="Charlie" type="script" description="Replace vehicles with Romanian cars :o"/> <script src="rvhs.lua" type="client"/> <file src="txd/stallion.txd" type="client"/> <file src="dff/stallion.dff" type="client"/> <file src="dff/huntley.dff" type="client"/> <file src="txd/huntley.txd" type="client"/> <file src="txd/sentinel.txd" type="client"/> <file src="dff/sentinel.dff" type="client"/> <file src="dff/regina.dff" type="client"/> <file src="txd/regina.txd" type="client"/> <file src="txd/peren.txd" type="client"/> <file src="dff/peren.dff" type="client"/> <file src="dff/comet.dff" type="client"/> <file src="txd/comet.txd" type="client"/> <file src="dff/club.dff" type="client"/> <file src="txd/club.txd" type="client"/> <file src="dff/buffalo.dff" type="client"/> <file src="txd/buffalo.txd" type="client"/> <file src="dff/admiral.dff" type="client"/> <file src="txd/admiral.txd" type="client"/> </meta> Link to comment
Discord Moderators Zango Posted January 5, 2012 Discord Moderators Share Posted January 5, 2012 You've a typo in the script. engineImportTXD ( dustertx, 489 ) > engineImportTXD ( dustertxd, 489 ) Try this: local vehicleReplacements = { [489] = {txd = 'txd/rancher.txd', dff = 'dff/rancher.dff'}, [445] = {txd = 'txd/admiral.txd', dff = 'dff/admiral.dff'} } function replaceVehicles () for model,replacementData in pairs(vehicleReplacements) do local txd = engineLoadTXD (replacementData.txd) if txd then engineImportTXD (txd, model) end local dff = engineLoadDFF (replacementData.dff, model) if dff then engineReplaceModel (dff, model) end end end addEventHandler ('onClientResourceStart', resourceRoot, replaceVehicles) addCommandHandler ('repveh', replaceVehicles) Add your remaining replacements to the vehicleReplacements table Link to comment
Charlie_Jefferson Posted January 5, 2012 Author Share Posted January 5, 2012 Thanks Zango, but I'd rather keep my code, which I know how it's working, rather then copying an unknown code. I just need to get this working. Link to comment
Castillo Posted January 5, 2012 Share Posted January 5, 2012 Zango's code is A LOT more efficient than yours, you should use his. P.S: It's also a lot easier to add new entries. Link to comment
Discord Moderators Zango Posted January 5, 2012 Discord Moderators Share Posted January 5, 2012 Was more like restructuring of your script, but that's alright. If there are no errors in debugscript and no vehicles are replaced it's most likely not calling the function. Try putting an outputChatBox or outputDebugString call in the top of your replacement function to check it. Link to comment
Charlie_Jefferson Posted January 5, 2012 Author Share Posted January 5, 2012 I think it's something wrong in the meta.xml. Do the DFF's and TXD's new a type = client? Link to comment
mjau Posted January 5, 2012 Share Posted January 5, 2012 Do this instead files shouldnt have any type defined... Edit: Look at this ... https://wiki.multitheftauto.com/wiki/Meta.xml Link to comment
Charlie_Jefferson Posted January 6, 2012 Author Share Posted January 6, 2012 I edited it and took the type part out. The vehicles are still not replaced... This is stressing me out. The script has no errors and it should work, although it doesn't. Help please. Link to comment
Discord Moderators Zango Posted January 7, 2012 Discord Moderators Share Posted January 7, 2012 Type argument doesn't matter. It could also be that your custom vehicles are invalid. Please .zip your resource (including files) and upload it somewhere. Link to comment
Charlie_Jefferson Posted January 7, 2012 Author Share Posted January 7, 2012 Uploaded the .zip file. http://www.mediafire.com/?yssu1ezwihte62e Link to comment
Discord Moderators Zango Posted January 7, 2012 Discord Moderators Share Posted January 7, 2012 First off, your script is invalid (and differs) from all the examples you've posted here. I don't know why you edited it, but opening debugscript 3 should tell you what's wrong. You simply can't use an if statement like that. I suggest you try the Scripting Introduction at the wiki, to get a basic grasp of Lua. 1) Remove the if statement. 2) Line 2 & 5 (rancher.txd/rancher.dff) those files are invalid. 3) Line 7 contains a typo as highlighted below: 'engineImport ( d1310txd, 445 ) ' Attempt to call a nil value (engineImportXD) makes the script yield error, which means stop in programming terms. When a script is stopped like that, the rest of the file isn't processed (and nothing is replaced). It has been mentioned several times to use debugscript, and I'll mention it once again: Use debugscript! It puts all errors and warnings in this neat box at the bottom of your screen. Here is the corrected version of your rvhs.lua file. Link to comment
Charlie_Jefferson Posted January 7, 2012 Author Share Posted January 7, 2012 Uh. About the If statement, wanted to test something and forgot to take it off. :3 I know how to script and I've read the scripting introduction. I've scripted for a server too. What's invalid with the rancher.txd and rancher.dff? I've checked debugscript too, before adding the if statement and nothing was wrong. Thank you for editing the script. Edit: It works, but I still don't get what "Rancher.txd/rancher.dff are invalid.". I understand their invalid but what does invalid mean? 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