#define FILTERSCRIPT
#include <a_samp>
#include <FCNPC>
#define MAX_NPCS 10
#if defined FILTERSCRIPT
new npcid;
public OnFilterScriptInit()
{
npcid = FCNPC_Create("TEST");
FCNPC_Spawn(npcid, 77, 2530.7561,-1678.0607,19.9302);
FCNPC_SetInterior(npcid, 0);
FCNPC_SetWeapon(npcid, random(11) + 22);
FCNPC_SetAmmo(npcid, 500);
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
#else
main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}
#endif
forward testnpc();
public testnpc()
{
new Float:x, Float:y, Float:z;
FCNPC_GetPosition(npcid,x,y,z);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerInRangeOfPoint(i,2.5,x,y,z))
{
new Float:rx, Float:ry, Float:rz;
GetPlayerPos(i,rx,ry,rz);
FCNPC_AimAt(npcid,rx,ry,rz,1);
}
}
return 1;
}
public FCNPC_OnSpawn()
{
new Float:x, Float:y, Float:z;
FCNPC_GetPosition(npcid,x,y,z);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerInRangeOfPoint(i,10,x,y,z))
{
SetTimer("testnpc",3000,false);
}
}
return 1;
}
You spawn the NPC already in OnGameModeInit and then the script checks if there is any player in range of the bot but that can't be because it's in OnGameModeInit
![]() I would set the timer in OnGameModeInit ![]() |
#define FILTERSCRIPT
#include <a_samp>
#include <FCNPC>
#if defined FILTERSCRIPT
new npcid;
public OnFilterScriptInit()
{
npcid = FCNPC_Create("TEST");
FCNPC_Spawn(npcid, 77, 2530.7561,-1678.0607,19.9302);
FCNPC_SetInterior(npcid, 0);
FCNPC_SetWeapon(npcid, random(11) + 22);
FCNPC_SetAmmo(npcid, 500);
FCNPC_SetHealth(npcid,100.0);
new Float:x, Float:y, Float:z;
FCNPC_GetPosition(npcid,x,y,z);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerInRangeOfPoint(i,1.5,x,y,z))
{
new Float:rx, Float:ry, Float:rz;
GetPlayerPos(i,rx,ry,rz);
FCNPC_AimAt(npcid,rx,ry,rz,1);
}
}
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
#else
main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}
#endif