NPC will quit after someone is trying to join server
#1

As the title says, the NPC will quit after someone is trying to login. Basically I don't know what the problem is, as I tried everything possible.

Here are the server logs:

Code:
----------
Loaded log file: "server_log.txt".
----------

SA-MP Dedicated Server
----------------------
v0.3x-R2, ©2005-2013 SA-MP Team

[11:02:12] 
[11:02:12] Server Plugins
[11:02:12] --------------
[11:02:12]  Loading plugin: sscanf
[11:02:12] 

[11:02:12]  ===============================

[11:02:12]       sscanf plugin loaded.     

[11:02:12]    © 2009 Alex "Y_Less" Cole

[11:02:12]  ===============================

[11:02:12]   Loaded.
[11:02:12]  Loaded 1 plugins.

[11:02:12] 
[11:02:12] Filterscripts
[11:02:12] ---------------
[11:02:12]   Loading filterscript 'npc_record.amx'...
[11:02:12]   Loading filterscript 'private.amx'...
[11:02:12]   Loaded 2 filterscripts.

[11:02:12]  
[11:02:12]  ======================================= 
[11:02:12]  |                                     | 
[11:02:12]  |        YSI version 1.03.0011        | 
[11:02:12]  |        By Alex "Y_Less" Cole        | 
[11:02:12]  |                                     | 
[11:02:12]  |  Checking the latest YSI version..  | 
[11:02:12]  |                                     | 
[11:02:12]  ======================================= 
[11:02:12]  
[11:02:12] 
----------------------------------
[11:02:12]  Blank Gamemode by your name here
[11:02:12] ----------------------------------

[11:02:12] Number of vehicle models: 1
[11:02:12] Incoming connection: XXX
[11:02:12] 
[11:02:12]  
[11:02:12] [npc:join] Tutorial has joined the server (XXX)
[11:02:12] Has joined and is waiting to enter vehicle
[11:02:12] NPC has been spawned
[11:02:27] [npc:part] Tutorial has left the server (0:0)
[11:02:42] Incoming connection: XXX
[11:02:42] [join] Ricard_Nune has joined the server (XXX68.1.70:52930)
And as I mentioned, here is the part of quitting:

Code:
[11:02:12] [npc:join] Tutorial has joined the server (XXX)
[11:02:12] Has joined and is waiting to enter vehicle
[11:02:12] NPC has been spawned
[11:02:27] [npc:part] Tutorial has left the server (0:0)
[11:02:42] Incoming connection: XXX
[11:02:42] [join] Ricard_Nune has joined the server (XXX)
I don't really know why it shall leave, but. Don't even know what is creating this.

I bet more on a possible crash, but don't know what may create that 'possible crash'.

OnGameModeInIt part:
pawn Code:
public OnGameModeInit()
{
    taxicar = AddStaticVehicle(420,1669.9904,-2321.4951,-3.0693,90.1905,6,1);
    ConnectNPC("Tutorial", "taxils");
    return 1;
}
OnPlayerConnect part:

pawn Code:
if(IsPlayerNPC(playerid))
    {
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid,name,sizeof(name));
        if(!strcmp(name,"Tutorial",false))
        {
            printf("Has joined and is waiting to enter vehicle");
            PutPlayerInVehicle(playerid,taxicar,0);
            printf("NPC has been spawned");
        }
        return 1;
    }
I putted it on connecting callback because that's the place where it tries to connect. On the other hand, I tried even the OnPlayerSpawn callback but also it didn't work, it left after connecting, without even printing any information to the console.

1. I have added maxnpc line to 10.
2. Both .amx/.pwn and .rec files have same name.


Thank you to whoever offers to help me.
Reply
#2

You cannot force a NPC to get in a vehicle while connecting. In OnPlayerConnect:
pawn Code:
if( IsPlayerNPC( playerid ) ) return 1;
in OnPlayerSpawn:
pawn Code:
if(IsPlayerNPC(playerid))
    {
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid,name,sizeof(name));
        if(!strcmp(name,"Tutorial",false))
        {
            printf("Has joined and is waiting to enter vehicle");
            PutPlayerInVehicle(playerid,taxicar,0);
            printf("NPC has been spawned");
        }
        return 1;
    }
Reply
#3

Quote:
Originally Posted by Konstantinos
View Post
You cannot force a NPC to get in a vehicle while connecting. In OnPlayerConnect:
pawn Code:
if( IsPlayerNPC( playerid ) ) return 1;
in OnPlayerSpawn:
pawn Code:
if(IsPlayerNPC(playerid))
    {
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid,name,sizeof(name));
        if(!strcmp(name,"Tutorial",false))
        {
            printf("Has joined and is waiting to enter vehicle");
            PutPlayerInVehicle(playerid,taxicar,0);
            printf("NPC has been spawned");
        }
        return 1;
    }
Even after that, it still didn't get fixed. Please check your PM.

Thank you.
Reply
#4

Quote:
Originally Posted by Konstantinos
View Post
pawn Code:
if( IsPlayerNPC( playerid ) ) return 1;
The same must be done in OnPlayerRequestClass and OnPlayerRequestSpawn, too.
Reply
#5

Quote:
Originally Posted by kvann
View Post
The same must be done in OnPlayerRequestClass and OnPlayerRequestSpawn, too.
There is nothing preventing the user to spawn. I'm not using any edit of any kind of gamemode, it's my own and I know what's in it.

The user will just have to login and he spawns, not any kind of place where to spawn. Just, spawn! If there would be anything preventing him to spawn then I would use it, but since it's not, then I don't have why to waste resources.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)