SA-MP Forums Archive
[Tutorial] Creating a new NPC - 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: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] Creating a new NPC (/showthread.php?tid=95034)

Pages: 1 2 3 4 5 6 7 8


Re: Tutorial -> Creating a new NPC - Youtube - 30.11.2009

Thanks [LSD]Rac3r,it fixed many errors,i have only 1 error now.

OLD SCRIPT:

Code:
public OnFilterScriptInit()
{
  print("my filterscript");
  ConnectNPC("MyFirstNPC","BOT");
  return 1;
}

new MyFirstNPCVehicle; //Global variable!
public OnFilterScriptInit()
{
  print("my filterscript");
  ConnectNPC("MyFirstNPC","BOT");
  MyFirstNPCVehicle = CreateVehicle(400, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);
  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, "MyFirstNPC", true)) //Checking if the NPC's name is MyFirstNPC
    {
      PutPlayerInVehicle(playerid, MyFirstNPCVehicle, 0); //Putting the NPC into the vehicle we created for it.
    }
    return 1;
  }
  //Other stuff for normal players goes here!
  return 1;
}
NEW SCRIPT:

Code:
#include <a_samp>

public OnFilterScriptInit()
{
  print("my filterscript");
  ConnectNPC("MyFirstNPC","bot");
  MyFirstNPCVehicle = CreateVehicle(400, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);
	return 1;
}

new MyFirstNPCVehicle; //Global variable!

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, "MyFirstNPC", true)) //Checking if the NPC's name is MyFirstNPC
    {
      PutPlayerInVehicle(playerid, MyFirstNPCVehicle, 0); //Putting the NPC into the vehicle we created for it.
    }
    return 1;
  }
  //Other stuff for normal players goes here!
  return 1;
}
As you see i deleted like 2-3 lines:

Code:
  print("my filterscript"); - deleted
  ConnectNPC("MyFirstNPC","BOT"); - deleted
  MyFirstNPCVehicle = CreateVehicle(400, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000); -I LEFT ONLY THIS LINE AND PUTTED IT NEAR THE TOP OF THE SCRIPT
  return 1; - deleted
So,was it right or now ill have a prob

LAST ERROR!:

Code:
C:\Program Files\gta.sa\GTA San Andreas\filterscripts\npc_test_2.pwn(7) : error 017: undefined symbol "MyFirstNPCVehicle"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Or if it wasnt right to delete the 2-3 lines,here is the other script:

Code:
#include <a_samp>

public OnFilterScriptInit()
{
  print("my filterscript");
  ConnectNPC("MyFirstNPC","BOT");
  return 1;
}

new MyFirstNPCVehicle; //Global variable!
public OnFilterScriptInit()
{
  print("my filterscript");
  ConnectNPC("MyFirstNPC","BOT");
  MyFirstNPCVehicle = CreateVehicle(400, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);
  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, "MyFirstNPC", true)) //Checking if the NPC's name is MyFirstNPC
    {
      PutPlayerInVehicle(playerid, MyFirstNPCVehicle, 0); //Putting the NPC into the vehicle we created for it.
    }
    return 1;
  }
  //Other stuff for normal players goes here!
  return 1;
}
ERROR:

Code:
C:\Program Files\gta.sa\GTA San Andreas\filterscripts\npc_test_2.pwn(12) : error 021: symbol already defined: "OnFilterScriptInit"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Thanks for the help!

EDIT: Lol i fixed it,Is this script OK?

Code:
#include <a_samp>

new MyFirstNPCVehicle; //Global variable!

public OnFilterScriptInit()
{
  print("my filterscript");
  ConnectNPC("MyFirstNPC","BOT");
  MyFirstNPCVehicle = CreateVehicle(400, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);
	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, "MyFirstNPC", true)) //Checking if the NPC's name is MyFirstNPC
    {
      PutPlayerInVehicle(playerid, MyFirstNPCVehicle, 0); //Putting the NPC into the vehicle we created for it.
    }
    return 1;
  }
  //Other stuff for normal players goes here!
  return 1;
}



Re: Tutorial -> Creating a new NPC - Rac3r - 30.11.2009

Yay you fixed it. Yes, that's looks pretty legit. Try it and find out


Re: Tutorial -> Creating a new NPC - Youtube - 30.11.2009

Finally works with [LSD]Rac3r's help!


Re: Tutorial -> Creating a new NPC - Franjdea - 30.11.2009

Didn't work, it just stands at the spawn point and I looked back at it and I don't know whats wrong..


