Jump to content

two questions


Dirk

Recommended Posts

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...