Openspace items

Post here your questions about the OpenSpace 1.x or notify bugs and suggestions.

Moderators: Lapo, Bax

Post Reply
olliepop
Posts: 3
Joined: 24 Nov 2007, 00:40

Openspace items

Post by olliepop »

Ok, this is a bit off support but it is still quite important.
How on earth would i setup items in openspace?

For example:
user steps on tile with item on it
user clicks tile again
item is added to inventory

how would the item be displayed on the map, and how would clicking on the tile activate the event to add the item to the inventory?

thanks :?
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Post by Bax »

I suppose you also want to make the item disappear from the map, so no one else can collect it.
This is the difficult part, as OpenSpace doesn't have this feature out of the box.
I won't describe how to make an object clickable: check the Ranch example for this (when the avatar is in front of the doors, they become clickable).
As the map can't be modified at runtime, you have to use a trick: get a reference to the clicked item (which is a skin attached to a tile) and call a custom method to change its graphics (or a gotoAndStop an empty frame is enough maybe).
Now the most difficult part: you have to send a custom message to the other connected clients to tell them to make the same object disappear so no one can get it; also, you will have to save this info in the room variables, so that you can do the same when a new user enters the map where the object disappeared.
A possible issue is that two users click on the same object at the same time. You will probably need to validate the action on the server-side.
Paolo Bax
The SmartFoxServer Team
olliepop
Posts: 3
Joined: 24 Nov 2007, 00:40

Post by olliepop »

thanks for your logic :)
the issue you arose however about two players clicking the same tile is quite a real one.. it could mean an item duplication cheat :s
so yes, i will have to do quite a bit of validation coding there to make sure only one copy of it can be taken.
unless i dont do items on the ground at all.. now thats an idea :idea:
nig3d
Posts: 164
Joined: 02 Jul 2008, 09:42

Post by nig3d »

the only way to be sure that a given item is not taken twice is to write an extension.
There is no way to manage such a thing properly on client side.
Post Reply