SA-MP Forums Archive
Getting an NPC to spawn when I enter a command - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Getting an NPC to spawn when I enter a command (/showthread.php?tid=105089)



Getting an NPC to spawn when I enter a command - Mattjones17 - 27.10.2009

Hi
I'm currently making a movie scene on SAMP using a collection of bots

Obviously I need to have control of when each bot spawns - does anyone know what I can do to this code to get it to work when I enter a command (lets say /cueat400)

Matt

And yes I'm aware that the code was originally for an LV taxi NPC - I simply edited it for personal use because I find it easier than writing the FS from scratch. I am not going to release it - it's just for a video clip i'm making

Код:
#include <a_samp>

new at400vid2;

public OnGameModeInit()
{
	print("GaGlets TAXI LV");
	// NPCS
	ConnectNPC("at400vid2","at400vid2");
	
	at400vid2 =	AddStaticVehicle(577,2310.8389,2407.7266,10.4841,268.0414,123,123); //

	return 1;
}

public OnPlayerSpawn(playerid)
{
  if(IsPlayerNPC(playerid)) //Checks if the player that just spawned is an NPC.
  {
    new npcname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, npcname, sizeof(npcname)); //Getting the NPC's name.
    if(!strcmp(npcname, "at400vid2", true)) //Checking if the NPC's name is MyFirstNPC
    {
      PutPlayerInVehicle(playerid, at400vid2, 0); //Putting the NPC into the vehicle we created for it.
    }
    return 1;
  }
  //Other stuff for normal players goes here!
  return 1;
}



Re: Getting an NPC to spawn when I enter a command - dice7 - 27.10.2009

Tried with SpawnPlayer() ?


Re: Getting an NPC to spawn when I enter a command - Mattjones17 - 27.10.2009

How would I do that?