Re: Tutorial -> Creating a new NPC - DJDhan - 03.12.2009

Very Nice tutorial!!!

Dude,when i try to record the vehicle path and use /stoprecord.It says it stopped recording.
Then i close the game and go to my npcmodes--->recordings and my recording is not there

Any help??


Re: Tutorial -> Creating a new NPC - Joe Staff - 03.12.2009

Recordings aren't saved in "scriptfiles/npcmodes/recordings/", They're saved in "scriptfiles/".


Re: Tutorial -> Creating a new NPC - DJDhan - 04.12.2009

Oh dude thanx a lot
Now i will work with the script part!


Re: Tutorial -> Creating a new NPC - DJDhan - 04.12.2009

An hey sorry for double posting... .
I want to know when i record a path,does it save the speed at which i record it too?or just the line of path that will be used and the speed of the vehicle will be set automatically?

Please help...


Re: Tutorial -> Creating a new NPC - HydraX - 02.01.2010

Quote:
Originally Posted by -Ranny[BR
]
I did everything right to put the npc is standing in the spawn, as did a friend has the same thing, I wonder if some ai can pass me a ready script saying where to put every thing is where can I change what's there if I fara jmudar .... please go through pm thanks.

****** translator.
I have the same problem also, but this only happens in he latest version of 0.3


Re: Tutorial -> Creating a new NPC - DRIFT_HUNTER - 03.01.2010

yea me2


Re: Tutorial -> Creating a new NPC - FragMonkey - 03.01.2010

I have been reading through this thread, and it seems like the only way to make a npc do something is through recordings.

Is there any way to NOT do a recording and have bots perform actions?

As an example, is it possible to have an NPC police officer that attempts to converge on your location when you have a wanted level?

Whether or not the above example is easy to do or not, I am looking for a way for bots to hang around the game world until something happens, and then have them perform actions, instead of recording their every move.


Re: Tutorial -> Creating a new NPC - rs2fun111 - 03.01.2010

errors :S

Code:
C:\Users\kalvi\Desktop\sa-mp\gamemodes\npcrecord.pwn(15) : warning 235: public function lacks forward declaration (symbol "OnFilterScriptInit")
C:\Users\kalvi\Desktop\sa-mp\gamemodes\npcrecord.pwn(18) : error 017: undefined symbol "ConnectNPC"
C:\Users\kalvi\Desktop\sa-mp\gamemodes\npcrecord.pwn(19) : error 017: undefined symbol "plane"
C:\Users\kalvi\Desktop\sa-mp\gamemodes\npcrecord.pwn(19) : error 017: undefined symbol "CreateVehicle"
C:\Users\kalvi\Desktop\sa-mp\gamemodes\npcrecord.pwn(22) : warning 235: public function lacks forward declaration (symbol "OnPlayerSpawn")
C:\Users\kalvi\Desktop\sa-mp\gamemodes\npcrecord.pwn(24) : error 017: undefined symbol "IsPlayerNPC"
C:\Users\kalvi\Desktop\sa-mp\gamemodes\npcrecord.pwn(30) : error 017: undefined symbol "PutPlayerInVehicle"
C:\Users\kalvi\Desktop\sa-mp\gamemodes\npcrecord.pwn(36) : warning 203: symbol is never used: "MyFirstNPCVehicle"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


5 Errors.



Re: Tutorial -> Creating a new NPC - Mauri - 05.01.2010

Is there a tutorial how i can create an KI-Bot?
On a Server, i have see a bot and he has killing some player
and was driving behind them with a car. How can i made
it too? It was awesome!


Re: Tutorial -> Creating a new NPC - gozo12 - 09.01.2010

how to fix this



My NPC doesn't join my server at all
This is most likely caused by your server being passworded.


yes it is how can ifix this ?? i make account for npc but not working



Re: Tutorial -> Creating a new NPC - braduz - 10.01.2010

OMFG HELP it wont even record


Re: Tutorial -> Creating a new NPC - Bearfist - 14.01.2010

My Bot is invincible =O
..help


Re: Tutorial -> Creating a new NPC - braduz - 14.01.2010

Quote:
Originally Posted by Bearfist
My Bot is invincible =O
..help
FACEPALM


Re: Tutorial -> Creating a new NPC - Bearfist - 14.01.2010

What ? ...
are they normally invincible or whats the matter ?!


Re: Tutorial -> Creating a new NPC - selten98 - 08.07.2010

I had a lot about this Tutorial


Re: Creating a new NPC - GangsTa_ - 10.07.2010

How to make standing NPCs, don't doing any movement?