Dirk Posted September 16, 2011 Share Posted September 16, 2011 Hello I have two questions about replacing a model. I just started playing MTA about two weeks now so I'm new to scripting. First: I can get the model to show up in the game with the collision working but when I add the texture to the code the texture wont load along with the collision so I think I'm doing something wrong in GMAX I use txdworkshop to make the TXD I took this code straight from the wiki meta.xml <meta> <info author="YourName" type="script" name="My Server" description="My first MTA DM server" /> <script src="server.lua" /> <script src="client.lua" type="client" /> <file src="Model.dff" /> <file src="Model.col" /> <file src="Model.txd" /> </meta> client.lua function ReplaceObject ( ) col = engineLoadCOL( "Model.col" ) dff = engineLoadDFF( "Model.dff", 0 ) --modelid is everytime 0, when you replace no vehicle txd = engineLoadTXD ( "Model.txd" ) engineImportTXD ( txd, 1337 ) engineReplaceCOL( col, 1337 ) engineReplaceModel( dff, 1337 )-- replace the model at least end addEvent ( "replaceObj", true ) addEventHandler ( "replaceObj", getRootElement(), ReplaceObject ) server.lua function ReplaceCommand ( ) triggerClientEvent( "replaceObj", getRootElement(), replaceObj ) end addCommandHandler( "replace", ReplaceCommand ) Second: How do I make the resource load the new models automatically when it starts I tried 'onResourceStart' and get no errors but it still wont work???? Link to comment
JR10 Posted September 16, 2011 Share Posted September 16, 2011 COL: For vehicles, please omit this function by embedding your COL file into your DFF file. This way, you can be sure that the COL file is correctly (and automatically) loaded when calling engineLoadDFF. function ReplaceObject ( ) col = engineLoadCOL( "Model.col" ) txd = engineLoadTXD ( "Model.txd" ) engineImportTXD ( txd, 1337 ) dff = engineLoadDFF( "Model.dff", 0 ) --modelid is everytime 0, when you replace no vehicle engineReplaceCOL( col, 1337 ) engineReplaceModel( dff, 1337 )-- replace the model at least end addEvent ( "replaceObj", true ) addEventHandler ( "replaceObj", getRootElement(), ReplaceObject ) DFF: To successfully load your model with textures, be sure to use engineLoadTXD and engineImportTXD before calling this function. Link to comment
Dirk Posted September 17, 2011 Author Share Posted September 17, 2011 Thanks for the reply.. The collision file works now but the texture still doesn't load.. When I try to Embed the .col in gmax I get an error '--Unable to convert: undefined to type: Integer' so I just export them separately. Link to comment
qaisjp Posted September 17, 2011 Share Posted September 17, 2011 Use collision editor. that might work Link to comment
Dirk Posted September 21, 2011 Author Share Posted September 21, 2011 I got it working now I think the problem was in TxdWorkshop in the image properties. It renames the image to whatever the file extension the image was or if you insert a template it names it the width and height of the template.So I just changes it back to what it was originally called and it works perfectly. Thank you for the reply's.. 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