About NPCs - 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: About NPCs (
/showthread.php?tid=239629)
About NPCs -
Tee - 14.03.2011
Hello Guys. There is a small problem I have, I have tryed to get a NPC on my local server but it does not work. I see where the NPC connects (in the console) but he won't spawn.
As kc said, we can put If(IsPlayerNpc(playerid))return 1; at the nessary callbacks. I put mine on OnPlayerRequestSpawn and OnPlayerRequestClass. Also I tryed it with OnPlayerConnect but non seems to work. The npc connects just does not spawn.
EDIT: I went in the server and teleported to id 0 and he was there.
but just standing at the place.
The NPC is not in a vehicle.
Re: About NPCs -
Kitten - 14.03.2011
Is this in a fliterscript or a gamemode?
and the recording file should be in the right place this can cause it to.
Re: About NPCs -
Tee - 14.03.2011
Gamemode. He is at the spawn just not doing anything and it is an on foot npc.
Re: About NPCs -
grand.Theft.Otto - 14.03.2011
Go back and do the OnGameModeInit part again like kc quoted. But what I recommend is you put every ConnectNPC line as the very first line under OnGameModeInit.
Also:
pawn Код:
if(IsPlayerNPC(playerid)) //Checks if the player that just spawned is an NPC.
{
new npcname[MAX_PLAYER_NAME];
new Text3D:label[MAX_PLAYERS];
GetPlayerName(playerid, npcname, sizeof(npcname)); //Getting the NPC's name.
if(!strcmp(npcname, "namehere", true)) //Checking if the NPC's name is MyFirstNPC
{
PutPlayerInVehicle(playerid, MyFirstNPCVehicle, 0); //Putting the NPC into the vehicle we created for it.
return 1;
}
put these functions as the first ones under OnPlayerSpawn and maybe your bot shouldn't be in the spawn point.
Re: About NPCs -
Tee - 14.03.2011
The bot should not be in a vehicle. Just normal running and doing stuff.
EDIT: I found my problem. #define RECORDING_TYPE 1 and not 2. Well he was just standing there waiting for his vehicle to arrive xD. 1 is for InVehicle and 2 is for OnFoot. Thanks anyways.