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 -
Mattjones17 - 27.10.2009
bump...
Re: Getting an NPC to spawn when I enter a command -
MadeMan - 27.10.2009
Do you want NPC to spawn when needed or drive when needed?
Re: Getting an NPC to spawn when I enter a command -
Mattjones17 - 27.10.2009
I want it to drive when needed
Re: Getting an NPC to spawn when I enter a command -
MadeMan - 27.10.2009
Then remove the PutPlayerInVehicle under OnPlayerSpawn and put it into your command.
Re: Getting an NPC to spawn when I enter a command -
GaGlets(R) - 27.10.2009
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 ?
Re: Getting an NPC to spawn when I enter a command -
Mattjones17 - 27.10.2009
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?
Re: Getting an NPC to spawn when I enter a command -
MadeMan - 27.10.2009
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
Re: Getting an NPC to spawn when I enter a command -
Mattjones17 - 27.10.2009
I dont really understand that lol
Would you mind writing a very simple one for me lol?
Re: Getting an NPC to spawn when I enter a command -
Mattjones17 - 27.10.2009
Код:
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)