<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Tren</id>
	<title>Multi Theft Auto: Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Tren"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/wiki/Special:Contributions/Tren"/>
	<updated>2026-04-29T05:42:32Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=EngineReplaceModel&amp;diff=36573</id>
		<title>EngineReplaceModel</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=EngineReplaceModel&amp;diff=36573"/>
		<updated>2013-07-09T09:03:07Z</updated>

		<summary type="html">&lt;p&gt;Tren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Client function}}&lt;br /&gt;
{{Note box|Please note the loading order that is used in the examples as other orders can cause textures, collisions or the DFF not to load due to technical limitations}}&lt;br /&gt;
&lt;br /&gt;
This function replaces the given model in the given model ID with the DFF file passed. This function supports vehicles and objects at the moment.&lt;br /&gt;
&lt;br /&gt;
As of 1.1.1 This supports Ped and Weapon models. For replace weapon models you can't use weapon ID's, you should use object ID's. All weapon model ID's here: [[Weapons]].&lt;br /&gt;
&lt;br /&gt;
Note: Due to a bug, when replacing models with built in collisions (i.e. vehicles), the collision may not get replaced correctly. The current work around is to load the dff again and do another replace after a short delay.&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool engineReplaceModel ( dff theModel, int modelID [, bool alphaTransparency = false ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''theModel:''' The model to replace the given model ID with&lt;br /&gt;
*'''modelID:''' The model it to replace the model of&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
*'''alphaTransparency:''' Set to true to enable special thing&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the model was successfully replaced, ''false'' if it failed for some reason, ie. the DFF or the model ID is not valid.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
'''Example 1:'''&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
Client-Side example for replacing vehicle model and texture with custom ones.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function ReplaceVehicle ( )&lt;br /&gt;
outputChatBox ( &amp;quot;&amp;gt; replacing the euros vehicle&amp;quot; )&lt;br /&gt;
&lt;br /&gt;
txd = engineLoadTXD ( &amp;quot;data/euros.txd&amp;quot; )&lt;br /&gt;
engineImportTXD ( txd, 587 )&lt;br /&gt;
dff = engineLoadDFF ( &amp;quot;data/euros.dff&amp;quot;, 587 )&lt;br /&gt;
engineReplaceModel ( dff, 587 )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEvent ( &amp;quot;replaceVeh&amp;quot;, true )&lt;br /&gt;
addEventHandler ( &amp;quot;replaceVeh&amp;quot;, getRootElement(), ReplaceVehicle )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
Server-side example function for triggering the replace.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function ReplaceCommand ( )&lt;br /&gt;
triggerClientEvent( &amp;quot;replaceVeh&amp;quot;, getRootElement(), replaceVeh )&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler( &amp;quot;replace&amp;quot;, ReplaceCommand )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 2:'''&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
Client-Side example for replacing object model, collision and texture with custom ones.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function ReplaceObject ( )&lt;br /&gt;
&lt;br /&gt;
txd = engineLoadTXD( &amp;quot;MyModel.txd&amp;quot; )&lt;br /&gt;
col = engineLoadCOL( &amp;quot;MyModel.col&amp;quot; )&lt;br /&gt;
dff = engineLoadDFF( &amp;quot;MyModel.dff&amp;quot;, 0 ) --modelid is everytime 0, when you replace no vehicle&lt;br /&gt;
&lt;br /&gt;
engineImportTXD( txd, 1234 )&lt;br /&gt;
engineReplaceCOL( col, 1234 )&lt;br /&gt;
engineReplaceModel( dff, 1234 )-- replace the model at least&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEvent ( &amp;quot;replaceObj&amp;quot;, true )&lt;br /&gt;
addEventHandler ( &amp;quot;replaceObj&amp;quot;, getRootElement(), ReplaceObject )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
Server-side example function for triggering the replace.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function ReplaceCommand ( )&lt;br /&gt;
triggerClientEvent( &amp;quot;replaceObj&amp;quot;, getRootElement(), replaceObj )&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler( &amp;quot;replace&amp;quot;, ReplaceCommand )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Engine_functions}}&lt;/div&gt;</summary>
		<author><name>Tren</name></author>
	</entry>
</feed>