NPC Respawning - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: NPC Respawning (
/showthread.php?tid=465750)
NPC Respawning -
CJ101 - 23.09.2013
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.
Re: NPC Respawning -
Cell_ - 25.09.2013
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;
}
Re: NPC Respawning -
CJ101 - 25.09.2013
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.