NPC's don't join their vehicles
#1

As the title says, my NPC's won't join their vehicles.
They just stand at the coordinates which are given by AddPlayerClass.

I really tried to find out if I made a mistake but I can't find one.
Here is my script, I would be grateful for anyone who could help me out

I am using an enum to store my npc data I hope it's not confusing.

Код:
/*============= Train & Tram ============= */

#define MAX_NPCS 2

/*definitions of the npcs*/
#define npc_train 1
#define npc_tram 2

enum server_bots
{
	Float:npc_x,
	Float:npc_y,
	Float:npc_z,
	npc_name[MAX_PLAYER_NAME],
	npc_script_name[32],
	npc_veh_var,
	npc_veh_id
}
new npc_data[MAX_NPCS][server_bots] = {
{1731.0669,-1951.1475,14.1172,"NPC_Zug","Zug",npc_train,538},
{-2006.5000,137.9100,27.9973,"NPC_Tram","Tram",npc_tram,449}
};

stock CreateNPCVehicles(){for(new i;i<MAX_NPCS;i++){npc_data[i][npc_veh_var] = AddStaticVehicleEx(npc_data[i][npc_veh_id],npc_data[i][npc_x],npc_data[i][npc_y],npc_data[i][npc_z],0,-1,-1,-1);}}
stock NPCConnect(){for(new i;i<MAX_NPCS;i++){ConnectNPC(npc_data[i][npc_name],npc_data[i][npc_script_name]);}}

stock NPCVehicleLink(playerid)
{
	if(IsPlayerNPC(playerid))
	{
	    for(new i;i<MAX_NPCS;i++)
	    {
			if(!strcmp(SpielerName[playerid], npc_data[i][npc_name], true))
			{
			    SetPlayerVirtualWorld(playerid,0);
			    SetPlayerInterior(playerid,0);
	 			PutPlayerInVehicle(playerid, npc_data[i][npc_veh_var], 0);
	  		}
		}
	}
	return 1;


}
NPCConnect/CreateNPCVehicles is executed in OnGameModeInit

that was the basic system, the rest is just about directing the npc through the different publics after connecting.

Код:
public OnPlayerConnect(playerid)
{
if(IsPlayerNPC(playerid))
{
print("is being transmitted");
return 1;
}
}
the next step would be the registration which is avoided by !IsPlayerNPC
It takes places in the OnPlayerRequestClass public

Код:
if(mysql_CheckAccount(playerid) == 0 && !IsPlayerNPC(playerid))
{
print("sticked in login");
}
this print is not being displayed.

after this code is executed this step follows (also in OnPlayerRequestClass):

Код:
if(IsPlayerNPC(playerid))
{
SpawnPlayer(playerid);
print("is being spawned");
}
and the last step is being reached:

Код:
public OnPlayerSpawn(playerid)
{
if(IsPlayerNPC(playerid))
{
NPCVehicleLink(playerid);
print("is being put into it's vehicle");
return 1;
}
That is it. It may be a little bit complicated at the first sight but it's very simple.

Can anyone relate to my problem or give me some advice? It's really important because it stops me from
finishing my server.

The recordings worked fine when I tested them some time ago.

I hope my english could be read easily I am not a native english speaker.

Greetz, SoulMan
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)