NPC Respawning
#1

I want to respawn a npc so a player can get in its vehicle and fly to SF..

code.

Код:
public OnPlayerSpawn(playerid)
{
	if(IsPlayerNPC(playerid))
	{
 		new npcname[MAX_PLAYER_NAME];
	    GetPlayerName(playerid, npcname, sizeof(npcname));
	    if(!strcmp(npcname, "FlightToSF", true))
	    {
	      	Flight1 = CreateVehicle(577,0,0,0,0,7,7,0);
	      	PutPlayerInVehicle(playerid, Flight1, 0);
	    }
	    return 1;
	}
	return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	switch(dialogid)
	{
	    case 3:
	    {
	        if(!response) return 1;
	        if(listitem == 0)
	        {
        		new i;
				for(new id; id<MAX_PLAYERS; id++)
				{
					new name[21];
					GetPlayerName(i,name,sizeof name);
					if(!strcmp(name,"FlightToSF",true))
					{
						i = id;
					}
					DestroyVehicle(Flight1);
					SpawnPlayer(i);
					PutPlayerInVehicle(playerid, Flight1,1);
					SendNotification(playerid,"You can press ENTER to leave~n~the plane.");
					return 1;
				}
	            
	        }
	    }
	}
	return 1;
}
but its not working.
Reply
#2

Store the vehicle id in a variable under OnGameModeInit or OnFilterScriptInit and spawn the NPC regularly. But under OnPlayerSpawn at the top, you can do something like this:
pawn Код:
if(IsPlayerNPC(playerid))
    {
        if(!strcmp(playerName(playerid), "FlightToSF"))
        {
            PutPlayerInVehicle(playerid, Flight1, 0);
        }
        return 1;
    }
Reply
#3

either you didn't read my post correctly, or you don't understand what i am asking. I already did that. That code does not help to fix my problem.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)