SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Reply
 
Thread Tools Display Modes
Old 05/12/2009, 03:02 AM   #501
BP13
High-roller
 
BP13's Avatar
 
Join Date: Jan 2009
Location: Canada
Posts: 2,034
Reputation: 2
Default Re: Tutorial -> Creating a new NPC

are all 10 of your posts in this topic?
__________________
BP13 is offline   Reply With Quote
Old 05/12/2009, 04:32 AM   #502
V1ceC1ty
Banned
 
Join Date: Oct 2008
Location: West Australia
Posts: 1,915
Reputation: 273
Default Re: Tutorial -> Creating a new NPC

Quote:
Originally Posted by DJDhan
It was some mistke in my editing of the gamemode!
Thought so
V1ceC1ty is offline   Reply With Quote
Old 05/12/2009, 05:33 AM   #503
DJDhan
High-roller
 
DJDhan's Avatar
 
Join Date: Oct 2009
Location: Canada
Posts: 1,152
Reputation: 3
Default Re: Tutorial -> Creating a new NPC

Quote:
Originally Posted by [SU
BP13 ]
are all 10 of your posts in this topic?
Umm not really most of them yet though
__________________
DJDhan is offline   Reply With Quote
Old 05/12/2009, 02:19 PM   #504
DJDhan
High-roller
 
DJDhan's Avatar
 
Join Date: Oct 2009
Location: Canada
Posts: 1,152
Reputation: 3
Default Re: Tutorial -> Creating a new NPC

Dude,i have a problem.
I created a train (ID 569) for a NPC Bot. But when i go to the station he is just standing in the middke of the train.
All other bots are fine.Only all the train bots can't seems to drive the train.

Any Help?!
__________________
DJDhan is offline   Reply With Quote
Old 05/12/2009, 04:17 PM   #505
Rac3r
Gangsta
 
Join Date: May 2007
Posts: 500
Reputation: 40
Default Re: Tutorial -> Creating a new NPC

