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



NPC Problem - andrejc999 - 13.10.2016

So guys I'm making a NPC system and I have a problem...

I want an NPC to drive a bus through the city so i made a recording and i made a code for the npc to connect and enter the vehicle (bus) but it doesn't seem that he is connecting at all idk why...

I checked in my script if there is like if(IsNPC(playerid)) return 0; but I didn't find it.

Here is the code:

Код:
//Under a timer (5 sec) that calls when gamemode starts..

ConnectNPC("BusVozac", "BuS");

//Under public OnPlayerConnect

	if(IsPlayerNPC(playerid))
	{
        printf("NPC: Connection is allowed.");
        return 1;
	}



Re: NPC Problem - Gotham - 13.10.2016

Make it under OnPlayerRequestSpawn and also under OnPlayerConnect.Basicallu
PHP код:
//Under OnPlayerRequestSpawn
   
if(IsPlayerNPC(playerid))
  {
     print(
"NPC: Spawned.");
     return 
1;
  } 
OnPlayerConnect
PHP код:
//Under OnPlayerConnect
  
if(IsPlayerNPC(playerid))
  {
     print(
"NPC:Connection is allowed");
     return 
1;
  } 
And also Try to make it "if(IsPlayerNPC(playerid)) return 1;" as you simply print it :P


Re: NPC Problem - andrejc999 - 13.10.2016

Yeah thx I forgot about that, but my NPC still doesn't even attempt to connect. Idk why..


Re: NPC Problem - Gotham - 13.10.2016

Don't make a timer for the NPC to connect.you may have forgot something in the timer which doesn't let the NPC connect!


Re: NPC Problem - andrejc999 - 13.10.2016

Nevermind I did something wrong but I've fixed it now... Thx for help