spawning NPCs (+rep)
#1

Hello, i want to make a system, its kinda simple actually,

but how can i spawn multiple NPCs
something like that:
Код:
ongamemodeinit:
ConnectNPC("[BOT]Mission","NPC");

onplayerspawn:
for(new i = 0; i < sizeof(BossInfo); i++)
{
SetPlayerPos(i,BossInfo[i][hqEntranceX],BossInfo[i][hqEntranceY],BossInfo[i][hqEntranceZ]);
}
i dont know how to connect them and how to set them at the right pos.can someone help me?thanks
Reply
#2

pawn Код:
if(IsPlayerNPC(playerid))
{
    for(new i = 0; i < sizeof(BossInfo); i++)
    {
        SetPlayerPos(playerid,BossInfo[i][hqEntranceX],BossInfo[i][hqEntranceY],BossInfo[i][hqEntranceZ]);
    }
}
What's "BossInfo" ?
Reply
#3

Код:
enum bossinfo {


 Float:hqEntranceX,
 Float:hqEntranceY,
 Float:hqEntranceZ,
 Float:hqExitX,
 Float:hqExitY,
 Float:hqExitZ,
 hqInt,
 hqPickup
};

new BossInfo[MAX_BOSSES][bossinfo];
Reply
#4

simple, create a timer.

Код:
forward Spawn(playerid);
public Spawn(playerid)
	{
	ConnectNPC("[BOT]Mission","NPC");
	for(new i = 0; i < sizeof(BossInfo); i++)
	{
	SetPlayerPos(i,BossInfo[i][hqEntranceX],BossInfo[i][hqEntranceY],BossInfo[i][hqEntranceZ]);
	}
}
then
Код:
ongamemodeinit:
SetTimer("Spawn",2000,true); //A NPC will spawn every two seconds.
Want it to stop? Easy

Код:
public Spawn(playerid)
	{
		if(bots <= 10) //10 NPCs can connect. Add 'new bots;' to the top of the script.
			{
			bots ++;
			ConnectNPC("[BOT]Mission","NPC");
			for(new i = 0; i < sizeof(BossInfo); i++)
				{
				SetPlayerPos(i,BossInfo[i][hqEntranceX],BossInfo[i][hqEntranceY],BossInfo[i][hqEntranceZ]);
			}			
		}
	}
Be sure to do bots --; when a NPC disconnects.

Hope i helped
Reply
#5

how can i get their id to BossInfo[i][bNPC] ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)