Hello, so what you got to do so that the NPC doesn't spawn and acts like an invalid player is the following (you can also use a player variable if you don't want to use gvar):
Download gvar:
https://sampforum.blast.hk/showthread.php?tid=151076
Your Server > gamemodes > yourgamemode.pwn:
pawn Код:
#include <gvar>
public OnGameModeInIt()
{
ConnectNPC("DarkyBot","mynpc");
// The rest of your code on this native...
}
public OnPlayerRequestClass(playerid, classid)
{
// If you want the npc to spawn put: "if(IsPlayerNPC(playerid)) return 1;"
if(GetPVarInt(playerid, "NoNPCSpawn") == 0)
{
return 0;
}
// The rest of your code on this native...
return 1;
}
public OnPlayerConnect(playerid)
{
SetPVarInt(playerid, "NoNPCSpawn", 0);
// The rest of your code on this native...
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case DIALOG_LOGIN:
{
if (!response) return Kick (playerid);
if( response )
{
if(Login Success)
{
SetPVarInt(playerid, "NoNPCSpawn", 1);
// Login code...
}
else // Login failed
{
// Register code...
}
return 1;
}
}
}
// The rest of your code on this native...
return 1;
}
Your Server > npcmodes > mynpc.pwn:
pawn Код:
#define RECORDING "mynpcrecord"
#define RECORDING_TYPE 2 //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
Your Server > npcmodes > recordings:
Place/rename a file named/to "mynpcrecord.rec". This file won't be used.
NOTE: This also fixes the bug when the player is forced to the class selection on login fail and gets kicked on some gamemodes.
Hope it helps!