NPC leaves 20 seconds after joining
#1

Hey guys,

I have been working on my own little GM that I will probably release sometime down the track, I'm fine with everything else but I have come across and issue with the Search and Rescue NPC that I created.

Before any of you tell me to read the tutorial on creating NPCs, I have already done that... Many times. There isn't a single issue in the script. I haven't implemented a login or AC system, so that's not the problem either.

My NPC connects, 20 seconds later it leaves. I have suspicions that the recording is either too long (3 minutes estimated) or because of the fact that the area, the NPC is flying in, is too far off of the map (remote island, just far enough that you cant see the map).

My GM is about a plane of convicts crashing near a deserted remote island and the survivors have got to fight to the death. A mix between BioShock and The Condemned. All I want to do is have this search and rescue helicopter fly over the island with a spot light for a couple of minutes and leave, then repeat the same thing after wards.

Could it be a problem with the recording or the distance from the San Andreas map? Any help much appreciated.
Reply
#2

Make sure all your functions can support NPC's..

If you have a function that kicks in 20 seconds later, make sure it has 'if(IsPlayerNPC(playerid)) return 1;' in it.
Reply
#3

It hates this part, when I remove it.. It stays. As soon as I implement it again, it leaves

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, "SearchAndRescue", true)) //Checking if the NPC's name is MyFirstNPC
    {
      PutPlayerInVehicle(playerid, SearchAndRescueVehicle, 0); //Putting the NPC into the vehicle we created for it.
    }
    return 1;
  }
  //Other stuff for normal players goes here!
  return 1;
}
Reply
#4

Sorry for the dubs but here is the NPC mini script:

FYI: The .rec file and the NPC mini script have the same file name.

pawn Код:
#include <a_npc>

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

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
Here is my script:

pawn Код:
#include <a_samp>
#include <a_npc>


main()
{
    print("\n----------------------------------");
    print("You are running Conshock");
    print("Made by iKlipse\n");
    print("\n----------------------------------");
}

new SearchAndRescueVehicle;

public OnGameModeInit()
{
    //Search and rescue NPC
    SearchAndRescueVehicle = CreateVehicle(497, 2834.17, -2042.44, 10.93, 0.0, 0, 1, -0);
    ConnectNPC("SearchAndRescue","searchnres");
    SetGameModeText("ConShock ALPHA");
    SetWeather(11); // (storm set)
    SetWorldTime(0); // (midnight)
    ShowPlayerMarkers(0);
    ShowNameTags(0);
    //Player classes
    AddPlayerClass(124, 3699.64, -3053.98, 0.11, 0, 0, 0, 0, 0, 0);
    //Giant lines of objects and pickups go here, I'm not posting them
  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, "SearchAndRescue", true)) //Checking if the NPC's name is MyFirstNPC
    {
      PutPlayerInVehicle(playerid, SearchAndRescueVehicle, 0); //Putting the NPC into the vehicle we created for it.
    }
    return 1;
  }
  //Other stuff for normal players goes here!
  return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
  if(IsPlayerNPC(playerid)) return 1;
  SetPlayerPos(playerid, 3428.33, -3124.33, 16.82);
    SetPlayerCameraPos(playerid, 3427.11, -3127.62, 16.82);
    SetPlayerCameraLookAt(playerid, 3429.82, -3123.52, 16.82);
    return 1;
}

public OnPlayerConnect(playerid)
{
  new pname[MAX_PLAYER_NAME], string[22 + MAX_PLAYER_NAME];
  GetPlayerName(playerid, pname, sizeof(pname));
  format(string, sizeof(string), "%s has entered The Island", pname);
  SendClientMessageToAll(0xAAAAAAAA, string);
  GameTextForPlayer(playerid,"~r~Welcome to ConShock~n~~w~By~n~~b~iKlipse",5000,5);
  SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, 1);
  SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL, 1);
  return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)