Issue disconnecting NPCs...

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

netvortex
Posts: 23
Joined: 08 Feb 2014, 11:34

Issue disconnecting NPCs...

Postby netvortex » 14 Apr 2014, 08:09

Hello
i'm instantiating NPCs through smartfox and moving them arround, everything works fine but there is one thing that could be an issue. When i purge all active NPCs on the server they get disconnected, however the admin panel still shows a number of users in the zone.

Code: Select all

         for user in mmoroom.getUserList() :
            if user.isNpc():
               _sfsApi.disconnectUser(user)


is used to remove them. Now my issue is that the Zone Monitor shows 8 users in the zone while really no NPCs or Players are in the room. Any idea what's causing this ?

Also, i was thinking i could spawn NPCs as "MMOItems" instead - whats the better approach here ? I got the feeling that the way the examples show the NPC integration was done before smartFox actually implemented MMOItems. So as for best performance/stability it might be better to use MMOItems feature instead ?

Best regards,
n.
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Issue disconnecting NPCs...

Postby Lapo » 14 Apr 2014, 10:24

Hi, NPCs should be better than MMOItems because they are Users and they will show up in the client's user list (when visible in the MMO Room). You can use MMOItems too but this shouldn't be a problem.

As regards the disconnection of NPCs... that seems strange. Are those remaining users in the AdminTool NPCs? What happens if you try to disconnect the manually via an admin "Kick"?

Do you server side errors that may suggest a failure in removing those users?
Also how do you log in those NPCs in the first place?

thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
netvortex
Posts: 23
Joined: 08 Feb 2014, 11:34

Re: Issue disconnecting NPCs...

Postby netvortex » 15 Apr 2014, 10:48

Lapo wrote:Hi, NPCs should be better than MMOItems because they are Users and they will show up in the client's user list (when visible in the MMO Room). You can use MMOItems too but this shouldn't be a problem.

As regards the disconnection of NPCs... that seems strange. Are those remaining users in the AdminTool NPCs? What happens if you try to disconnect the manually via an admin "Kick"?

Do you server side errors that may suggest a failure in removing those users?
Also how do you log in those NPCs in the first place?

thanks


That is the weird thing, in the ZoneList of the ZoneMonitor the room shows up like this : "Someroom<7>", but both users & room list are completely empty. We are still in development mode, so if you like i can PM you the server data and you can take a look as well... In my current setup i can replicate it, the number increases when continue connecting & disconnecting NPCs. That's why i asked if it'll be better to use the MMOItem feature instead of connecting NPCs as users - since it looks to me that MMOItems could result in a better performance when that number there keeps increasing.
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Issue disconnecting NPCs...

Postby Lapo » 15 Apr 2014, 11:15

I don't think there will be any significant performance difference between NPC and MMOItems.
One thing you have to keep in mind is that NPC will count as actual Users so if you have a limited license you will be better off with MMOItems.

"Someroom<7>", but both users & room list are completely empty.

This I don't understand very well.
Didn't you say that there are NPCs stuck in the system after removing them? Where exactly do they show up in the Admin Tool?
Lapo

--

gotoAndPlay()

...addicted to flash games
netvortex
Posts: 23
Joined: 08 Feb 2014, 11:34

Re: Issue disconnecting NPCs...

Postby netvortex » 15 Apr 2014, 11:50

In the Zonenames List on the left... the number keeps increasing...

I just ported my extension from python to java, will test it with the new prototype after i figured out why it's not showing up as extension in the ext list...
fmax
Posts: 1
Joined: 30 Mar 2019, 10:42

Re: Issue disconnecting NPCs...

Postby fmax » 30 Mar 2019, 10:49

Hey Lapo,

Just wanted to bump on this. This still happens. I have added NPCs using this :

user = gh.getParentExtension().getApi().createNPC("MYBOT-"+room.getLifeTime()+"-"+ThreadLocalRandom.current().nextInt(0, 10000)+"-"+ThreadLocalRandom.current().nextInt(0, 10000), room.getZone(), true);

Then after sometime I want to make them get up ( exit ) so I call this :

gh.getParentExtension().getApi().disconnectUser(bot);

I am sure that disconnect is happening because I am seeing the logs put in the server side disconnect handler class.

Problem is that while these users are removed from the rooms, they still show up in Zone.

Because of this very soon we run of out license limit ( 2000 right now ) . I am attaching the snapshots to clarify.

thank you
Attachments
Screenshot from 2019-03-30 16-22-54.png
(62.06 KiB) Not downloaded yet
Screenshot from 2019-03-30 16-23-03.png
(65.98 KiB) Not downloaded yet
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Issue disconnecting NPCs...

Postby Lapo » 02 Apr 2019, 10:18

Sorry for the delay.
We've received a lot of spam a few days ago an the approval queue was flooded.

As regards your problem I've tried to reproduce it by creating an NPC and then removing it with SFSApi.disconnectUser();
When I check the zone.getUserList() it is empty, as expected.

Code: Select all

Zone z = getParentZone();
User lapo = getApi().createNPC("Lapo", z, false);
System.out.println(z.getUserList());


This outputs the following -> [( User Name: Lapo, Id: 1, Priv: 0, Sess: NO_IP ) ]

Then I do:

Code: Select all

getApi().disconnectUser(lapo);
System.out.println(z.getUserList());

Which shows this -> []
An empty list, as expected.

I noticed you're using SFS2X 2.13.0. I am not aware of any bugs in that version related to NPC but I'd recommend upgrading to the latest release 2.13.5, which is a patch that can be applied to your current installation very quickly.

If the problem persists after the patch, I will need to see a code example that showcases how to reproduce the issue.
https://www.smartfoxserver.com/download/#p=updates

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Thomasea and 99 guests