Skip to content
WoutProvost edited this page Apr 26, 2020 · 52 revisions

Requirements

  • A SA-MP version which is compatible with the latest FCNPC version. Both the latest non-0.3.DL SA-MP version and the latest 0.3.DL SA-MP version are supported.
  • Optionally, foreach, to add the ability to use: foreach (new npcid : FCNPC).

Download

The latest version can be found on the releases page for both the latest non-0.3.DL SA-MP version and the latest 0.3.DL SA-MP version.

Installation

  • Add a maxnpc line in the server.cfg file if one does not already exist and set it to the maximum amount of NPCs you want. Make sure it is not more than maxplayers, else increase that value.
  • Create a plugins folder in the root of the server directory if one does not already exist.
  • Put the FCNPC.dll file (for Windows) or the FCNPC.so file (for Linux) in the plugins folder if you're using the non-0.3.DL SA-MP version, otherwise put the FCNPC-DL.dll file (for Windows) or the FCNPC-DL.so file (for Linux) in the plugins folder if you're using the 0.3.DL SA-MP version.
  • Add a plugins line in the server.cfg file if one does not already exist.
  • Add FCNPC (for Windows) or FCNPC.so (for Linux) to that line if you're using the non-0.3.DL SA-MP version, otherwise add FCNPC-DL (for Windows) or FCNPC-DL.so (for Linux) to that line if you're using the 0.3.DL SA-MP version. If there is already another plugin on that line, separate the plugins by using a space between them.
  • Put the FCNPC.inc file in the pawno/include folder. It supports both the non-0.3.DL SA-MP version and the 0.3.DL SA-MP version.
  • Put #include <FCNPC> in the filterscript/gamemode you want to use the plugin in.
  • Enable lag compensation in server.cfg if not done already. This is to ensure that OnPlayerWeaponShot will be called, and as a result NPC vehicle damage will work.
  • If your NPCs will use MapAndreas, initialize MapAndreas in your gamemode by putting the following line under OnGameModeInit if not done already. You also don't need to load the MapAndreas plugin separately in server.cfg, since FCNPC loads this automatically!
MapAndreas_Init(MAP_ANDREAS_MODE_FULL);
  • If your NPCs will use ColAndreas, initialize ColAndreas in your gamemode by putting the following line under OnGameModeInit if not done already. You also don't need to load the ColAndreas plugin separately in server.cfg, since FCNPC loads this automatically!
CA_Init();

Simplest Example Script

This example filterscript creates an NPC named FirstNPC and spawns him at the center of the map. More advanced examples can be found here.

#define FILTERSCRIPT
#include <a_samp>
#include <FCNPC>

new myFirstNPC = INVALID_PLAYER_ID;

#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
	myFirstNPC = FCNPC_Create("FirstNPC");
	FCNPC_Spawn(myFirstNPC, 0, 0.0, 0.0, 3.1);
	return 1;
}

public OnFilterScriptExit()
{
	FCNPC_Destroy(myFirstNPC);
	myFirstNPC = INVALID_PLAYER_ID;
	return 1;
}
#endif

FCNPC Developers

If you would like to help develop this plugin, you need to download the sources and build the project.

Sources

To download the sources, use the following git command:

git clone --recursive https://github.com/ziggi/FCNPC.git

Note the use of the --recursive argument, because this repository contains submodules.

Building

To build the project you can use Visual Studio. To generate the project you can use CMake.
On Windows, execute the following commands. This example is for Visual Studio 15 2017:

cd FCNPC
mkdir build
cd build
cmake .. -G "Visual Studio 15 2017"

On Linux, execute the following commands:

cd FCNPC
mkdir build
cd build
cmake ..
make