NPC help, ignored in NPC tutorial, plz help!
#1

hi there

i was ignored in the NPC topic so i came here,

the problem is, that the npc spawns, but where the spawn point is, not in a car etc...

here is my script

Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>

#if defined FILTERSCRIPT


public OnFilterScriptExit()
{
	return 1;
}

#else

main()
{
	print("\n------------------------------------------");
	print(" TDM and FREEROAM BY SLASH01 'n' IRON MAN");
	print("------------------------------------------\n");
}

#endif
new VanManVehicle; //Global variable!
new StripManVehicle; //Global variable!
new PoliceManVehicle; //Global variable!

public OnGameModeInit()
{
	// Don't use these lines if it's a filterscript
	SetGameModeText("Slash01's Freeroam");

  ConnectNPC("VanMan","vanlv");
  VanManVehicle = CreateVehicle(498, 0.0, 0.0, 5.0, 0.0, 0, 1, 5000);
  ConnectNPC("StripMan","strip");
  StripManVehicle = CreateVehicle(517, 0.0, 0.0, 5.0, 0.0, 0, 1, 5000);
  ConnectNPC("PoliceMan","police");
  StripManVehicle = CreateVehicle(598, 0.0, 0.0, 5.0, 0.0, 0, 1, 5000);
  
	return 1;
}

public OnGameModeExit()
{
	return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
	SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
	return 1;
}

public OnPlayerConnect(playerid)
{
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	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, "VanMan", true)) //Checking if the NPC's name is MyFirstNPC
    {
      PutPlayerInVehicle(playerid, VanManVehicle, 0); //Putting the NPC into the vehicle we created for it.
      return 1;
    }
    if(!strcmp(npcname, "StripMan", true))
    {
      PutPlayerInVehicle(playerid, StripManVehicle, 0);
      return 1;
    }
    if(!strcmp(npcname, "PoliceMan", true))
    {
      PutPlayerInVehicle(playerid, PoliceManVehicle, 0);
      return 1;
    }
    return 1;
  }
  //Other stuff for normal players goes here!
  return 1;
}
i have made the small files in the npcmodes etc, and stoill it dont work... the other two work though....
Reply
#2

Quote:
Originally Posted by Slash01 (now known as Iron_Man)
hi there

i was ignored in the NPC topic so i came here,

the problem is, that the npc spawns, but where the spawn point is, not in a car etc...

here is my script

Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>

#if defined FILTERSCRIPT


public OnFilterScriptExit()
{
	return 1;
}

#else

main()
{
	print("\n------------------------------------------");
	print(" TDM and FREEROAM BY SLASH01 'n' IRON MAN");
	print("------------------------------------------\n");
}

#endif
new VanManVehicle; //Global variable!
new StripManVehicle; //Global variable!
new PoliceManVehicle; //Global variable!

public OnGameModeInit()
{
	// Don't use these lines if it's a filterscript
	SetGameModeText("Slash01's Freeroam");

  ConnectNPC("VanMan","vanlv");
  VanManVehicle = CreateVehicle(498, 0.0, 0.0, 5.0, 0.0, 0, 1, 5000);
  ConnectNPC("StripMan","strip");
  StripManVehicle = CreateVehicle(517, 0.0, 0.0, 5.0, 0.0, 0, 1, 5000);
  ConnectNPC("PoliceMan","police");
  StripManVehicle = CreateVehicle(598, 0.0, 0.0, 5.0, 0.0, 0, 1, 5000);
  
	return 1;
}

public OnGameModeExit()
{
	return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
	SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
	return 1;
}

public OnPlayerConnect(playerid)
{
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	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, "VanMan", true)) //Checking if the NPC's name is MyFirstNPC
    {
      PutPlayerInVehicle(playerid, VanManVehicle, 0); //Putting the NPC into the vehicle we created for it.
      return 1;
    }
    if(!strcmp(npcname, "StripMan", true))
    {
      PutPlayerInVehicle(playerid, StripManVehicle, 0);
      return 1;
    }
    if(!strcmp(npcname, "PoliceMan", true))
    {
      PutPlayerInVehicle(playerid, PoliceManVehicle, 0);
      return 1;
    }
    return 1;
  }
  //Other stuff for normal players goes here!
  return 1;
}
i have made the small files in the npcmodes etc, and stoill it dont work... the other two work though....
pawn Код:
VanManVehicle = CreateVehicle(498, 0.0, 0.0, 5.0, 0.0, 0, 1, 5000);
  ConnectNPC("StripMan","strip");
  -> StripManVehicle = CreateVehicle(517, 0.0, 0.0, 5.0, 0.0, 0, 1, 5000);
  ConnectNPC("PoliceMan","police");
  -> StripManVehicle = CreateVehicle(598, 0.0, 0.0, 5.0, 0.0, 0, 1, 5000);
Same Variable. Change it and it'll work =D
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)