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????