EngineLoadIFP: Difference between revisions
No edit summary |
(Updated engineLoadIFP with latest syntax and example.) |
||
Line 6: | Line 6: | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
ifp engineLoadIFP ( string IfpFilePath, string CustomBlockName ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''IfpFilePath:''' the [[filepath|file path]] to the IFP file you want to load. | *'''IfpFilePath:''' the [[filepath|file path]] to the IFP file you want to load. | ||
*'''CustomBlockName:''' the new block name for the IFP file. | *'''CustomBlockName:''' the new block name for the IFP file. You cannot use the GTA default [[Animations|internal block]] names. | ||
===Returns=== | ===Returns=== | ||
Line 17: | Line 17: | ||
==Example== | ==Example== | ||
'''Example 1:''' This example loads a custom IFP file ([https://drive.google.com/file/d/1XZNNCCn7xhBNbhaIbsBubky3BEj06zWp/view?usp=sharing parkour.ifp]), adds a command "animation" that takes 1 parameter as animation name for playing animations within that IFP. | |||
<section name="animation.lua" class="client" show="true"> | <section name="animation.lua" class="client" show="true"> | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
--[[ | |||
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", "myNewBlock") | |||
-- let us know if IFP failed to load | |||
if not IFP then | |||
outputChatBox("Failed to load 'parkour.ifp'") | |||
end | end | ||
addCommandHandler("animation", setanimation) | -- execute the command using /animation <NameOfCustomAnimation> | ||
-- for example, /animation CartWheel | |||
function setanimation ( commandName, animationName ) | |||
-- check if IFP file has loaded | |||
if IFP then | |||
-- now play our custom animation | |||
setPedAnimation(localPlayer, customBlockName, animationName) | |||
end | |||
end | |||
addCommandHandler ( "animation", setanimation ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> | ||
Line 31: | Line 57: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
<meta> | <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> | </meta> | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 19:55, 18 June 2018
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 IfpFilePath, string CustomBlockName )
Required Arguments
- IfpFilePath: the file path to the IFP file you want to load.
- CustomBlockName: the new block name for the IFP file. You cannot use the GTA default internal block names.
Returns
Returns an IFP element if the IFP file loaded, false otherwise.
Example
Example 1: 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", "myNewBlock") -- 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 ( commandName, animationName ) -- check if IFP file has loaded if IFP then -- now play our custom animation setPedAnimation(localPlayer, customBlockName, animationName) end end addCommandHandler ( "animation", setanimation )
<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>
See Also
- engineAddImage
- engineApplyShaderToWorldTexture
- engineFreeModel
- engineGetModelFlags
- engineGetModelIDFromName
- engineGetModelLODDistance
- engineGetModelNameFromID
- engineGetModelPhysicalPropertiesGroup
- engineGetModelTextureNames
- engineGetModelTextures
- engineGetModelTXDID
- engineGetModelVisibleTime
- engineGetObjectGroupPhysicalProperty
- engineGetSurfaceProperties
- engineGetVisibleTextureNames
- engineImageGetFilesCount
- engineImageGetFiles
- engineImageGetFile
- engineImageLinkDFF
- engineImageLinkTXD
- engineImportTXD
- engineLoadCOL
- engineLoadDFF
- engineLoadIMG
- engineLoadIFP
- engineLoadTXD
- engineRemoveImage
- engineRemoveShaderFromWorldTexture
- engineReplaceAnimation
- engineReplaceCOL
- engineReplaceModel
- engineRequestModel
- engineResetModelFlags
- engineResetModelLODDistance
- engineResetSurfaceProperties
- engineRestoreAnimation
- engineRestoreCOL
- engineRestoreDFFImage
- engineRestoreModel
- engineRestoreModelPhysicalPropertiesGroup
- engineRestoreObjectGroupPhysicalProperties
- engineRestoreTXDImage
- engineRestreamWorld
- engineSetAsynchronousLoading
- engineSetModelFlag
- engineSetModelFlags
- engineSetModelLODDistance
- engineSetModelPhysicalPropertiesGroup
- engineSetModelVisibleTime
- engineSetObjectGroupPhysicalProperty
- engineSetSurfaceProperties
- engineStreamingFreeUpMemory
- engineStreamingGetUsedMemory