EngineReplaceCOL: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Example is already complete.)
 
(12 intermediate revisions by 8 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Client function}}<!-- Change this to "Client function" or "Server function" appropriately-->
{{Client function}}
<!-- Describe in plain english what this function does. Don't go into details, just give an overview -->
{{Note|Please note the loading order that is used in the examples as other orders can cause collisions, textures or the DFF not to load due to technical limitations}}
 
This function replaces the collision file of the given model id to the collision file passed. Use [[engineLoadCOL]] to load the collision file first.
This function replaces the collision file of the given model id to the collision file passed. Use [[engineLoadCOL]] to load the collision file first.
{{Note|Collision libraries (.col files containing multiple collision models) are not supported. See [[COL]] for details. Object models are supported only (no vehicles or players).}}


==Syntax==  
==Syntax==  
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd -->
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool engineReplaceCOL ( col theCol, int modelID )
bool engineReplaceCOL ( col theCol, int modelID )
</syntaxhighlight>  
</syntaxhighlight>  
 
{{OOP||[[COL|col]]:replace}}
===Required Arguments===  
===Required Arguments===  
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type -->
*'''theCol:''' The collision file to replace with
*'''theCol:''' The collision file to replace with
*'''modelID:''' The model ID whose collision file you want to replace
*'''modelID:''' The model ID whose collision file you want to replace


===Returns===
===Returns===
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check -->
Returns ''true'' if the collision was successfully replaced, ''false'' or ''nil'' if the collision could not be replaced for a reason.
Returns ''true'' if the collision was successfully replaced, ''false'' or ''nil'' if the collision could not be replaced for a reason.


==Example==  
==Example==
<section name="Client" class="client" show="true">
See [https://wiki.multitheftauto.com/wiki/EngineReplaceModel#Example unified example available in engineReplaceModel.]
Client-Side example for replacing object collision with custom one.
<syntaxhighlight lang="lua">
function ReplaceCollision ( )
outputChatBox ( "> Replacing Collision Data." )
col = engineLoadCOL( "myColFile.col" )
engineReplaceCOL( col, 3356 )
end
 
addEvent ( "collisionReplace", true )
addEventHandler ( "collisionReplace", getRootElement(), ReplaceCollision )
</syntaxhighlight>
</section>
 
 
<section name="Server" class="server" show="true">
Server-side example function for triggering the replace.
<syntaxhighlight lang="lua">
function ReplaceCols ( )
triggerClientEvent ( "collisionReplace", getRootElement(), collisionReplace )
end
addCommandHandler("replacecol", ReplaceCols)
</syntaxhighlight>
</section>


==See Also==
==See Also==
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc -->
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc -->
{{Engine_functions}}
{{Engine_functions}}

Latest revision as of 21:35, 29 April 2024

[[{{{image}}}|link=|]] Note: Please note the loading order that is used in the examples as other orders can cause collisions, textures or the DFF not to load due to technical limitations

This function replaces the collision file of the given model id to the collision file passed. Use engineLoadCOL to load the collision file first.

[[{{{image}}}|link=|]] Note: Collision libraries (.col files containing multiple collision models) are not supported. See COL for details. Object models are supported only (no vehicles or players).

Syntax

bool engineReplaceCOL ( col theCol, int modelID )

OOP Syntax Help! I don't understand this!

Method: col:replace(...)


Required Arguments

  • theCol: The collision file to replace with
  • modelID: The model ID whose collision file you want to replace

Returns

Returns true if the collision was successfully replaced, false or nil if the collision could not be replaced for a reason.

Example

See unified example available in engineReplaceModel.

See Also