SA-MP Forums Archive
NPC connect - 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 connect (/showthread.php?tid=354334)



NPC connect - Roko_foko - 26.06.2012

I want to connect a NPC and put it stay on one point.
I've read "[Tutorial] Creating a new NPC" by kc and still don't know where is the problem.
I hope you will find it.


The NPC can't connect.( Incoming connection: 127.0.0.1:55033, but nothing else)
From gamemode:
Код:
public OnGameModeInit()
{
       //...
       ConnectNPC("[NPC]Policeman","Policeman");
	   return 1;
}
public OnPlayerConnect(playerid)
{
    if (IsPlayerNPC(playerid))
    {
		GetPlayerName(playerid,gPlayerAccountName[playerid],MAX_PLAYER_NAME);
		if(!strcmp(gPlayerAccountName[playerid],"Policeman"))
		{
		    SetPlayerPos(playerid,251.2565,67.6969,1003.6406);
		    SetPlayerFacingAngle(playerid,89.3009);
		    SetPlayerInterior(playerid,6);
		    SetPlayerVirtualWorld(playerid,0);
		}
		return 1;
    }
    //...
}
NPC script which is in .../npcmodes
Код:
#define RECORDING "Policeman"
#define RECORDING_TYPE 2

#include <a_npc>

main(){}
public OnNPCModeInit()
{
    printf("NPC script loaded");
    return 1;
}
public OnNPCModeExit()
{
    print("NPC script unloaded");
    return 1;
}
public OnNPCConnect(myplayerid)
{
    printf("I successfully connected the server with ID %i!", myplayerid);
}
public OnNPCDisconnect(reason[])
{
    printf("Bot has been disconnected from the server. %s", reason);
}
public OnNPCSpawn()
{
    StartRecordingPlayback(RECORDING_TYPE, RECORDING);
    printf("NPC spawned");
    return 1;
}
public OnRecordingPlaybackEnd()
{
    StartRecordingPlayback(RECORDING_TYPE, RECORDING);
}
I have the "Policeman.rec" in .../npcmodes/recordings. I think the recording isn't necessary, but after it didn't work i put it just dor safety. recording= staying on one position.
Please help!
Thank you in advance!


Re: NPC connect - MadeMan - 26.06.2012

Did you set 'maxnpc' in server.cfg ?


Re: NPC connect - Roko_foko - 26.06.2012

No I didn't. That solved the problem. Thank you rep+