02.02.2013, 18:31
(
Last edited by TheArcher; 17/10/2013 at 06:16 AM.
Reason: Add informations about damage system
)
Advanced Recordfree NPC (ARNPC) -
IntroductionHey everybody. Today I'm going to release my ARNPC (Advanced Recordfree NPC). I think this is going to be useful specialy for who is going to use NPC on their servers.
This include has many features and very simple to use. This include is based on Mauzen's RNPC plugin!
Why this?
Since many people (mostly the newbie) has a lot of problems on using the RNPC plugin itself, this include gives you a simple way to manage your NPCs.
How to install?
This include is very simple to install, you just need very basic knowlage of how SA-MP Server package is structured.
- Copy "a_rnpc.inc & YSI folder" to "pawno\include" directory
- Copy "rnpc.dll or rnpc.so" to your "plugins" directory
- Copy "RNPC.amx and RNPC.pwn (optional)" to your "npcmodes" directory
pawn Code:
#include <a_rnpc>
Changelog
Code:
- 02/02/2013 - 1.0 Beta release
- 02/02/2013 - 1.0 RC1 release: - Fixed bug when npc moves the guns disappear.
- 05/02/2013 - 1.0 RC2 release:
- Fix: SetRNPCHealth and SetRNPCArmour works perfectly
- Add: SetRNPCSkillLevel function
- Add: OnRNPCDeath callback
- Fix: RNPC_StopPlayback is now WORKING!
NOTE: Re-download RNPC.pwn & RNPC.amx and put them on npcmodes folder if you're running RC1 or less. - 14/02/2013 - 1.1 Stable release
- Add: RNPCFollowPlayer
- Add: RNPCShotAt / RNPCAimAt
- Add: SetRNPCVehicleSiren / GetRNPCVehicleSiren
- Fix: Fixed problem when a NPC connect with a previous ID it starts with the previous record.
- Fix: Fixed npc angle on spawn point
- Add: RNPCStopUseWeapon - 21/08/2013 - 1.1 R2 Review version
- Now NPCs can connect even on loop (remember that npcs will connect itself after all them load)
- Fixed when OnPlayerConnect gets called once on multiple connections
- Added a simply Virtualworld for NPCs
pawn Code:
Functions
/*
// core
native CreateRNPC(npcname[])
native DestroyRNPC(npcid)
native IsPlayerRNPC(npcid)
native GetRNPCID(npcid)
native GetRNPCState(npcid)
native GetRNPCName(npcid)
native SetRNPCVirtualWorld(npcid, worldid)
native GetRNPCVirtualWorld(npcid)
// vehicle controls
native PutRNPCInVehicle(npcid, vehicleid, seatid) // not working with 0.2.1 plugin
native RemoveRNPCFromVehicle(npcid) // not working with 0.2.1 plugin
native SetRNPCVehicleSiren(npcid,vstate)
native GetRNPCVehicleSiren(npcid)
// on foot controls
native SetRNPCSkin(npcid, skin)
native SetRNPCPos(npcid, Float:x, Float:y, Float:z)
native GetRNPCPos(npcid, &Float:x, &Float:y, &Float:z)
native MoveRNPC(npcid, Float:x, Float:y, Float:z, Float:speed) // taken from the original rnpc include
native SetRNPCFacingAngle(npcid, Float:angle)
native SetRNPCHealth(npcid, health) // remember the health value must be an integer and not working with 0.3 plugin
native GetRNPCHealth(npcid)
native SetRNPCArmour(npcid, armour) // remember the armour value must be an integer and not working with 0.3 plugin
native GetRNPCArmour(npcid)
native SetRNPCWeapon(npcid, weaponid)
native GetRNPCWeapon(npcid)
native SetRNPCSkillLevel(npcid, skill, level)
// npc actions
native RNPCWalkTo(npcid,Float:X,Float:Y,Float:Z);
native RNPCRunTo(npcid,Float:X,Float:Y,Float:Z);
native RNPCSprintTo(npcid,Float:X,Float:Y,Float:Z);
native RNPCAimAt(npcid,Float:X,Float:Y);
native RNPCShotAt(npcid,Float:X,Float:Y);
native RNPCStopUseWeapon(npcid);
native RNPCDriveTo(npcid,Float:X,Float:Y,Float:Z,Float:speed);
native RNPCFollowPlayer(npcid, targetid, movemode = RNPC_SPEED_SPRINT)
// .rec part
native RNPC_StartPlayback(npcid, rec[])
native RNPC_StopPlayback(npcid)
native RNPC_StartBuildPlayback(npcid, slot=0, vehicleid=0)
*/
Callbacks
forward OnRNPCCreated(npcid);
forward OnRNPCDestroyed(npcid);
forward OnRNPCSpawn(npcid);
forward OnRNPCPlaybackFinished(npcid); // it's usable but already called so DO NOT uncomment this
forward OnRNPCDeath(npcid);
Click here to download 1.1 R2 Package (includes, RNPC Plugin 0.3.1, YSI package)
Click here to watch the gamemode tested with this include - pastebin. (GM edited as with 1.1R2 version
Bugs
PutRNPCInVehicle works only with driver sits.
Notes
- IF YOU USE A TIMER WITH ANY FUNCTION KILL THEM BEFORE USING A NEW ONE!
- THIS INCLUDE WAS TESTED ONLY WITH 0.3e and (not R2) and 0.3x SERVER.
- THIS INCLUDE NEEDS y_hooks.
- DO NOT USE RNPC PLUGIN BELOW 0.3 VERSION.
- SOMETIMES THE NPCS MAY NOT BE SYNCED WELL.
- THE GAMEMODE .pwn FILE REQUIRES EXTRA INCLUDES THAT THE PACKAGE DOESN'T INCLUDE.
- PLEASE DO NOT REMOVE ANY CREDITS FROM THE INCLUDE.
- Use "RemoveRNPCFromVehicle" if a NPC is in a car, before using another function.
- When multiple npcs get connected the order of connection may be wrong
- Since this include and the plugin either have not a damage system whatsoever I can't/ I have not time for a good one. You can take a look HERE.. - Thanks to [uL]Pottus
Credits
Me for the include
Mauzen for his RNPC Plugin and Joe Staff's code based.
****** for y_hooks.