Where to create NPC

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

Moderators: Lapo, Bax

User avatar
khokhani1510
Posts: 17
Joined: 06 Feb 2014, 11:08
Location: Gujarat, India
Contact:

Where to create NPC

Postby khokhani1510 » 07 Sep 2021, 09:49

Hello,

First of all thanks to sfs team for building this amazing api.

I am creating board game in which if sufficient players are not found in room NPCs need to be created.

Have checked NPC documents as prescribed here.

https://smartfoxserver.com/blog/ways-of-working-with-npcs-in-a-multiplayer-game-p-1/
https://smartfoxserver.com/blog/ways-of-working-with-npcs-in-a-multiplayer-game-p-2/

Seems little bit confusing for me.

Two ways to create NPCs..
1. Create NPCs as client application.
2. Create NPCs at server side.

Question is: At which level and where to create NPC at server side?

Do I need to create NPC at room level (in room extension) when sufficient users are not found?
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Where to create NPC

Postby Lapo » 07 Sep 2021, 15:49

Hi,
if you need to compensate the number of missing players with NPCs I think the best strategy is to create them from server side.

Do I need to create NPC at room level (in room extension) when sufficient users are not found?

Yes, if your game is controlled by a Room Level Extension then that's the right place to create them by calling the
getApi().createNPC(...) method

As regards "when" it depends on how the game works. Maybe you could run a timer that allows players to join the game, and when this expires you can check how many real clients have joined and add the necessary NPCs.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
khokhani1510
Posts: 17
Joined: 06 Feb 2014, 11:08
Location: Gujarat, India
Contact:

Re: Where to create NPC

Postby khokhani1510 » 08 Sep 2021, 03:57

Thanks Lapo, for helping hands.

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 75 guests