Trains need to be created with AddStaticVehicle(.....

Also, when creating a train, it use 4 ID slots, so if this is the first vehicle created, it will use vehicleid 1.

Example:
Code:
	AddStaticVehicle(492,0.0,0.0,0.0,0.0,-1,-1);//  ID 0
	AddStaticVehicle(538,1462.0745,2630.8787,10.8203,200.0,-1,-1); // ID 1,2,3,4
	AddStaticVehicle(506,0.0,0.0,0.0,0.0,-1,-1);// ID 5
In this case, we would put the bot in vehicleid 2.
Rac3r is offline   Reply With Quote
Old 06/12/2009, 05:53 AM   #506
Angelus~
Big Clucker
 
Join Date: Aug 2009
Posts: 62
Reputation: 0
Default Re: Tutorial -> Creating a new NPC

When i use the function PutPlayerInVehicle, the NPC doesn't go in and then disconnects from the server a couple seconds later whats going on?
Angelus~ is offline   Reply With Quote
Old 06/12/2009, 06:20 AM   #507
V1ceC1ty
Banned
 
Join Date: Oct 2008
Location: West Australia
Posts: 1,915
Reputation: 273
Default Re: Tutorial -> Creating a new NPC

Quote:
Originally Posted by Angelus~
When i use the function PutPlayerInVehicle, the NPC doesn't go in and then disconnects from the server a couple seconds later whats going on?
are you doing it right? lets see the script.
V1ceC1ty is offline   Reply With Quote
Old 06/12/2009, 03:07 PM   #508
DJDhan
High-roller
 
DJDhan's Avatar
 
Join Date: Oct 2009
Location: Canada
Posts: 1,152
Reputation: 3
Default Re: Tutorial -> Creating a new NPC

Code:
public OnFilterScriptInit()
{
ConnectNPC("TrainDriverLStoLS","train_ls_to_ls");
	traindriverlstolsvehicle=CreateVehicle(538, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{if(!IsPlayerNPC(playerid))
	return 0;

	new playername[64];
	GetPlayerName(playerid,playername,64);
if(!strcmp(playername,"TrainDriverLStoLS",true))
	{
	  SetSpawnInfo(playerid,61,61,0.0,0.0,0.0,0.0,-1,-1,-1,-1,-1,-1);
 	}
return 0;
}
public OnPlayerSpawn(playerid)
{
   if(!strcmp(playername, "TrainDriverLStoLS", true))
  {
      PutPlayerInVehicle(playerid, traindriverlstolsvehicle, 0);
      SetPlayerColor(playerid,0xFFFFFFFF);
      return 1;
  }
return 1;
}
Ho am i supposed to add a npc train in gl_npcs coz i am using gl_npcs for all of my bots?And how do i put the player in id 2 vehicle?
Or do i have to add it to the gamemode?
__________________
DJDhan is offline   Reply With Quote
Old 06/12/2009, 03:44 PM   #509
DJDhan
High-roller
 
DJDhan's Avatar
 
Join Date: Oct 2009
Location: Canada
Posts: 1,152
Reputation: 3
Default Re: Tutorial -> Creating a new NPC

Here is my gl_npc!
Code:
#pragma tabsize 0
#include <a_samp>

//-------------------------------------------------
new traindriverlvvehicle;
new traindriverlsvehicle;
new traindriversfvehicle;
new pilotlvvehicle;
new pilotsfvehicle;
new pilotlsvehicle;
new shamalsfvehicle;
new hydrashipvehicle;
new lsairbikervehicle;
new busgrovetolsairvehicle;


public OnFilterScriptInit()
{  AddStaticVehicle(538, 1700.7551,-1953.6531,14.8756,200.0,-1,-1);
/*	ConnectNPC("TrainDriverLV","train_lv");
  traindriverlvvehicle=CreateVehicle(569, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);

	ConnectNPC("TrainDriverLS","train_ls");
	traindriverlsvehicle=CreateVehicle(569, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);
	
	ConnectNPC("TrainDriverSF","train_sf");
	traindriversfvehicle=CreateVehicle(569, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000); */
	
	ConnectNPC("PilotLV","at400_lv");
	pilotlvvehicle=CreateVehicle(577, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);

	ConnectNPC("PilotSF","at400_sf");
	pilotsfvehicle=CreateVehicle(577, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);

	ConnectNPC("PilotLS","at400_ls");
	pilotlsvehicle=CreateVehicle(577, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);
	
	ConnectNPC("SHAMALSFPILOT","shamalsf");
  shamalsfvehicle=CreateVehicle(519, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);

  ConnectNPC("HYDRASHIPPILOT","hydraship");
  hydrashipvehicle=CreateVehicle(520, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);
  
  ConnectNPC("LSAIRBIKER","lsairbiker");
  lsairbikervehicle=CreateVehicle(522, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);
  
  ConnectNPC("BUSGROVETOLSAIR","busgrovetolsair");
  busgrovetolsairvehicle=CreateVehicle(437, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);
  
  ConnectNPC("TrainDriverLStoLS","train_ls_to_ls");

	// Testing
	//ConnectNPC("TestIdle","onfoot_test");
	//ConnectNPC("TaxiTest","mat_test");
	
	return 1;
}

//-------------------------------------------------
// IMPORTANT: This restricts NPCs connecting from
// an IP address outside this server. If you need
// to connect NPCs externally you will need to modify
// the code in this callback.

public OnPlayerConnect(playerid)
{
	if(IsPlayerNPC(playerid))
 {
	  new ip_addr_npc[64+1];
	  new ip_addr_server[64+1];
	  GetServerVarAsString("bind",ip_addr_server,64);
	  GetPlayerIp(playerid,ip_addr_npc,64);
	  
		if(!strlen(ip_addr_server))
		{
		  ip_addr_server = "127.0.0.1";
		}
		
		if(strcmp(ip_addr_npc,ip_addr_server,true) != 0)
		{
		  // this bot is remote connecting
		  printf("NPC: Got a remote NPC connecting from %s and I'm kicking it.",ip_addr_npc);
		  Kick(playerid);
		  return 0;
		}
    printf("NPC: Connection from %s is allowed.",ip_addr_npc);
 }
	
	return 1;
}

//-------------------------------------------------

public OnPlayerRequestClass(playerid, classid)
{
	if(!IsPlayerNPC(playerid))
	return 0; // We only deal with NPC players in this script

	new playername[64];
	GetPlayerName(playerid,playername,64);

 	if(!strcmp(playername,"TrainDriverLV",true))
	{
    SetSpawnInfo(playerid,69,255,1462.0745,2630.8787,10.8203,0.0,-1,-1,-1,-1,-1,-1);
	}
	else if(!strcmp(playername,"TrainDriverSF",true))
	{
	  SetSpawnInfo(playerid,69,255,-1942.7950,168.4164,27.0006,0.0,-1,-1,-1,-1,-1,-1);
	}
	else if(!strcmp(playername,"TrainDriverLS",true))
	{
	  SetSpawnInfo(playerid,69,255,1700.7551,-1953.6531,14.8756,0.0,-1,-1,-1,-1,-1,-1);
	}
	else if(!strcmp(playername,"PilotLV",true))
	{
	  SetSpawnInfo(playerid,69,61,0.0,0.0,0.0,0.0,-1,-1,-1,-1,-1,-1);
	}
	else if(!strcmp(playername,"PilotSF",true))
	{
	  SetSpawnInfo(playerid,69,61,0.0,0.0,0.0,0.0,-1,-1,-1,-1,-1,-1);
	}
	else if(!strcmp(playername,"PilotLS",true))
	{
	  SetSpawnInfo(playerid,69,61,0.0,0.0,0.0,0.0,-1,-1,-1,-1,-1,-1);
	}
	else if(!strcmp(playername,"TestIdleDriver",true))
	{
	  SetSpawnInfo(playerid,69,61,0.0,0.0,0.0,0.0,-1,-1,-1,-1,-1,-1);
	}
	else if(!strcmp(playername,"TaxiTest",true))
	{
	  SetSpawnInfo(playerid,69,61,0.0,0.0,0.0,0.0,-1,-1,-1,-1,-1,-1);
	}
  else if(!strcmp(playername,"SHAMALSFPILOT",true))
	{
	  SetSpawnInfo(playerid,69,61,0.0,0.0,0.0,0.0,-1,-1,-1,-1,-1,-1);
	}
	else if(!strcmp(playername,"HYDRASHIPPILOT",true))
	{
	  SetSpawnInfo(playerid,287,61,0.0,0.0,0.0,0.0,-1,-1,-1,-1,-1,-1);
	}
	else if(!strcmp(playername,"LSAIRBIKER",true))
	{
	  SetSpawnInfo(playerid,178,178,0.0,0.0,0.0,0.0,-1,-1,-1,-1,-1,-1);
 	}
 	else if(!strcmp(playername,"BUSGROVETOLSAIR",true))
	{
	  SetSpawnInfo(playerid,61,61,0.0,0.0,0.0,0.0,-1,-1,-1,-1,-1,-1);
 	}
 	else if(!strcmp(playername,"TrainDriverLStoLS",true))
	{
	  SetSpawnInfo(playerid,61,61,0.0,0.0,0.0,0.0,-1,-1,-1,-1,-1,-1);
 	}
	return 0;
}

//-------------------------------------------------

public OnPlayerSpawn(playerid)
{
	if(!IsPlayerNPC(playerid))
	return 1;
	new playername[64];
	GetPlayerName(playerid,playername,64);

	if(!strcmp(playername,"TrainDriverLV",true))
	{
    PutPlayerInVehicle(playerid,traindriverlvvehicle,0);
    SetPlayerColor(playerid,0xFFFFFFFF);
    return 1;
 	}
	else if(!strcmp(playername,"TrainDriverSF",true))
	{
	  PutPlayerInVehicle(playerid,traindriversfvehicle,0);
	  SetPlayerColor(playerid,0xFFFFFFFF);
	  return 1;
	}
	else if(!strcmp(playername,"TrainDriverLS",true))
	{
	  PutPlayerInVehicle(playerid,traindriverlsvehicle,0);
	  SetPlayerColor(playerid,0xFFFFFFFF);
	  return 1;
	}
	else if(!strcmp(playername,"PilotLV",true))
	{
	  PutPlayerInVehicle(playerid,pilotlvvehicle,0);
	  SetPlayerColor(playerid,0xFFFFFFFF);
    return 1;
	}
	else if(!strcmp(playername,"PilotSF",true))
	{
	  PutPlayerInVehicle(playerid,pilotsfvehicle,0);
	  SetPlayerColor(playerid,0xFFFFFFFF);
	  return 1;
	}
	else if(!strcmp(playername,"PilotLS",true))
	{
	  PutPlayerInVehicle(playerid,pilotlsvehicle,0);
	  SetPlayerColor(playerid,0xFFFFFFFF);
	  return 1;
	}
	else if(!strcmp(playername,"TestIdleDriver",true))
	{
	  PutPlayerInVehicle(playerid,43,0);
	  SetPlayerColor(playerid,0xFFFFFFFF);
	  return 1;
	}
	else if(!strcmp(playername,"TaxiTest",true))
	{
	  PutPlayerInVehicle(playerid,968,0);
	  SetPlayerColor(playerid,0xFFFFFFFF);
	  return 1;
	}
 	else if(!strcmp(playername, "SHAMALSFPILOT", true))
  {
      PutPlayerInVehicle(playerid, shamalsfvehicle, 0);
      SetPlayerColor(playerid,0xFFFFFFFF);
      return 1;
  }
  else if(!strcmp(playername, "HYDRASHIPPILOT", true))
  {
      PutPlayerInVehicle(playerid, hydrashipvehicle, 0);
      SetPlayerColor(playerid,0xFFFFFFFF);
      return 1;
  }
  else if(!strcmp(playername, "LSAIRBIKER", true))
  {
      PutPlayerInVehicle(playerid, lsairbikervehicle, 0);
      SetPlayerColor(playerid,0xFFFFFFFF);
      return 1;
  }
  else if(!strcmp(playername, "BUSGROVETOLSAIR", true))
  {
      PutPlayerInVehicle(playerid, busgrovetolsairvehicle, 0);
      SetPlayerColor(playerid,0xFFFFFFFF);
      return 1;
  }
  else if(!strcmp(playername, "TrainDriverLStoLS", true))
  {
      PutPlayerInVehicle(playerid, 2, 0);
      SetPlayerColor(playerid,0xFFFFFFFF);
      return 1;
  }
	return 1;
}
Ok i an dealing with Traindriverlstols.
I added a static train as racer said it is there but how do i put the npc in the train?

Help?!
__________________
DJDhan is offline   Reply With Quote
Old 06/12/2009, 04:51 PM   #510
Angelus~
Big Clucker
 
Join Date: Aug 2009
Posts: 62
Reputation: 0
Default Re: Tutorial -> Creating a new NPC

Quote:
Originally Posted by V1ceC1ty
Quote:
Originally Posted by Angelus~
When i use the function PutPlayerInVehicle, the NPC doesn't go in and then disconnects from the server a couple seconds later whats going on?
are you doing it right? lets see the script.
Code:
#include <a_samp>

new vehicle;

public OnFilterScriptInit()
{
	ConnectNPC("1st","1st");
 	vehicle =	AddStaticVehicle(492,1071.8664,-1854.9331,13.1725, -90, 0, 0); // bus1
	return 1;
}

public OnPlayerSpawn(playerid)
{
  if(IsPlayerNPC(playerid))
  {
    new npcname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, npcname, sizeof(npcname));
    if(!strcmp(npcname, "1st", true))
    {
      PutPlayerInVehicle(playerid, vehicle, 0);
    }
    return 1;
  }
  return 1;
}
i noticed that the NPC doesn't disconnect if i remove PutPlayerInVehicle
but when i put it back, NPC disconnects like 5 seconds after i log on
Angelus~ is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
need help with NPC creating the_zande Help Archive 2 09/07/2010 11:44 PM
help creating a new gm Lookin Help Archive 8 16/06/2010 03:23 PM
I need a tut on creating kujox32 Help Archive 0 05/05/2010 02:16 AM
Creating Box VirSpectorX Help Archive 5 15/04/2010 02:47 PM
Help creating my own... x.X.LEGENDARIO.X.x Everything and Nothing 20 06/02/2010 03:40 PM


All times are GMT. The time now is 01:37 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.