SA-MP Forums Archive
[FCNPC] Help with FCNPC_AimAt. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [FCNPC] Help with FCNPC_AimAt. (/showthread.php?tid=510203)



[FCNPC] Help with FCNPC_AimAt. - Galletziz - 30.04.2014

Hi i have make this script in a filterscript, and the npc spawn perfectly but when i want that him shot me with a function FCNPC_AimAt, it doesn't works, you know why..?

pawn Код:
#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;
}
thanks for read.


Re: [FCNPC] Help with FCNPC_AimAt. - Galletziz - 30.04.2014

Bump, someone that know help me..?!


Re: [FCNPC] Help with FCNPC_AimAt. - Galletziz - 30.04.2014

Bump* з_з


AW: [FCNPC] Help with FCNPC_AimAt. - Macronix - 30.04.2014

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


Re: AW: [FCNPC] Help with FCNPC_AimAt. - Galletziz - 30.04.2014

Quote:
Originally Posted by Macronix
Посмотреть сообщение
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
still not working, the npc aim at no defined point, and i want that aim to me.


Re: [FCNPC] Help with FCNPC_AimAt. - Galletziz - 30.04.2014

pawn Код:
#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
I have edited the code above whit this but still don't works, when i go near the npc, he stay already aming and shot at nobody. Someone know why?!


Re: [FCNPC] Help with FCNPC_AimAt. - Galletziz - 30.04.2014

Bump**


Re: [FCNPC] Help with FCNPC_AimAt. - Galletziz - 30.04.2014

Bump***


Re: [FCNPC] Help with FCNPC_AimAt. - Galletziz - 30.04.2014

Nobody knows help me?!
If someone knows an other include for controlable npcs, can reply please.


AW: [FCNPC] Help with FCNPC_AimAt. - Macronix - 30.04.2014

Uhm, i mean u just have to put the SetTimer in OnGameModeInit, not the whole thing .^^