SA-MP Forums Archive
NPCs join and leave - 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: NPCs join and leave (/showthread.php?tid=228127)



NPCs join and leave - Master_Gangster - 18.02.2011

as the title says the npcs I make join then leave for some unknown reason...

here is the code I put under onplayerspawn:

Код:
if(IsPlayerNPC(playerid)) 
  	{
    new npcname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, npcname, sizeof(npcname));
    if(!strcmp(npcname, "Bus_Driver", true)) 
    {
      PutPlayerInVehicle(playerid, MyFirstNPCVehicle, 431); 
    }
    return 1;
  	}
  	if(IsPlayerNPC(playerid))
  	{
    new npcname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, npcname, sizeof(npcname));
    if(!strcmp(npcname, "Crazy_Train_Driver", true)) 
    {
      PutPlayerInVehicle(playerid, MyFirstNPCVehicle, 538); 
    }
    return 1;
  	}
  	if(IsPlayerNPC(playerid))
    {
        new npcname[MAX_PLAYER_NAME];
        GetPlayerName(playerid, npcname, sizeof(npcname));
        if(!strcmp(npcname, "Busdriver", true))
        {
        	PutPlayerInVehicle(playerid, NPCBus, 0);
        	SetPlayerSkin(playerid, 255);
        	ResetPlayerWeapons(playerid);
        }
        return 1;
    }
    if(IsPlayerNPC(playerid)) 
  	{
    new npcname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, npcname, sizeof(npcname)); 
    if(!strcmp(npcname, "Helicopter", true)) 
    {
      PutPlayerInVehicle(playerid, MyFirstNPCVehicle, 425); 
    }
    return 1;
  	}
any help?


Re: NPCs join and leave - [WF]Demon - 18.02.2011

If your server has a login, put if(IsPlayerNPC(playerid)) return 1; before it makes the NPC login, Also put that in OnPlayerConnect OnPlayerRequestSpawn and OnPlayerRequestClass to be safe and then it should work.


Re: NPCs join and leave - Master_Gangster - 18.02.2011

Quote:
Originally Posted by [WF]Demon
Посмотреть сообщение
If your server has a login, put if(IsPlayerNPC(playerid)) return 1; before it makes the NPC login, Also put that in OnPlayerConnect OnPlayerRequestSpawn and OnPlayerRequestClass to be safe and then it should work.
let me test and I'll post the results mate (: