NPC Connects but doesnt spawn
#1

Hello guys i am setting npc on my game mode but they are not working for some reason i have all playbacks and everything as it should be , i want to make 3 npc trains

GameModeinit:
PHP код:
public OnGameModeInit()
{
    
////////////////////////////////////NPC TRAINS ////////////////////////////////
    
NPCTextTrain1 Create3DTextLabel("Los Santos Transport Company Train"0x6495EDFF0.00.00.030.0,00);
    
NPCTextTrain2 Create3DTextLabel("San Feriero Transport Company Train "0x6495EDFF0.00.00.030.0,00);
    
NPCTextTrain3 Create3DTextLabel("Los Venturas Transport Company Train "0x6495EDFF0.00.00.030.0,00);
    
ConnectNPC("LSTrain1","train1");
    
ConnectNPC("SFTrain2","train2");
    
ConnectNPC("LVTrain3","train3");
    
LSTrain1NPCVehicle AddStaticVehicleEx(538,-1942.7950,168.4164,27.0006,200.0,-1,-1500);
    
SFTrain2NPCVehicle AddStaticVehicleEx(538,1700.7551,-1953.6531,14.8756,200.0,-1,-1500);
    
LVTrain3NPCVehicle AddStaticVehicleEx(538,1462.0745,2630.8787,10.8203,200.0,-1,-1500);
    
traininfo[0] = CreatePickup12392828.0707,-1368.0125,-0.5015 );
    
traininfo[1] = CreatePickup12392, -1953.9332,131.9761,26.6407 );
    
traininfo[2] = CreatePickup123921433.6084,2626.3992,11.3926 );
    
traininfo[3] = CreatePickup123922858.3093,1291.1527,11.3906 );
    
traininfo[4] = CreatePickup123921738.0891,-1949.9952,14.1172 );
    
    return 
1;

PlayerSpawn :

PHP код:
public OnPlayerSpawn(playerid)
{
    
//------------------------- NPC-----------------------------
   
if(IsPlayerNPC(playerid)){
        
///////////////TRAIN/////////////
        
new npcname[MAX_PLAYER_NAME];
        
GetPlayerName(playeridnpcnamesizeof(npcname)); //Getting the NPC's name.
        
if(!strcmp(npcname"LSTrain1"true)) //Checking if the NPC's name is MyFirstNPC
        
{
          
PutPlayerInVehicle(playeridLSTrain1NPCVehicle0);
          
Attach3DTextLabelToVehicle(NPCTextTrain1LSTrain1NPCVehicle0.00.00.0);
        }
        if(!
strcmp(npcname"SFTrain2"true))
        {
          
PutPlayerInVehicle(playeridSFTrain2NPCVehicle0);
          
Attach3DTextLabelToVehicle(NPCTextTrain2SFTrain2NPCVehicle0.00.00.0);
        }
        if(!
strcmp(npcname"LVTrain3"true))
        {
          
PutPlayerInVehicle(playeridLVTrain3NPCVehicle0);
          
Attach3DTextLabelToVehicle(NPCTextTrain3LVTrain3NPCVehicle0.00.00.0);
        }
    }
    
    return 
1;

i got no errors or something and npc joins the server , but trains are not moving and no1 are inside them
Reply
#2

Can you show your train.pwn file?
Reply
#3

You may want to create the vehicles before you connect the NPC. I'm not sure if that will have any effect since logically OnGameModeInit has to finish first before anything else can happen. Although NPCs do spawn their own processes. Worth a try, though.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)