-
Notifications
You must be signed in to change notification settings - Fork 31
Natives
Home ▸ Natives
- Parameters:
rate
: The time in ms the plugin updates.- Return values:
1
: The function executed successfully.0
: The function failed to execute. A rate <0
was given.- Notes:
- Defaults to
5
if not set manually in any script.- The plugin uses this value to keep track of the time passed. Therefore it has to be the same as the SA-MP server sleep time set in
server.cfg
.- If you change this in one of your running scripts, it will change in every other running script as well. In other words, this is a global value.
Set the tick rate at which the plugin should update.
- Parameters: This function has no parameters.
- Return values: The tick rate.
Get the tick rate set in FCNPC_SetTickRate.
- Parameters:
rate
: The time in ms the NPCs update.- Return values:
1
: The function executed successfully.0
: The function failed to execute. A rate <0
was given.- Notes:
- Defaults to
50
if not set manually in any script.- A value < the plugin update time in ms will act as the plugin update time.
- Some actions will still happen every plugin tick regardless of the update rate.
- If you change this in one of your running scripts, it will change in every other running script as well. In other words, this is a global value.
Set the update rate at which the plugin should update every NPC.
- Parameters: This function has no parameters.
- Return values: The update rate.
Get the update rate set in FCNPC_SetUpdateRate.
- Parameters:
address
: The address returned by MapAndreas_GetAddress.- Return values:
1
: The function executed successfully. The NPCs can now use MapAndreas.0
: The function failed to execute. MapAndreas is not inited and therefore the given address was0
. Use MapAndreas_Init first.- Notes:
- The NPCs can't use MapAndreas if not set manually in any script.
- If you change this in one of your running scripts, it will change in every other running script as well. In other words, this is a global value.
Stores the memory address of MapAndreas in the FCNPC plugin so that the map data doesn't have to be loaded a second time and is only present in MapAndreas.
- Parameters:
name[]
: The playername the NPC should have. See SetPlayerName for any restrictions.- Return values:
Valid playerid
: The function executed successfully.INVALID_PLAYER_ID
: The function failed to execute. An invalid name was given, or there was already another player connected with the given name, or the server was full, ormaxnpc
inserver.cfg
was reached.
Connect an NPC to the server. Or, if an NPC are already connected to the server, returns his ID.
- Parameters:
npcid
: The ID of the NPC to destroy.- Return values:
1
: The function executed successfully.0
: The function failed to execute. An invalid playerid was given, or the playerid given was not online, or the playerid given was not an NPC.
Disconnect an NPC from the server.
- Parameters:
npcid
: The ID of the NPC to spawn.skinid
: The ID of the skin the NPC should use.Float:x
: The X coordinate to position the NPC at.Float:y
: The Y coordinate to position the NPC at.Float:z
: The Z coordinate to position the NPC at.- Return values:
1
: The function executed successfully.0
: The function failed to execute. An invalid playerid was given, or the playerid given was not online, or the playerid given was not an NPC, or the NPC is already spawned.- Notes:
- The NPC will have
100.0
health,0.0
armour, weaponFist
with ammo0
and ammoInClip0
, special actionSPECIAL_ACTION_NONE
and player statePLAYER_STATE_ONFOOT
.- If the NPC has already been spawned a first time or is dead, use FCNPC_Respawn instead.
Spawn an NPC for the first time.
- Parameters:
npcid
: The ID of the NPC to respawn.- Return values:
1
: The function executed successfully.0
: The function failed to execute. An invalid playerid was given, or the playerid given was not online, or the playerid given was not an NPC, or the NPC is not yet spawned a first time.- Notes:
- If the NPC was previously dead, his health will be reset to
100.0
and his armour to0.0
. If not, his health and armour will not change.- The NPC will respawn on the position he is currently at, face the angle he has currently and perform the special action he is performing currently.
- If the NPC was previously playing back a recording, it will be briefly paused and be then resumed again.
- The NPC's player state will be reset to
PLAYER_STATE_ONFOOT
no matter what. If he was previously in a vehicle, he will be put back in that vehicle on the seat he was previously and his player state will be set toPLAYER_STATE_DRIVER
orPLAYER_STATE_PASSENGER
accordingly. He will also assume the position and facing angle of the vehicle.- If the NPC has not yet been spawned a first time, use FCNPC_Spawn instead.
Respawn an NPC.
- Parameters:
npcid
: The ID of the NPC to kill.- Return values:
1
: The function executed successfully.0
: The function failed to execute. An invalid playerid was given, or the playerid given was not online, or the playerid given was not an NPC, or the NPC is already dead.- Notes:
- The killerid will be
INVALID_PLAYER_ID
and the reason will beSuicide
.- The NPC will stop aiming, his player state will be set to
PLAYER_STATE_WASTED
, his keys will be set toKEY_NONE
and the his velocity will be set to0.0, 0.0, 0.0
.- If the NPC was previously playing back a recording, it will be stopped and OnFinishPlayback will be called. The NPC's keys will be reset to
KEY_NONE
again and the NPC's velocity will be reset to0.0, 0.0, 0.0
again.- If the NPC was previously playing back a node, it will be stopped and OnFinishNode will be called. The NPC's keys will be reset to
KEY_NONE
again and the NPC's velocity will be reset to0.0, 0.0, 0.0
again.
Kill an NPC.
- Parameters:
npcid
: The ID of the NPC to check.- Return values (bool):
true
: The function executed successfully. The NPC is spawned.false
:
- The function executed successfully. The NPC is not spawned.
- The function failed to execute. An invalid playerid was given, or the playerid given was not online, or the playerid given was not an NPC.
Checks whether an NPC is spawned.
- Parameters:
npcid
: The ID of the NPC to check.- Return values (bool):
true
: The function executed successfully. The NPC is dead.false
:
- The function executed successfully. The NPC is not dead.
- The function failed to execute. An invalid playerid was given, or the playerid given was not online, or the playerid given was not an NPC.
Checks whether an NPC is dead (player state == PLAYER_STATE_WASTED
).
- Parameters:
npcid
: The ID of the NPC to check.- Return values (bool):
true
: The function executed successfully. The given ID is a valid playerid, is online and is an NPC created by FCNPC.false
: The function executed successfully. The given ID is an invalid playerid, or the playerid given is not online, or the playerid given is not an NPC created by FCNPC.
Checks whether a given ID is a valid NPC. This function returns 0 in OnPlayerConnect
for newly created NPC.
- Parameters:
npcid
: The ID of the NPC to check.forplayerid
: The ID of the player to check.- Return values (bool):
true
: The function executed successfully. The NPC is streamed in for the given player.false
:
- The function executed successfully. The NPC is not streamed in for the given player.
- The function failed to execute. An invalid playerid was given, or the playerid given was not online, or the playerid given was not an NPC, or the forplayerid given was invalid, or the forplayerid given was not online, or the given forplayerid is the NPC.
Checks whether an NPC is streamed in for the given player.
- Parameters:
npcid
: The ID of the NPC to check.- Return values (bool):
true
: The function executed successfully. The NPC is streamed in for at least one player.false
:
- The function executed successfully. The NPC is not streamed in for any player.
- The function failed to execute. An invalid playerid was given, or the playerid given was not online, or the playerid given was not an NPC.
Checks whether an NPC is streamed in for any player.
FCNPC_SetAnimation(npcid, animationid, Float:fDelta = 4.1, loop = 0, lockx = 1, locky = 1, freeze = 0, time = 1)
- Parameters:
npcid
: The ID of the NPC to set the animation of.animationid
: The ID of the animation.Float:fDelta
: The speed to play the animation.loop
: If set to 1, the animation will loop. If set to 0, the animation will play once.lockx
: If set to 0, the player is returned to their old X coordinate once the animation is complete (for animations that move the player such as walking). 1 will not return them to their old position.locky
: Same as above but for the Y axis. Should be kept the same as the previous parameter.freeze
: Setting this to 1 will freeze the player at the end of the animation. 0 will not.time
: Timer in milliseconds. For a never-ending loop it should be 0.- Return values:
1
: The function executed successfully.0
: The function failed to execute. An invalid playerid was given, or the playerid given was not an NPC.
Sets animation to NPC by changing sync data. Animation is replayed after restreaming. Needs to use FCNPC_ResetAnimation (with small delay) before replay the current animation.
FCNPC_SetAnimationByName(npcid, name[], Float:fDelta = 4.1, loop = 0, lockx = 1, locky = 1, freeze = 0, time = 1)
- Parameters:
npcid
: The ID of the NPC to set the animation of.name[]
: The name of the animation. Mask:LIBNAME:ANIMNAME
(ex:PED:WALK_DRUNK
).Float:fDelta
: The speed to play the animation.loop
: If set to 1, the animation will loop. If set to 0, the animation will play once.lockx
: If set to 0, the player is returned to their old X coordinate once the animation is complete (for animations that move the player such as walking). 1 will not return them to their old position.locky
: Same as above but for the Y axis. Should be kept the same as the previous parameter.freeze
: Setting this to 1 will freeze the player at the end of the animation. 0 will not.time
: Timer in milliseconds. For a never-ending loop it should be 0.- Return values:
1
: The function executed successfully.0
: The function failed to execute. An invalid playerid was given, or the playerid given was not an NPC.
Sets the animation to the NPC by changing sync data. Animation is replayed after restreaming. Needs to use FCNPC_ResetAnimation (with small delay) before replay the current animation.
- Parameters:
npcid
: The ID of the NPC to reset the animation of.- Return values:
1
: The function executed successfully.0
: The function failed to execute. An invalid playerid was given, or the playerid given was not an NPC.
Resets the animation to the NPC by changing the sync data.
FCNPC_GetAnimation(npcid, &animationid = 0, &Float:fDelta = 4.1, &loop = 0, &lockx = 1, &locky = 1, &freeze = 0, &time = 1)
- Parameters:
npcid
: The ID of the NPC to get the animation of.&animationid
: The name of the animation. Mask:LIBNAME:ANIMNAME
(ex:PED:WALK_DRUNK
).&Float:fDelta
: The speed to play the animation.&loop
: If set to 1, the animation will loop. If set to 0, the animation will play once.&lockx
: If set to 0, the player is returned to their old X coordinate once the animation is complete (for animations that move the player such as walking). 1 will not return them to their old position.&locky
: Same as above but for the Y axis. Should be kept the same as the previous parameter.&freeze
: Setting this to 1 will freeze the player at the end of the animation. 0 will not.&time
: Timer in milliseconds. For a never-ending loop it should be 0.- Return values:
1
: The function executed successfully.0
: The function failed to execute. An invalid playerid was given, or the playerid given was not an NPC.
Gets the animation from the NPC sync data.
FCNPC_ApplyAnimation(npcid, animlib[], animname[], Float:fDelta = 4.1, loop = 0, lockx = 1, locky = 1, freeze = 0, time = 1)
- Parameters:
npcid
: The ID of the NPC to set the animation of.animlib[]
: The animation library from which to apply an animation.animname[]
: The name of the animation to apply, within the specified library.Float:fDelta
: The speed to play the animation.loop
: If set to 1, the animation will loop. If set to 0, the animation will play once.lockx
: If set to 0, the player is returned to their old X coordinate once the animation is complete (for animations that move the player such as walking). 1 will not return them to their old position.locky
: Same as above but for the Y axis. Should be kept the same as the previous parameter.freeze
: Setting this to 1 will freeze the player at the end of the animation. 0 will not.time
: Timer in milliseconds. For a never-ending loop it should be 0.- Return values:
1
: The function executed successfully.0
: The function failed to execute. An invalid playerid was given, or the playerid given was not an NPC.
Sends the RPC packets to the streamed players, works like ApplyAnimation (should be recalled after restreaming).
- Parameters:
npcid
: The ID of the NPC to clear the animations of.- Return values:
1
: The function executed successfully.0
: The function failed to execute. An invalid playerid was given, or the playerid given was not an NPC.
Clears all animations for the given player by sending RPC packet to the streamed players, works like ClearAnimations.
- Return values:
FCNPC_INVALID_MOVEPATH_ID
: The function failed to execute. Memory allocation failure.- The function returns created move path id.
Creates new move path.
- Parameters:
pathid
: The ID of the move path.- Return values:
1
: The function executed successfully.0
: The function failed to execute. An invalid move path id was given.
Destroys move path from the memory.
- Parameters:
pathid
: The ID of the move path.- Return values (bool):
true
: The function executed successfully. The move path is valid.false
: The function failed to execute. An invalid move path id was given.
Checks whether a move path is valid.
- Parameters:
pathid
: The ID of the move path.Float:x
: The X coordinate to position the point at.Float:y
: The Y coordinate to position the point at.Float:z
: The Z coordinate to position the point at.- Return values:
1
: The function executed successfully.0
: The function failed to execute. An invalid move path id was given.
Adds point to the move path.
- Parameters:
pathid
: The ID of the move path.Float:points[][3]
: The array of the array of coordinate points.size
: The size of thepoints
array. Default issizeof(points)
.- Return values:
1
: The function executed successfully.0
: The function failed to execute. An invalid move path id was given.
Adds points to the move path.
FCNPC_AddPointsToMovePath2(pathid, Float:points_x[], Float:points_y[], Float:points_z[], const size = sizeof(points_x))
- Parameters:
pathid
: The ID of the move path.Float:points_x[]
: The array of the X coordinate points.Float:points_y[]
: The array of the Y coordinate points.Float:points_z[]
: The array of the Z coordinate points.size
: The size of thepoints
arrays. Default issizeof(points_x)
.- Return values:
1
: The function executed successfully.0
: The function failed to execute. An invalid move path id was given.
Adds points to the move path.
- Parameters:
pathid
: The ID of the move path.pointid
: The ID of the move path point.- Return values:
1
: The function executed successfully.0
: The function failed to execute. An invalid move path id or point id was given.
Removes point from the move path.
- Parameters:
pathid
: The ID of the move path.pointid
: The ID of the move path point.- Return values (bool):
true
: The function executed successfully. The move path point is valid.false
: The function failed to execute. An invalid move path id or point id was given.
Checks whether a move path point is valid.
- Parameters:
pathid
: The ID of the move path.pointid
: The ID of the move path point.&Float:x
: The X coordinate to position the point at.&Float:y
: The Y coordinate to position the point at.&Float:z
: The Z coordinate to position the point at.- Return values:
1
: The function executed successfully.0
: The function failed to execute. An invalid move path id or point id was given.
Gets a move path point coordinates.
- Parameters:
pathid
: The ID of the move path.- Return values:
-1
: The function failed to execute. An invalid move path id was given.- The number of the move points in the move path.
Gets the number of the move points in the move path.
FCNPC_GoByMovePath(npcid, pathid, type = FCNPC_MOVE_TYPE_AUTO, Float:speed = FCNPC_MOVE_SPEED_AUTO, bool:UseMapAndreas = false, Float:radius = 0.0, bool:setangle = true, Float:dist_offset = 0.0)
- Parameters:
npcid
: The ID of the NPC.pathid
: The ID of the move path.type
: The type of the move. Default isFCNPC_MOVE_TYPE_AUTO
.Float:speed
: The speed of the move. Default isFCNPC_MOVE_SPEED_AUTO
.bool:UseMapAndreas
: Use whether MapAndreas plugin for the getting Z coords while NPC is moving. Default isfalse
.Float:radius
: To change a position on the point at random offset. Default is0.0
.bool:setangle
: Change whether NPC angle while moving. Default istrue
.Float:dist_offset
: The offset distance to the point. Default is0.0
.- Return values:
1
: The function executed successfully.0
: The function failed to execute. An invalid move path id or point id was given.
Moves an NPC by the move path.
Wiki written by Freaksken.