Getting an NPC to spawn when I enter a command
#1

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;
}
Reply
#2

bump...
Reply
#3

Do you want NPC to spawn when needed or drive when needed?
Reply
#4

I want it to drive when needed
Reply
#5

Then remove the PutPlayerInVehicle under OnPlayerSpawn and put it into your command.
Reply
#6

Quote:
Originally Posted by MadeMan
Then remove the PutPlayerInVehicle under OnPlayerSpawn and put it into your command.
Yeah its true... im working with that (making new npc )

Author..
U realy will use my npc ?
Reply
#7

Gaglets - Yes - it's very easily modified and reliable

Mademan - so if I put thatunder OnPlayerCommandText - the bot will start driving once I enter the text?

Reply
#8

Yes, but you have to change playerid to that bots id. There are 2 ways for that:
  • save the bot's id to a variable when it connects to the server and later use it with your command
  • make an extra parameter for your command so you can do /yourcommand [playerid] where [playerid] is the id of the bot
Reply
#9

I dont really understand that lol

Would you mind writing a very simple one for me lol?
Reply
#10

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/plane1", cmdtext, true, 10) == 0)
  {
    PutPlayerInVehicle(playerid, at400vid2, 0); //Putting the NPC into the vehicle we created for it.
  }
  return 1;
}
have tried this - now no commands work and the bot just stands still at the spawn poitn (as a ped not a car)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)