23.01.2014, 17:16
(
Последний раз редактировалось Swedky; 25.01.2014 в 17:05.
)
Код:
- Changelog:
- 23/01/2014 - 4:30 - Include published.
Today I present this one include that I did to be able to control the NPC's using only the native functions that SA-MP offers. First that nothing, they will have to have the file 'SAfull.hmap' and unload these files and include them in the specified folder: http://www.mediafire.com/download/ow...9jg9/AFNPC.zip
Functions:
pawn Код:
// Done by RyDeR:
native Float:GetPointZPos(const Float: fX, const Float: fY, &Float: fZ = 0.0);
// Done by me:
native CreateNPC(npcid, name[]); // Create a NPC in the Server.
native DestroyNPC(npcid); // It destroys a NPC in the Server.
native SpawnNPC(npcid);
native SetNPCPos(npcid, Float:PosX, Float:PosY, Float:PosZ);
native SetNPCPosFindZ(npcid); // It establishes the NPC in the position Z adapted in his position.
native SetNPCPosFindZEx(npcid, Float:PosX, Float:PosY); // It establishes the NPC in the position Z adapted in the declared positions.
native SetNPCFacingAngle(npcid, Float:Angle);
native RotateNPCToPos(npcid, const Float:PosX, const Float:PosY); // It does that the angle of the NPC is fixed in the positions 'X' and 'Y'
native SetNPCHealth(npcid, Float:Health);
native SetNPCArmour(npcid, Float:Armour);
native ApplyNPCAnimation(npcid, animlib[], animname[], Float:fDelta, loop, lockx, locky, freeze, time, forcesync = 0);
native GetNPCPos(npcid, &Float:PosX, &Float:PosY, &Float:PosZ);
native GetNPCFacingAngle(npcid, &Float:Angle);
native Float:GetNPCHealth(npcid);
native Float:GetNPCArmour(npcid);
native CountAllNPC(); // He returns NPC's quantity connected in the Server.
native KickAllNPC();
native ForeachNPC(iterate); // It crosses a loop for all the connected NPC's.
// Forward's:
forward OnNPCCreated(npcid); // Called when a NPC connects to the Server.
forward OnNPCSpawn(npcid); // Called when a NPC spawns in the Server.
forward OnPlayerDamgeToNPC(npcid, playerid, weaponid, Float:amount); // Called when one Player damages a NPC with firearms.
forward OnNPCDeath(npcid, killerid, weaponid); // Called when a NPC dies for a player.
forward OnNPCDisconnect(npcid); // Called when a NPC is disconnected.
Note: When a Player damages a NPC, the quantity of life that reduces him to the NPC is the same that when a Player damages another Player.
Note2: The animation of dies (OnNPCDeath) is established when a NPC dies for 2° time in forward.
Bugs:
Without counting previously saying, none.
Downloads:
Pastebin: [Include] AFNPC - Control System for NCP.
MediaFire: [Include] AFNPC - Control System for NCP.
Credits:
Me - Idea and Script.
Edugta. - Thanks to him I could solve a mistake where 'OnNPCSpawn' was never called.
RyDeR` - For an idea of how to do a 'RotateNPCToPos' and for 'SAfull.hmap' (https://sampforum.blast.hk/showthread.php?tid=266806).
pds2k12 - An improvement of 'ForeachNPC' -(Example use: http://pastebin.com/6SHkSj1f)-
Regards.