spawning NPCs (+rep) - 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: spawning NPCs (+rep) (
/showthread.php?tid=334107)
spawning NPCs (+rep) -
WardenCS - 13.04.2012
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
Re: spawning NPCs (+rep) -
zSuYaNw - 13.04.2012
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" ?
Re: spawning NPCs (+rep) -
WardenCS - 13.04.2012
Код:
enum bossinfo {
Float:hqEntranceX,
Float:hqEntranceY,
Float:hqEntranceZ,
Float:hqExitX,
Float:hqExitY,
Float:hqExitZ,
hqInt,
hqPickup
};
new BossInfo[MAX_BOSSES][bossinfo];
Re: spawning NPCs (+rep) -
Marco_Valentine - 14.04.2012
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
Re: spawning NPCs (+rep) -
WardenCS - 04.05.2012
how can i get their id to BossInfo[i][bNPC] ?