how to spawn npc?
#1

Hi guys.
I would like to know how we can force a npc to spawn. I have a RP gamemode i added a NPC for a command im making it appears on the console he connects but i cant see any new id's ingame and he doesnt spawn. Any sugestions?
cumpz
vasco
Reply
#2

You can't see the ID's of NPC in the players list (aka tab) but make sure you are in the correct world where the NPC is spawned.
Reply
#3

NPCs start at like ID 0 since they usually connect/spawn before any players do.
Reply
#4

Make sure you don't try to show the login/register dialogs to it, and even if it spawned it probably spawned at coodinates 0, 0, 0.
Add something like this:
Код:
public OnPlayerConnect(playerid)
{
    if(IsPlayerNPC(playerid))
    {
        SetPlayerPos(playerid, x, y, z); // Replace with the coordinates he should spawn at
        return 1;
    }

    // The rest of your code

}
Reply
#5

Quote:
Originally Posted by CalvinC
Посмотреть сообщение
Make sure you don't try to show the login/register dialogs to it, and even if it spawned it probably spawned at coodinates 0, 0, 0.
Add something like this:
Код:
public OnPlayerConnect(playerid)
{
    if(IsPlayerNPC(playerid))
    {
        SetPlayerPos(playerid, x, y, z); // Replace with the coordinates he should spawn at
        return 1;
    }

    // The rest of your code

}
Hum i did that and it still doesnt spawn him cuz id 0 should be him like it says on the console but when i join im the id 0 and the bot just doesnt exist. Imma leave here the scripts:

OnGamemodeInit:
PHP код:
deliveryplane CreateVehicle(512,-13.0069,-122.7030,2.0356,85.8541,0,0,0);
    
ConnectNPC("deliveryguy""delivery"); 
OnPlayerConnect
PHP код:
if(IsPlayerNPC(playerid))
    {
        
SetPlayerPos(playerid, -13.0069,-122.7030,2.0356); // Replace with the coordinates he should spawn at
        
return 1;
    }
    
// the rest of the login script is here 
OnPlayerSpawn
PHP код:
if(IsPlayerNPC(playerid))
  {
    new 
npcname[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnpcnamesizeof(npcname));
    if(!
strcmp(npcname"deliveryguy"true))
    {
      
PutPlayerInVehicle(playeriddeliveryplane0);
    }
    return 
1;
  } 
Please can anyone help me?
Reply
#6

anyone??
Reply
#7

plz i really need this npc can anyone help me? ill +rep
Reply
#8

ongamemodeinit
PHP код:
ConnectNPC("deliveryguy""delivery"); 
onplayerrequestclass
PHP код:
if (IsPlayerNPC(playerid)) {
    new 
playername[64];
    
GetPlayerName(playerid,playername,64);
    if (!
strcmp(playername"deliveryguy"true)) {
        
SetSpawnInfo(playeridNO_CLASS1, -13.0069, -122.70302.03560.0, -1, -1, -1, -1, -1, -1);
    }
    return 
1;

onplayerspawn
PHP код:
if (IsPlayerNPC(playerid)) {
    new 
playername[64];
    
GetPlayerName(playerid,playername,64);
    if(!
strcmp(playername"deliveryguy"true)) {
        
PutPlayerInVehicle(playerid10);
        
SetPlayerColor(playerid0xFFFFFFFF);
    }

also you must have npc-record file in npcmodes/recordings and of course the npc file in npcmodes
Reply
#9

Well it didnt spawn. But imma give up trying to use NPC's it was suppost to be like a command that a player did and then a NPC delivered them the materials he asked for. All was ready but NPC aint working so imma go for like airdroping a crate. But thanks i +rep u guys thx rly for trying
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)