SA-MP Forums Archive
NPC leaves server after joining - 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: NPC leaves server after joining (/showthread.php?tid=126609)

Pages: 1 2 3


NPC leaves server after joining - Ma - 09.02.2010

Hi,

I'm using an edit from the Godfather gamemode and I created an filterscript with NPC's.
When I load this filterscript, my NPC leaves my server after joining.
I think they get autokicked by the godfather login system.
How can I fix this in the filterscript? Or do I need to create accounts for my NPC's and let them log in? But how do I let my NPC's write a command?

I hope somebody can help me with this problem.


Re: NPC leaves server after joining - V1ceC1ty - 09.02.2010

http://forum.sa-mp.com/index.php?topic=119947.0

Read the whole tutorial.


Re: NPC leaves server after joining - Ma - 09.02.2010

Quote:
Originally Posted by V1ceC1ty
I read this whole topic 5 time's, there is no solution for this problem in it. Thanks for trying.


Re: NPC leaves server after joining - V1ceC1ty - 09.02.2010

There is a solution, read it all. It's even in big writing.


Re: NPC leaves server after joining - Ma - 09.02.2010

Quote:
Originally Posted by V1ceC1ty
There is a solution, read it all. It's even in big writing.
If you mean

Code:
if(IsPlayerNPC(playerid)) return 1;
That is not working, I placed this line on every place you can think about, and stull my NPC get kicked.


Re: NPC leaves server after joining - V1ceC1ty - 09.02.2010

Quote:
Originally Posted by Ma
Quote:
Originally Posted by V1ceC1ty
There is a solution, read it all. It's even in big writing.
If you mean

Code:
if(IsPlayerNPC(playerid)) return 1;
That is not working, I placed this line on every place you can think about, and stull my NPC get kicked.
You see all my NPC scripts in my signature, well I read through the tutorial properly and got my first NPC to work the first time. There is numerous reasons why yours doesn't work so why don't you let us see your script?


Re: NPC leaves server after joining - Ma - 09.02.2010

Quote:
Originally Posted by V1ceC1ty
Quote:
Originally Posted by Ma
Quote:
Originally Posted by V1ceC1ty
There is a solution, read it all. It's even in big writing.
If you mean

Code:
if(IsPlayerNPC(playerid)) return 1;
That is not working, I placed this line on every place you can think about, and stull my NPC get kicked.
You see all my NPC scripts in my signature, well I read through the tutorial properly and got my first NPC to work the first time. There is numerous reasons why yours doesn't work so why don't you let us see your script?
I just followed the tutorial step by step in a filterscript, nothing more, nothing less, and my gamemode is just the basic godfather, nothing else.


Re: NPC leaves server after joining - [KMA]DlennartD - 09.02.2010

Try like KC says:

Code:
onPlayerCommandText(npc_id_here, "/command");
Maybe you can let your NPC's login on a existing account, I'm not sure but you can give it a shot.


Re: NPC leaves server after joining - Ma - 09.02.2010

Quote:
Originally Posted by [KMA
DlennartD ]
Try like KC says:

Code:
nPlayerCommandText(npc_id_here, "/command");
Maybe you can let your NPC's login on a existing account, I'm not sure but you can give it a shot.
Where shall I place this line?


Re: NPC leaves server after joining - (Jeff) - 09.02.2010

Quote:
Originally Posted by Ma
Quote:
Originally Posted by [KMA
DlennartD ]
Try like KC says:

Code:
nPlayerCommandText(npc_id_here, "/command");
Maybe you can let your NPC's login on a existing account, I'm not sure but you can give it a shot.
Where shall I place this line?
OnPlayerCommand Text i suppose


Re: NPC leaves server after joining - [KMA]DlennartD - 09.02.2010

Oh sorry I made a mistake, it need to be onPlayerCommandText(npc_id_here, "/command"); not nPlayerCommandText(npc_id_here, "/command");




Re: NPC leaves server after joining - Ma - 09.02.2010

Nope, isn't working, I still get the same thing, this time I tryd V1ceC1ty his taxi filterscript:




Re: NPC leaves server after joining - Calgon - 09.02.2010

Quote:
Originally Posted by Ma
Nope, isn't working, I still get the same thing, this time I tryd V1ceC1ty his taxi filterscript:

So, they're being kicked. Have you definitely added the code to OnPlayerConnect()?

Quote:
Originally Posted by [KMA
DlennartD ]
Oh sorry I made a mistake, it need to be onPlayerCommandText(npc_id_here, "/command"); not nPlayerCommandText(npc_id_here, "/command");

You failed again, it's OnPlayerCommandText().


Re: NPC leaves server after joining - V1ceC1ty - 09.02.2010

Have you changed maxnpcs?


Re: NPC leaves server after joining - Ma - 09.02.2010

Quote:
Originally Posted by V1ceC1ty
Have you changed maxnpcs?
Yes I did, I put max on 10

