NPC leaves server after joining
#1

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.
Reply
#2

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

Read the whole tutorial.
Reply
#3

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.
Reply
#4

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

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.
Reply
#6

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?
Reply
#7

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.
Reply
#8

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.
Reply
#9

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?
Reply
#10

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
Reply
#11

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

Reply
#12

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

Reply
#13

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().
Reply
#14

Have you changed maxnpcs?
Reply
#15

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?
Reply
#16

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

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

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?
Reply
#19

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
Reply
#20

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)