[Tutorial] Creating a new NPC
#41

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

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

Finally works with [LSD]Rac3r's help!
Reply
#44

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

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??
Reply
#46

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

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

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...
Reply
#49

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
Reply
#50

yea me2
Reply
#51

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.
Reply
#52

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.
Reply
#53

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!
Reply
#54

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
Reply
#55

OMFG HELP it wont even record
Reply
#56

My Bot is invincible =O
..help
Reply
#57

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

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

I had a lot about this Tutorial
Reply
#60

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


Forum Jump:


Users browsing this thread: 7 Guest(s)