Quote:
Originally Posted by CalgonX
Quote:
Originally Posted by Ma
Nope, isn't working, I still get the same thing, this time I tryd V1ceC1ty his taxi filterscript:

So, they're being kicked. Have you definitely added the code to OnPlayerConnect()?

Quote:
Originally Posted by [KMA
DlennartD ]
Oh sorry I made a mistake, it need to be onPlayerCommandText(npc_id_here, "/command"); not nPlayerCommandText(npc_id_here, "/command");

You failed again, it's OnPlayerCommandText().
So I should put onPlayerCommandText(0, "/login password"); in OnPlayerConnect() in my filterscript?


Re: NPC leaves server after joining - [KMA]DlennartD - 10.02.2010

Hmmm, I have no idea actually, now I'm curious of anybody can fix this issue.


Re: NPC leaves server after joining - V1ceC1ty - 10.02.2010

If he posts the FS and npcmode ill be able to fix it. :l


Re: NPC leaves server after joining - [KMA]DlennartD - 10.02.2010

Quote:
Originally Posted by V1ceC1ty
If he posts the FS and npcmode ill be able to fix it. :l
Well he say he try it with your taxi filterscript and got the same error, so maybe you can fix than one?


Re: NPC leaves server after joining - Ma - 10.02.2010

Here is my NPC filterscript:

Code:
#include <a_samp>
#include <dini>

#define COLOR_YELLOW 0xFFFF00AA

new MyFirstNPCVehicle; //Global variable!

forward OnPlayerLogin(playerid,password[]);
forward OnNPCConnect(myplayerid);

public OnFilterScriptInit()
{
  ConnectNPC("Yoko","politie");
  MyFirstNPCVehicle = CreateVehicle(596,1535.7097,-1677.5266,13.1147,359.5821, 0, 1, 5000);
  return 1;
}

public OnFilterScriptExit()
{
	return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
  SendClientMessage(playerid, COLOR_YELLOW, "Requesting Class");
	return 1;
}

public OnPlayerConnect(playerid)
{
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	return 1;
}

public OnPlayerLogin(playerid,password[])
{
  return 1;
}

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, "Yoko", true)) //Checking if the NPC's name is MyFirstNPC
    {
      print("spawn");
      OnPlayerCommandText(playerid, "/login password");
      PutPlayerInVehicle(playerid, MyFirstNPCVehicle, 0); //Putting the NPC into the vehicle we created for it.
      SetPlayerSkin(playerid,280); //Give NPC a skin
    }
    return 1;
  }
  //Other stuff for normal players goes here!
  return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
	return 1;
}

public OnVehicleSpawn(vehicleid)
{
	return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
	return 1;
}

public OnPlayerText(playerid, text[])
{
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
	return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
	return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
	return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
	return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
	return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
	return 1;
}

public OnRconCommand(cmd[])
{
	return 1;
}

public OnPlayerRequestSpawn(playerid)
{
	return 1;
}

public OnObjectMoved(objectid)
{
	return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
	return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
	return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
	return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
	return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
	return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
	return 1;
}

public OnPlayerExitedMenu(playerid)
{
	return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
	return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
	return 1;
}

public OnPlayerUpdate(playerid)
{
	return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
	return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
	return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
	return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
	return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
	return 1;
}

public OnNPCConnect(myplayerid)
{
  printf("I successfully connected the server with ID %i!", myplayerid);
}
And here is my npcmode:

Code:
#define RECORDING "politie" //This is the filename of your recording without the extension.
#define RECORDING_TYPE 1 //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



Re: NPC leaves server after joining - WThieves - 10.02.2010

i've got this kind of crap too, but atleast i got a little further they join and connect and then just stand frozen at the playerspawnpoint,
Anyhow i can help you a little further:
EDIT: Find this in the gf gamemode
Find:
Quote:

if(gPlayerLogged[playerid] == 0)

and then you should see something like this:
Quote:

if(gPlayerLogged[playerid] == 0)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "** This server requires a Login BEFORE spawn (Kicked) **");
KickPlayer[playerid] = 1;
}

Now you can change it to this:
Quote:

if(gPlayerLogged[playerid] == 0)
{
if(IsPlayerNPC(playerid)) return 1;
SendClientMessage(playerid, COLOR_LIGHTRED, "** This server requires a Login BEFORE spawn (Kicked) **");
KickPlayer[playerid] = 1;
}

Or completely remove it like this:
Quote:

if(gPlayerLogged[playerid] == 0)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "You are not logged in so you are in demo mode.");
SendClientMessage(playerid, COLOR_LIGHTRED, "This means you can't save your stats, choose a character or talk.");
SendClientMessage(playerid, COLOR_LIGHTRED, "To do this you must /login *password* or /register *password* if you haven't done so");
}

This only will stop it getting kicked BUT:
the 1st solution will stop npc's getting kicked (untested)
the 2nd solution will stop anyone/anything getting kicked (used and tested)

Hope it helps and please tell me if it works 'cause i've still got the blinking or no move problem.