Freaksken edited this page Jun 27, 2018 · 38 revisions

Everything in the plugin is prefixed with FCNPC_.
Questions can be asked in the forum thread, or in the Russian forum thread.

Requirements

Download

The latest version can be found on the releases page.

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.
  • 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 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.
  • 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 as follows if not done already in one of your scripts in which you want to use FCNPC. If your script is a gamemode, put the following lines under OnGameModeInit. If it is a filterscript, put them under OnFilterScriptInit.
MapAndreas_Init(MAP_ANDREAS_MODE_FULL);
FCNPC_InitMapAndreas(MapAndreas_GetAddress());

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
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.