Implementing "Retrievable Items"

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

Ninjaoninja2
Posts: 204
Joined: 22 Sep 2013, 23:33

Implementing "Retrievable Items"

Postby Ninjaoninja2 » 29 May 2014, 07:31

Hello,I was wondering if you guys could help get me started on what I might need to acquire to have users able to get items just laying around in a room.
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Implementing "Retrievable Items"

Postby Bax » 29 May 2014, 08:08

I think it depends on how your game works. For example if the player must click on an item to collect it, or he has to move his avatar above it.
In the first case you can: (1) send a request to your Extension where (2) it gets validated (make sure the item is in the expected coordinates, is not being collected by other players, etc). Then (3) the item is assigned to the player (maybe you have an "inventory" data structure, backed by a database entry) and (4) an Extension response is sent to all the users in the Room so that (5) their clients can remove the item from the game environment.
Instead, in case the avatar walks over the item to be collected, it depends on how you handle the avatar and item position and their collision. If everything is handled on the client side, then you can follow the same steps described above. Otherwise if the Extension is in charge of detecting the collisions, you can skip the first two steps.
Paolo Bax
The SmartFoxServer Team
Ninjaoninja2
Posts: 204
Joined: 22 Sep 2013, 23:33

Re: Implementing "Retrievable Items"

Postby Ninjaoninja2 » 29 May 2014, 08:17

Bax wrote:I think it depends on how your game works. For example if the player must click on an item to collect it, or he has to move his avatar above it.
In the first case you can: (1) send a request to your Extension where (2) it gets validated (make sure the item is in the expected coordinates, is not being collected by other players, etc). Then (3) the item is assigned to the player (maybe you have an "inventory" data structure, backed by a database entry) and (4) an Extension response is sent to all the users in the Room so that (5) their clients can remove the item from the game environment.
Instead, in case the avatar walks over the item to be collected, it depends on how you handle the avatar and item position and their collision. If everything is handled on the client side, then you can follow the same steps described above. Otherwise if the Extension is in charge of detecting the collisions, you can skip the first two steps.

SO basically what your saying here is if I turned the dbExtension on for the simpleChat zone then coded an extension where I would put columns like in a DB like: item name, and a time stamp to see when the user picked it up (Optional part here), and then have the extensions pick up on the collisions by using the user variables? Just want to make sure I am understanding you here :P
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Implementing "Retrievable Items"

Postby Bax » 29 May 2014, 08:24

Yes, that could be a basic starting point.
Paolo Bax
The SmartFoxServer Team
Ninjaoninja2
Posts: 204
Joined: 22 Sep 2013, 23:33

Re: Implementing "Retrievable Items"

Postby Ninjaoninja2 » 29 May 2014, 08:33

Bax wrote:Yes, that could be a basic starting point.

Alright thanks Bax, I am going to leave this thread unsolved for now because I may have more related questions.
Ninjaoninja2
Posts: 204
Joined: 22 Sep 2013, 23:33

Re: Implementing "Retrievable Items"

Postby Ninjaoninja2 » 29 May 2014, 10:28

Ninjaoninja2 wrote:
Bax wrote:Yes, that could be a basic starting point.

Alright thanks Bax, I am going to leave this thread unsolved for now because I may have more related questions.

Okay Bax, I have one quick question I have got it to work to where I can click the item and the item shows up on my avatar but I now I want to be able to walk up to it, how would I do that? Here's my current code.on (release)

Code: Select all

{
var newCol = 2;
_root.smartfox.setUserVariables({col:newCol, init:true});
_root.myAvatar.disc.gotoAndStop(newCol);
I put this in a button so now I have some knowledge of what I want to do with this, how should I go about making an extension allowing users just to go up to the item?
}
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Implementing "Retrievable Items"

Postby Bax » 29 May 2014, 11:18

Sorry but this is generic Flash support. You will have to look for Flash tutorials to learn how to detect collisions.
Paolo Bax
The SmartFoxServer Team

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 62 guests