[Tutorial] Creating a new NPC
#21

I tried to use AddStaticVehicle but nothing changes.
The problem may be due to my gamemode?
Reply
#22

can bots use animations?

I have recorded action of foot with using of animations, and the result is just walking, and no animations. Preloading animation libraries don't help too. Or I just trying for nothing?
Reply
#23

Quote:
Originally Posted by SFather
can bots use animations?

I have recorded action of foot with using of animations, and the result is just walking, and no animations. Preloading animation libraries don't help too. Or I just trying for nothing?
Apply the animation to the NPC, and players who are close to it when you applied the animation will see the NPC with the animation.
Reply
#24

NPC = a Computer, Like playing Single Player.
Reply
#25

Quote:
Originally Posted by kc
Quote:
Originally Posted by SFather
can bots use animations?

I have recorded action of foot with using of animations, and the result is just walking, and no animations. Preloading animation libraries don't help too. Or I just trying for nothing?
Apply the animation to the NPC, and players who are close to it when you applied the animation will see the NPC with the animation.
thanx for answer.

it's so uncomfortable ;[
Reply
#26

hi, my npc not walking noob npc only waiting xD
and animations not working on npc

sorry my english is bad
Reply
#27

Hi, i made a NPC that walks around a little area here's the code:

Code:
#include <a_samp>
#include <a_npc>

public OnFilterScriptInit()
{
  ConnectNPC("Guy","ShinderNPC");
	return 1;
}

public OnRecordingPlaybackEnd() StartRecordingPlayback(2, ShinderNPC);
I have this error:
Code:
C:\Documents and Settings\Administrator\Desktop\ETC\GTA SA Stuff\sampserver0.3\filterscripts\NPCs.pwn(10) : warning 235: public function lacks forward declaration (symbol "OnRecordingPlaybackEnd")
C:\Documents and Settings\Administrator\Desktop\ETC\GTA SA Stuff\sampserver0.3\filterscripts\NPCs.pwn(10) : error 017: undefined symbol "StartRecordingPlayback"
i think every callback a_npc have doesn't work on this FS?
Or does the NPC really needs to just drive a stupid car but can't walk?
Reply
#28

Quote:
Originally Posted by Bcklup
Hi, i made a NPC that walks around a little area here's the code:

Code:
#include <a_samp>
#include <a_npc>

public OnFilterScriptInit()
{
  ConnectNPC("Guy","ShinderNPC");
	return 1;
}

public OnRecordingPlaybackEnd() StartRecordingPlayback(2, ShinderNPC);
I have this error:
Code:
C:\Documents and Settings\Administrator\Desktop\ETC\GTA SA Stuff\sampserver0.3\filterscripts\NPCs.pwn(10) : warning 235: public function lacks forward declaration (symbol "OnRecordingPlaybackEnd")
C:\Documents and Settings\Administrator\Desktop\ETC\GTA SA Stuff\sampserver0.3\filterscripts\NPCs.pwn(10) : error 017: undefined symbol "StartRecordingPlayback"
i think every callback a_npc have doesn't work on this FS?
Or does the NPC really needs to just drive a stupid car but can't walk?
<a_samp> and <a_npc> cannot be included properly in the same script. Remove <a_samp>
Reply
#29

now this error came along after i deleted "#include <a_samp>"

Code:
C:\Documents and Settings\Administrator\Desktop\ETC\GTA SA Stuff\sampserver0.3\filterscripts\NPCs.pwn(3) : warning 235: public function lacks forward declaration (symbol "OnFilterScriptInit")
C:\Documents and Settings\Administrator\Desktop\ETC\GTA SA Stuff\sampserver0.3\filterscripts\NPCs.pwn(5) : error 017: undefined symbol "ConnectNPC"
C:\Documents and Settings\Administrator\Desktop\ETC\GTA SA Stuff\sampserver0.3\filterscripts\NPCs.pwn(9) : warning 235: public function lacks forward declaration (symbol "OnPlayerSpawn")
C:\Documents and Settings\Administrator\Desktop\ETC\GTA SA Stuff\sampserver0.3\filterscripts\NPCs.pwn(11) : error 017: undefined symbol "IsPlayerNPC"
C:\Documents and Settings\Administrator\Desktop\ETC\GTA SA Stuff\sampserver0.3\filterscripts\NPCs.pwn(11) : error 017: undefined symbol "SetPlayerSkin"
C:\Documents and Settings\Administrator\Desktop\ETC\GTA SA Stuff\sampserver0.3\filterscripts\NPCs.pwn(14) : error 017: undefined symbol "ShinderNPC"
lol BTW i added this liiittle script before i compiled w/o #include <a_samp>

