EngineLoadIFP

From Multi Theft Auto: Wiki

This function loads an animation library (IFP) file into GTA with a custom block name. All three IFP formats are supported ANPK, ANP2, and ANP3. Unfortunately, GTA 3 animations are not supported, however, you can load GTA:VC IFP files using this function. You don't have to replace any animation to play a custom one, to play a custom animation, load the IFP file using this function, then use setPedAnimation.

If you wish to replace a GTA internal animation with a custom one, you can use engineReplaceAnimation. To unload the IFP file, use destroyElement, restarting or stopping the resource can also unload the IFP file automatically.

Syntax

ifp engineLoadIFP ( string ifp_file / string raw_data, string CustomBlockName )

Required Arguments

  • ifp_file / raw_data: the filepath to the IFP file you want to load or whole data buffer of the IFP file.
  • CustomBlockName: the new block name for the IFP file. You cannot use the GTA default internal block names. You should namespace this name using a string like resource.blockname

Returns

Returns an IFP element if the IFP file loaded, false otherwise.

[[{{{image}}}|link=]] Tip: If you want to synchronize animations, you can check [ifp_demo] resource

Example

This example loads a custom IFP file (parkour.ifp), adds a command "animation" that takes 1 parameter as animation name for playing animations within that IFP.

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

-- execute the command using /animation <NameOfCustomAnimation>
-- for example, /animation CartWheel
function setanimation( _, animationName )
    -- check if IFP file has loaded
    if IFP then
        -- now play our custom animation
        setPedAnimation( localPlayer, customBlockName, animationName )
    end
end
addCommandHandler( "animation", setanimation )

See Also

FROM VERSION 1.5.7 r19626 ONWARDS
FROM VERSION 1.5.7 r20147 ONWARDS