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



NPC invisible. - Bates - 09.01.2012

Hello guys! I'm recording a NPC driving the tram around San Fierro. Now, it worked perfect until today when the NPC got invisible.. I have no idea what I did.. There's no warnings or anything, and yes I've made sure the NPC is not in the wrong virtual world - my /gotop command sets the interior and the virtual world.. Here's my code:

pawn Код:
public OnPlayerConnect(playerid) {

    if(IsPlayerNPC(playerid))
    {
        SetSpawnInfo(playerid, 0, 61, -1982.4727, 133.8975, 27.6875, 0, 0, 0, 0, 0, 0, 0);
        SpawnPlayer(playerid);
        print("NPC connected, returning 1.");
        return 1;
    }
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, "Tram_Driver", true)) //Checking if the NPC's name is MyFirstNPC
        {
            PutPlayerInVehicle(playerid, npctram, 0); //Putting the NPC into the vehicle we created for it.
            VehicleEngineOn(npctram);
            printf("NPC %s has spawned.", npcname);
        }
        return 1;
    }



Re: NPC invisible. - sGarfield - 09.01.2012

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, "Tram_Driver", true)) //Checking if the NPC's name is MyFirstNPC
        {
            PutPlayerInVehicle(playerid, npctram, 0); //Putting the NPC into the vehicle we created for it.
            VehicleEngineOn(npctram);  
            SetPlayerVirtualWorld(playerid, 0); SetPlayerInterior(playerid, 0);
            printf("NPC %s has spawned.", npcname);
        }
        return 1;
    }



Re: NPC invisible. - Konstantinos - 09.01.2012

Delete all these inside teh OnPlayerConnect callback. All of them are useless because we spawn the NPCs OnPlayerSpawn Callback.


Re: NPC invisible. - Bates - 09.01.2012

Quote:
Originally Posted by sGarfield
Посмотреть сообщение
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, "Tram_Driver", true)) //Checking if the NPC's name is MyFirstNPC
        {
            PutPlayerInVehicle(playerid, npctram, 0); //Putting the NPC into the vehicle we created for it.
            VehicleEngineOn(npctram);  
            SetPlayerVirtualWorld(playerid, 0); SetPlayerInterior(playerid, 0);
            printf("NPC %s has spawned.", npcname);
        }
        return 1;
    }
Already tried that, doesn't work :/

Quote:
Originally Posted by Dwane
Посмотреть сообщение
Delete all these inside teh OnPlayerConnect callback. All of them are useless because we spawn the NPCs OnPlayerSpawn Callback.
I have to SetSpawnInfo, SpawnPlayer and return 1 for it for it to spawn at all..