Code:
public OnPlayerSpawn(playerid)
{
	if(IsPlayerNPC(playerid) == 1) SetPlayerSkin(playerid, 29);
}
no error or warnings about that when #include <a_samp> was included


EDIT: Almost Fixed it now it says:
Code:
C:\Documents and Settings\Administrator\Desktop\ETC\GTA SA Stuff\sampserver0.3\filterscripts\NPCs.pwn(6) : error 017: undefined symbol "ConnectNPC"
Reply
#30

As I understand, your script is a filterscript and not npcmode, right? If so, include a_samp instead of a_npc.
Reply
#31

Quote:
Originally Posted by ZeeX
As I understand, your script is a filterscript and not npcmode, right? If so, include a_samp instead of a_npc.
sorry for not telling but i fixed it already only on problem, The NPCs spawn at any random time and not at the time i want them to spawn, and they dont move
Reply
#32

pawn Code:
#include <a_samp>

new MyFirstNPCVehicle;
public OnFilterScriptInit()
{
  print("my filterscript");
  ConnectNPC("MyFirstNPC","hydrapilot");
  MyFirstNPCVehicle = CreateVehicle(520, 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;
}
Whats wrong there? I've done all correct but the bot still stay at the same pos. i think PutPLayerInVehicle don't work, but why?
Reply
#33


sorry, there is a solution to my problem?
Reply
#34

Quote:
Originally Posted by Cedimedi
pawn Code:
#include <a_samp>

new MyFirstNPCVehicle;
public OnFilterScriptInit()
{
  print("my filterscript");
  ConnectNPC("MyFirstNPC","hydrapilot");
  MyFirstNPCVehicle = CreateVehicle(520, 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;
}
Whats wrong there? I've done all correct but the bot still stay at the same pos. i think PutPLayerInVehicle don't work, but why?
OnPlayerRequestClass , if the player is an NPC you have to return 1....
Reply
#35

I edited now a FS from the pack or somewhere.

pawn Code:
#include <a_samp>

new hydra;

public OnGameModeInit()
{
    ConnectNPC("Driver","hydrapilotA");
    hydra = AddStaticVehicle(520,2044.8854,1473.2106,10.4494,181.3339,6,1); // Taxi
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    return 1;
}

public OnPlayerConnect(playerid)
{
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
  if(IsPlayerNPC(playerid)) //Checks if the player is an NPC.
  {
    new npcname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, npcname, sizeof(npcname));
    if(!strcmp(npcname, "Driver", true))
    {
      PutPlayerInVehicle(playerid, hydra, 0);
    }
  }
  return 1;
}
Now it still don't work, the Bot don't spawn... only after /rcon gmx but then he do nothing just stay arround... omg im tired of scripting :/
Reply
#36

I got problem..
Its creating vehicle, But nobody drive on it.
I did all the things are needed in the folder npcmodes.

The amx I called: Police_PatrolNPC

Here what I did:


Top:
Quote:

new NPCP;

OnGameModeInit:
Quote:

ConnectNPC("PoliceMan_","Police_PatrolNPC");
NPCP = CreateVehicle(596,1535.8658,-1668.4530,13.0795,358.5437,1,0, 5000);




OnPlayerSpawn:
Quote:

if(IsPlayerNPC(playerid))
{
new npcname[MAX_PLAYER_NAME];
GetPlayerName(playerid, npcname, sizeof(npcname)); //Getting the NPC's name.
if(!strcmp(npcname, "PoliceMan_", true)) //Checking if the NPC's name is MyFirstNPC
{
//SetPlayerSkin(playerid, 280);
PutPlayerInVehicle(playerid, NPCP, 0); //Putting the NPC into the vehicle we created for it.
//SetSpawnInfo( playerid, 0, 280, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0 );
}
return 1;
}



And In Police_PatrolNPC, I wrote:

Quote:

#define RECORDING "Police_Patrol" //This is the filename of your recording without the extension.
#define RECORDING_TYPE 1 //1 for in vehicle and 2 for on foot.

#include <a_npc>
main(){}
public OnRecordingPlaybackEnd() StartRecordingPlayback(RECORDING_TYPE, RECORDING);
public OnNPCEnterVehicle(vehicleid, seatid) StartRecordingPlayback(RECORDING_TYPE, RECORDING);
public OnNPCExitVehicle() StopRecordingPlayback();

And the bot is stays high in the sky,
And he doesn't spawn to the vehicle.























edit:
I did Police man walking..
He is spawn to the walk place, but he is not walking!
Reply
#37

Quote:
Originally Posted by _Ben_[Fux-c.co.il RP
]
I got problem..
Its creating vehicle, But nobody drive on it.
I did all the things are needed in the folder npcmodes.
Look at the define in the "mini" script... (and especially its comment)

pawn Code:
#define RECORDING_TYPE 1 //1 for in vehicle and 2 for on foot.
Reply
#38

How can i download server for samp 0.3?? if there are scripts so samp and servers are onnline?? Can somebody tell me where to download samp 0.3 and server to it?? thanks
Reply
#39

Hey guys,im new to this,i got many errors on the gamemode script so i just created a filterscript.
I still get errors lol can anyone help?

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;
}
BOT is the filename.
Errors:
Code:
C:\Program Files\gta.sa\GTA San Andreas\filterscripts\npc_test_2.pwn(1) : warning 235: public function lacks forward declaration (symbol "OnFilterScriptInit")
C:\Program Files\gta.sa\GTA San Andreas\filterscripts\npc_test_2.pwn(3) : error 017: undefined symbol "print"
C:\Program Files\gta.sa\GTA San Andreas\filterscripts\npc_test_2.pwn(4) : error 017: undefined symbol "ConnectNPC"
C:\Program Files\gta.sa\GTA San Andreas\filterscripts\npc_test_2.pwn(9) : warning 235: public function lacks forward declaration (symbol "OnFilterScriptInit")
C:\Program Files\gta.sa\GTA San Andreas\filterscripts\npc_test_2.pwn(10) : error 021: symbol already defined: "OnFilterScriptInit"
C:\Program Files\gta.sa\GTA San Andreas\filterscripts\npc_test_2.pwn(11) : error 017: undefined symbol "print"
C:\Program Files\gta.sa\GTA San Andreas\filterscripts\npc_test_2.pwn(12) : error 017: undefined symbol "ConnectNPC"
C:\Program Files\gta.sa\GTA San Andreas\filterscripts\npc_test_2.pwn(13) : error 017: undefined symbol "CreateVehicle"
C:\Program Files\gta.sa\GTA San Andreas\filterscripts\npc_test_2.pwn(17) : warning 235: public function lacks forward declaration (symbol "OnPlayerSpawn")
C:\Program Files\gta.sa\GTA San Andreas\filterscripts\npc_test_2.pwn(19) : error 017: undefined symbol "IsPlayerNPC"
C:\Program Files\gta.sa\GTA San Andreas\filterscripts\npc_test_2.pwn(21) : error 017: undefined symbol "MAX_PLAYER_NAME"
C:\Program Files\gta.sa\GTA San Andreas\filterscripts\npc_test_2.pwn(21) : error 009: invalid array size (negative, zero or out of bounds)
C:\Program Files\gta.sa\GTA San Andreas\filterscripts\npc_test_2.pwn(21) : error 036: empty statement
C:\Program Files\gta.sa\GTA San Andreas\filterscripts\npc_test_2.pwn(21) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase
Can anyone fix it and post it or just help me?thanks very much!
Reply
#40

Very nice tutorial, it cleared up a few things for me. Thanks KC.

*******, you need to use the includes. Silly boy
Code:
#include <a_samp> // top of script
Quote:
Originally Posted by matrix_smq
Having problems when adding a NPC, i added
Code:
if(IsPlayerNPC(playerid)) return 1;
everywhere and still... the NPC connects and after like 20-30 seconds it times out, any ideas?
You're not telling people enough information. which callback is that code from? What does the console say? What GM are you using?

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)