SA-MP Forums Archive
Dynamic NPC - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Dynamic NPC (/showthread.php?tid=130846)



Dynamic NPC - Hot - 28.02.2010

Hello guys. First of all, I would like to apologize about my english.

I had a look at wiki page, and I have saw some NPC's Callbacks. But I don't know how to use them. I would like to create a lots of NPCS (60~100). Some questions:

1 - How to create random spawns for NPCs? (I know how to create for players, but not for a NPC).
2 - How to make the NPC move toward a player?
3 - How to make NPCs attack players?

I would be happy if you guys could give me some answers. Thanks.


Re: Dynamic NPC - DarkPower - 28.02.2010

http://forum.sa-mp.com/index.php?topic=119947.0

good luck


Re: Dynamic NPC - Hot - 28.02.2010

But, how about setting the pos for an NPC? Instead of playerid i would use npcid?


Re: Dynamic NPC - DarkPower - 28.02.2010

try to use [size=14pt]>Search<


Re: Dynamic NPC - Hot - 28.02.2010

Oh my god, you are so rude. I did a >SEARCH< and could not find anything. Being rude will not solve my questions.


Re: Dynamic NPC - Sharks - 28.02.2010

This is a help forum, if you dont know how to help him, stop saying: "Click on Search" or sending URL.

If you wanna help, then help! If not, dont come here.

I m sorry Hot, i dont know how to solve your problem(yet).


Re: Dynamic NPC - Hot - 28.02.2010

Okay, at leat you said it honestly. I will be waiting for some help.


Re: Dynamic NPC - Nero_3D - 28.02.2010

Quote:
Originally Posted by Hot
1 - How to create random spawns for NPCs? (I know how to create for players, but not for a NPC).
2 - How to make the NPC move toward a player?
3 - How to make NPCs attack players?
1)
Like with normal players

Example (in a filterscript)
pawn Code:
#define NPC_NAME ("MyNPC")
#define NPC_SCRIPT ("mynpc")

new MyNPC;
pawn Code:
public OnFilterScriptInit()
{
    if(!MyNPC) ConnectNPC(NPC_NAME, NPC_SCRIPT);
    MyNPC = INVALID_PLAYER_ID;
    for(new i, name[MAX_PLAYER_NAME]; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerNPC(i))
        {
            GetPlayerName(i, name, MAX_PLAYER_NAME))
            if(strmp(name, NPC_NAME, false) == 0)
            {
                MyNPC = i;
                break;
            }
        }
    } // Gets the id of the NPC
    if(MyNPC == INVALID_PLAYER_ID) SetTimer("OnFilterScriptInit", 5_000, false);
}
pawn Code:
public OnPlayerSpawn(playerid)
{
    if(playerid == MyNPC)
    {
        switch(random(2) + 1)
        {
            case 1: SetPlayerPos(playerid, 1000.0, 2000.0, 3000.0);
            case 2: SetPlayerPos(playerid, 3000.0, 2000.0, 1000.0);
        }
    }
}
2)
NPC's only follow the record paths, if the record stops they are just standing around (kind of freezed)
You can apply animations to the NPC (in your case moving animations) but "normal walking" isnt possible

3)
Like above the NPC's are freezed after replaying the record, so they wont shot by themself
You can apply shot animations, too, and degrees the target health

There is something that Mo3 already made -> The NPC REVOLUTION - smart acting and performing bots (videos - no source code)