SA-MP Forums Archive
npc problems - 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)
+--- Thread: npc problems (/showthread.php?tid=290646)



npc problems - manchestera - 16.10.2011

Ok ill trying to create a vehicle npc but failed tbh i am getting alot of errors so i think its something to do mith my { or } as i always mess them up if you dont mind having a look please do.

Many thanks.

Код:
ConnectNPC("Captian Dave","area51tank1");//top of the script
new MyFirstNPCVehicle;//top of the script

public OnGameModeInit()
{
  print("COD5");
  ConnectNPC("MyFirstNPC","area51tank1");
{
  print("COD5");
  ConnectNPC("MyFirstNPC","area51tank1");
  MyFirstNPCVehicle = CreateVehicle(432, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);
{



public OnPlayerSpawn(playerid)
{
  if(IsPlayerNPC(playerid))
  {
    new npcname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, npcname, sizeof(Captian Dave)); 
    if(!strcmp(npcname, "MyFirstNPC", true)) 
    {
      PutPlayerInVehicle(playerid, MyFirstNPCVehicle, 0);
    }
    return 1;
  }
Код:
C:\Users\GTA ONLY\Desktop\codmw21\codmw2\gamemodes\COD5.pwn(28) : error 021: symbol already defined: "ConnectNPC"
C:\Users\GTA ONLY\Desktop\codmw21\codmw2\gamemodes\COD5.pwn(1025) : error 017: undefined symbol "GetPlayerSpeedSpeedo"
C:\Users\GTA ONLY\Desktop\codmw21\codmw2\gamemodes\COD5.pwn(1034) : error 017: undefined symbol "IsPlayerInPlane"
C:\Users\GTA ONLY\Desktop\codmw21\codmw2\gamemodes\COD5.pwn(1035) : error 017: undefined symbol "GetPlayerSpeedSpeedo"
C:\Users\GTA ONLY\Desktop\codmw21\codmw2\gamemodes\COD5.pwn(1036) : error 017: undefined symbol "GetPlayerSpeedSpeedo"
C:\Users\GTA ONLY\Desktop\codmw21\codmw2\gamemodes\COD5.pwn(1096) : error 017: undefined symbol "GetPlayerSpeed"
C:\Users\GTA ONLY\Desktop\codmw21\codmw2\gamemodes\COD5.pwn(1097) : error 017: undefined symbol "IsPlayerInPlane"
C:\Users\GTA ONLY\Desktop\codmw21\codmw2\gamemodes\COD5.pwn(1105) : error 004: function "SendClientMessageToAdmins" is not implemented
C:\Users\GTA ONLY\Desktop\codmw21\codmw2\gamemodes\COD5.pwn(1144) : error 004: function "MutePlayer" is not implemented
C:\Users\GTA ONLY\Desktop\codmw21\codmw2\gamemodes\COD5.pwn(1270) : warning 217: loose indentation
C:\Users\GTA ONLY\Desktop\codmw21\codmw2\gamemodes\COD5.pwn(1274) : warning 217: loose indentation
C:\Users\GTA ONLY\Desktop\codmw21\codmw2\gamemodes\COD5.pwn(2242) : error 079: inconsistent return types (array & non-array)
C:\Users\GTA ONLY\Desktop\codmw21\codmw2\gamemodes\COD5.pwn(2246) : warning 225: unreachable code
C:\Users\GTA ONLY\Desktop\codmw21\codmw2\gamemodes\COD5.pwn(2246) : error 029: invalid expression, assumed zero
C:\Users\GTA ONLY\Desktop\codmw21\codmw2\gamemodes\COD5.pwn(2246) : error 004: function "OnGameModeExit" is not implemented
C:\Users\GTA ONLY\Desktop\codmw21\codmw2\gamemodes\COD5.pwn(2255) : error 079: inconsistent return types (array & non-array)
C:\Users\GTA ONLY\Desktop\codmw21\codmw2\gamemodes\COD5.pwn(2259) : warning 225: unreachable code
C:\Users\GTA ONLY\Desktop\codmw21\codmw2\gamemodes\COD5.pwn(2259) : error 029: invalid expression, assumed zero



Re: npc problems - Kostas' - 16.10.2011

First of all you have the same NPC 2 times
pawn Код:
public OnGameModeInit()
{
  ConnectNPC("MyFirstNPC","area51tank1");
  ConnectNPC("MySecondNPC","area51tank2"); //If you want 2nd npc
  return 1;
}
Then if the npc are on vehicl you should kreate one for them
pawn Код:
new MyFirstNPCVehicle; //MyFirstNPC replace the NPC's name if you want to change it
If the NPC is on foot skip this
pawn Код:
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: npc problems - manchestera - 16.10.2011

Ok i changed it now into a fs what compiles fine but the npc is connecting then disconnecting striaght away i added

if(IsPlayerNPC(playerid)) return 1; toall the onplayerrequest


Re: npc problems - Kostas' - 16.10.2011

check again at
pawn Код:
if(IsPlayerNPC(playerid)) return 1;



Re: npc problems - manchestera - 16.10.2011

I have put it in every onplayer and it is still disconnecting is there anyting wrong with this


Код:
#define RECORDING "area51tank1" //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);

#if RECORDING_TYPE == 1
  public OnNPCEnterVehicle(vehicleid, seatid) StartRecordingPlayback(RECORDING_TYPE, RECORDING);
  public OnNPCExitVehicle() StopRecordingPlayback();
#else
  public OnNPCSpawn() StartRecordingPlayback(RECORDING_TYPE, RECORDING);
#endif



Re: npc problems - Kostas' - 16.10.2011

Except this, show me tha part for the npc you have n your gamemode or filterscript.


Re: npc problems - manchestera - 16.10.2011

Im a retard -.- didnt move the npc recording to /npc/recordings -.- working now sorry for wasting your time what you said at first still helped so thankyou for your time.


Re: npc problems - Kostas' - 16.10.2011

Quote:
Originally Posted by manchestera
Посмотреть сообщение
Im a retard -.- didnt move the npc recording to /npc/recordings -.- working now sorry for wasting your time what you said at first still helped so thankyou for your time.
xD, No Problem dude!


Re: npc problems - manchestera - 16.10.2011

Big LOL now ive added a second npc but all it has done is make my tank that was working fine into a flying tank.
So the 1st npc vehicle is being used as the second npc vehicle what is a hunter XD so ive messed up someone where as i have one npc one vehicle but a flying tank XD

Код:
#if defined FILTERSCRIPT

new MyFirstNPCVehicle;
new MySecondNPCVehicle; //Global variable!
public OnFilterScriptInit()
{
  print("my filterscript");
  ConnectNPC("MyFirstNPC","area51tank1");
  ConnectNPC("MyFirstNPC","area51hunter1");
  MyFirstNPCVehicle = CreateVehicle(432, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);
  MySecondNPCVehicle = CreateVehicle(425, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);
  return 1;
}

public OnFilterScriptExit()
{
	return 1;
}

#else

#endif

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;
    }
    if(!strcmp(npcname, "MySecondNPC", true))
    {
      PutPlayerInVehicle(playerid, MySecondNPCVehicle, 0);
      return 1;
    }
    return 1;
  }
  //Other stuff for normal players goes here!
  return 1;
}
Many thanks


Re: npc problems - Kostas' - 16.10.2011

Erm..Same name
Replace this
pawn Код:
public OnFilterScriptInit()
{
  print("my filterscript");
  ConnectNPC("MyFirstNPC","area51tank1");
  ConnectNPC("MyFirstNPC","area51hunter1");
  MyFirstNPCVehicle = CreateVehicle(432, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);
  MySecondNPCVehicle = CreateVehicle(425, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);
  return 1;
}
To
pawn Код:
public OnFilterScriptInit()
{
  print("my filterscript");
  ConnectNPC("MyFirstNPC","area51tank1");
  ConnectNPC("MySecondNPC","area51hunter1");
  MyFirstNPCVehicle = CreateVehicle(432, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);
  MySecondNPCVehicle = CreateVehicle(425, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);
  return 1;
}