NPC Connects but doesnt spawn -
cyberlord - 08.08.2016
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", 0x6495EDFF, 0.0, 0.0, 0.0, 30.0,0, 0);
NPCTextTrain2 = Create3DTextLabel("San Feriero Transport Company Train ", 0x6495EDFF, 0.0, 0.0, 0.0, 30.0,0, 0);
NPCTextTrain3 = Create3DTextLabel("Los Venturas Transport Company Train ", 0x6495EDFF, 0.0, 0.0, 0.0, 30.0,0, 0);
ConnectNPC("LSTrain1","train1");
ConnectNPC("SFTrain2","train2");
ConnectNPC("LVTrain3","train3");
LSTrain1NPCVehicle = AddStaticVehicleEx(538,-1942.7950,168.4164,27.0006,200.0,-1,-1, 500);
SFTrain2NPCVehicle = AddStaticVehicleEx(538,1700.7551,-1953.6531,14.8756,200.0,-1,-1, 500);
LVTrain3NPCVehicle = AddStaticVehicleEx(538,1462.0745,2630.8787,10.8203,200.0,-1,-1, 500);
traininfo[0] = CreatePickup( 1239, 2, 828.0707,-1368.0125,-0.5015 );
traininfo[1] = CreatePickup( 1239, 2, -1953.9332,131.9761,26.6407 );
traininfo[2] = CreatePickup( 1239, 2, 1433.6084,2626.3992,11.3926 );
traininfo[3] = CreatePickup( 1239, 2, 2858.3093,1291.1527,11.3906 );
traininfo[4] = CreatePickup( 1239, 2, 1738.0891,-1949.9952,14.1172 );
return 1;
}
PlayerSpawn :
PHP код:
public OnPlayerSpawn(playerid)
{
//------------------------- NPC-----------------------------
if(IsPlayerNPC(playerid)){
///////////////TRAIN/////////////
new npcname[MAX_PLAYER_NAME];
GetPlayerName(playerid, npcname, sizeof(npcname)); //Getting the NPC's name.
if(!strcmp(npcname, "LSTrain1", true)) //Checking if the NPC's name is MyFirstNPC
{
PutPlayerInVehicle(playerid, LSTrain1NPCVehicle, 0);
Attach3DTextLabelToVehicle(NPCTextTrain1, LSTrain1NPCVehicle, 0.0, 0.0, 0.0);
}
if(!strcmp(npcname, "SFTrain2", true))
{
PutPlayerInVehicle(playerid, SFTrain2NPCVehicle, 0);
Attach3DTextLabelToVehicle(NPCTextTrain2, SFTrain2NPCVehicle, 0.0, 0.0, 0.0);
}
if(!strcmp(npcname, "LVTrain3", true))
{
PutPlayerInVehicle(playerid, LVTrain3NPCVehicle, 0);
Attach3DTextLabelToVehicle(NPCTextTrain3, LVTrain3NPCVehicle, 0.0, 0.0, 0.0);
}
}
return 1;
}
i got no errors or something and npc joins the server , but trains are not moving and no1 are inside them
Re: NPC Connects but doesnt spawn -
Freaksken - 08.08.2016
Can you show your
train.pwn file?
Re: NPC Connects but doesnt spawn -
Vince - 08.08.2016
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.