SA-MP Forums Archive
Need help with NPC - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Need help with NPC (/showthread.php?tid=186144)



Need help with NPC - corne - 27.10.2010

Filterscript:
Код:
//Rhino driver

#include <a_samp>
#include <a_npc>

new rhinodriver;

public OnFilterScriptInit()
{
	ConnectNPC("rhino","rhino");
	rhinodriver = CreateVehicle(432, 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, "rhino", true)) //Checking if the NPC's name is MyFirstNPC
    	{
      		PutPlayerInVehicle(playerid, rhinodriver, 0); //Putting the NPC into the vehicle we created for it.
    	}
    	return 1;
  	}
  	return 1;
}
Npcmodes script:
Код:
#define RECORDING "rhino" //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
The NPC spawns at his spawn place but dont moves, i alreadly tried to fix it but i cant, its something with OnPlayerSpawn. Anyone can help me?


Re: Need help with NPC - Backwardsman97 - 27.10.2010

The only thing I can think of is to remove the include for a_npc from the filter script. It's not supposed to be there.


Re: Need help with NPC - boelie - 27.10.2010

*dont use createvehicle use addstaticvehicle
*try to 'not' to name the npc name and filename the same
*check if the recording file is in the right place


Re: Need help with NPC - Backwardsman97 - 28.10.2010

If he didn't use createvehicle, he couldn't get the vehicle id.


Re: Need help with NPC - Scenario - 28.10.2010

I noticed that you were "returning 1" when it wasn't necessary. I would replace your "OnPlayerSpawn" with 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, "rhino", true)) //Checking if the NPC's name is MyFirstNPC
        {
            PutPlayerInVehicle(playerid, rhinodriver, 0); //Putting the NPC into the vehicle we created for it.
        }
    }
    return 1;
}
Just make sure that in your 'server.cfg' file, you have identified that you have NPC's in your server. Simply change this line:

Код:
maxnpc 0
Obviously replacing 0 with however many NPC's you have.


Re: Need help with NPC - Blade_Cervetti - 28.10.2010

I am having a problem like this but the only difference is, I have 4 npcs that load right and 2 that wont. One joins then shortly leaves and the other doesnt join at all!


Re: Need help with NPC - Scenario - 28.10.2010

You should double check this:

Quote:

Just make sure that in your 'server.cfg' file, you have identified that you have NPC's in your server. Simply change this line:

Код:
maxnpc 0
Obviously replacing 0 with however many NPC's you have.




Re: Need help with NPC - Blade_Cervetti - 28.10.2010

Its a 32 slot server and I have enabled 10 npcs when I only have 6