SA-MP Forums Archive
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)
+--- Thread: NPC (/showthread.php?tid=493069)



NPC - DarkLored - 06.02.2014

Hello i recently noticed that id 0 in samp gets glitched and i wanted to make a invisable npc that i only connect and it blocks players from logging as id 0 so my problem is that the NPC isnt connecting

here is my code:
pawn Код:
#include "a_npc"
pawn Код:
#define RECORDING "mynpc"
pawn Код:
ConnectNPC("PG BOT","mynpc");
thats the codes that i am using cause i dont want a actual npc in the gamemode i just want one that will connect any idea?


Re: NPC - DarkLored - 06.02.2014

Any help guys?


Re: NPC - DarkLored - 06.02.2014

guys i need help i barely found tutorials on npc's and i dont know why the npc isnt connecting


Re: NPC - Crypto20 - 06.02.2014

do you got your nps files in the /npcmodes/ directory?


Re: NPC - DarkLored - 06.02.2014

Yes i have


Re: NPC - DarkLored - 06.02.2014

Help please


Re: NPC - DarkLored - 06.02.2014

Guys can you help me ?


Re: NPC - SickAttack - 06.02.2014

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!


Re: NPC - DarkLored - 06.02.2014

Wow thanks mate it worked i am really thankful for your help +1


Re: NPC - Hoborific - 07.02.2014

You can't have spaces in bot names by the way.