EngineReplaceAnimation: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
(Removed warning)
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
{{Client function}}
{{New items|3.0156|1.5.6|
{{New feature/item|3.0156|1.5.5|12195|
This function replaces a specific internal (default) animation with a custom one that has been loaded using [[EngineLoadIFP|engineLoadIFP]] function. This function only affects a specific [[player]] or [[ped]], the [[Animations|internal animation]] is not replaced for everyone, for instance, different players and peds are able to have completely different crouching, walking, and fighting etc., animations running simultaneously at the same time. Also, it's not synchronized, you'll need to execute this function on every client in Lua to synchronize it.
This function replaces a specific internal (default) animation with a custom one that has been loaded using [[EngineLoadIFP|engineLoadIFP]] function. This function only affects a specific [[player]] or [[ped]], the [[Animations|internal animation]] is not replaced for everyone, for instance, different players and peds are able to have completely different crouching, walking, and fighting etc., animations running simultaneously at the same time. Also, it's not synchronized, you'll need to execute this function on every client in Lua to synchronize it.


Internal animations replaced using this function can still be played with [[SetPedAnimation|setPedAnimation]]. You can restore replaced animations back with [[EngineRestoreAnimation|engineRestoreAnimation]].
Internal animations replaced using this function can still be played with [[SetPedAnimation|setPedAnimation]]. You can restore replaced animations back with [[EngineRestoreAnimation|engineRestoreAnimation]].


It should be noted that partial animations are not supported, you can still replace them, but they won't work as intended, for example, "FightA_block" animation from "ped" block is a partial animation, you can't replace it properly, only a few animations are partial, rest of them are not, so it shouldn't be a problem.
It should be noted that partial animations are not supported, you can still replace them, but they won't work as intended, for example, "FightA_block" animation from "ped" block is a partial animation, you can't replace it properly, only a few animations are partial, rest of them are not, so it shouldn't be a problem.}}
|12213}}
 
==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
Line 23: Line 23:


==Example==
==Example==
'''Example 1:''' This example loads a custom IFP file ([https://drive.google.com/file/d/1XZNNCCn7xhBNbhaIbsBubky3BEj06zWp/view?usp=sharing parkour.ifp]), and replaces the internal crouch animation from ped block with a custom animation. If you press C on your keyboard, the custom animation will be played instead of crouch animation.
This example loads a custom IFP file ([https://drive.google.com/file/d/1XZNNCCn7xhBNbhaIbsBubky3BEj06zWp/view?usp=sharing parkour.ifp]), and replaces the internal crouch animation from ped block with a custom animation. If you press C on your keyboard, the custom animation will be played instead of crouch animation.
<section name="client.lua" class="client" show="true">
 
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--[[
--[[
Line 36: Line 36:
HandPlant
HandPlant
]]
]]


-- you can choose any name you want, do not choose a default GTA:SA block name
-- you can choose any name you want, do not choose a default GTA:SA block name
Line 42: Line 41:


-- load the IFP file
-- load the IFP file
local IFP = engineLoadIFP ( "parkour.ifp", customBlockName )
local IFP = engineLoadIFP( "parkour.ifp", customBlockName )


-- let us know if IFP failed to load
-- let us know if IFP failed to load
if not IFP then
if not IFP then
     outputChatBox ( "Failed to load 'parkour.ifp'" )
     outputChatBox( "Failed to load 'parkour.ifp'" )
end
end


-- replace the crouch animation
-- replace the crouch animation
engineReplaceAnimation ( localPlayer, "ped", "weapon_crouch", customBlockName, "HandPlant" )
engineReplaceAnimation( localPlayer, "ped", "weapon_crouch", customBlockName, "HandPlant" )
</syntaxhighlight>
</section>
<section name="meta.xml" class="server" show="true">
<syntaxhighlight lang="lua">
<meta>
    <info author="Saml1er" version="1.0.0" description="Just a simple test resource for custom ped IFP animations" />
    <file src="parkour.ifp" />
    <script src="client.lua" type="client" />
</meta>
</syntaxhighlight>
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{Engine_functions}}
{{Engine_functions}}

Latest revision as of 11:24, 7 October 2018

This function replaces a specific internal (default) animation with a custom one that has been loaded using engineLoadIFP function. This function only affects a specific player or ped, the internal animation is not replaced for everyone, for instance, different players and peds are able to have completely different crouching, walking, and fighting etc., animations running simultaneously at the same time. Also, it's not synchronized, you'll need to execute this function on every client in Lua to synchronize it.

Internal animations replaced using this function can still be played with setPedAnimation. You can restore replaced animations back with engineRestoreAnimation.

It should be noted that partial animations are not supported, you can still replace them, but they won't work as intended, for example, "FightA_block" animation from "ped" block is a partial animation, you can't replace it properly, only a few animations are partial, rest of them are not, so it shouldn't be a problem.

Syntax

bool engineReplaceAnimation ( ped thePed, string InternalBlockName, string InternalAnimName, string CustomBlockName, string CustomAnimName )

Required Arguments

  • thePed: the player or ped you want to replace an animation for.
  • InternalBlockName: the internal block name.
  • InternalAnimName: the internal animation name inside InternalBlockName.
  • CustomBlockName: the custom block name of the loaded IFP file that you passed to engineLoadIFP as second parameter.
  • CustomAnimName: the custom animation name inside the loaded IFP file with CustomBlockName.

Returns

Returns true on success, false in case of failure.

Example

This example loads a custom IFP file (parkour.ifp), and replaces the internal crouch animation from ped block with a custom animation. If you press C on your keyboard, the custom animation will be played instead of crouch animation.

--[[
credits to Paul_Cortez for the IFP file.
parkour.ifp has following animations:

BckHndSpingBTuck
BckHndSping
CartWheel
FrntHndSpring
HandPlant
]]

-- you can choose any name you want, do not choose a default GTA:SA block name
local customBlockName = "myNewBlock"

-- load the IFP file
local IFP = engineLoadIFP( "parkour.ifp", customBlockName )

-- let us know if IFP failed to load
if not IFP then
    outputChatBox( "Failed to load 'parkour.ifp'" )
end

-- replace the crouch animation
engineReplaceAnimation( localPlayer, "ped", "weapon_crouch", customBlockName, "HandPlant" )

See Also