[SOLVED]MMO Player Variables

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

OhMyOhmit
Posts: 18
Joined: 24 Apr 2018, 12:25

[SOLVED]MMO Player Variables

Postby OhMyOhmit » 24 Apr 2018, 12:40

Hello everyone. I'm new to this forum and SmartFox as well, so sorry for nooby question :)
I've already downloaded the MMO and FPS examples and tested them for a little bit. Everything seemed understandable to me, but until I wanted to add a simple Health Variable and attach it to the player. As I can see in FPS example, all player variables are made on a server side by CombatPlayer "simulation", but in MMO example such variables as material, model, location coordinates of player are containing on the client, if I understood everything correctly. As I suggested, it is because MMO example uses the AOI system, but I might be wrong.

So my question is: How to correctly add a variables such as mana and hp to player for a MMORPG?
Last edited by OhMyOhmit on 06 May 2018, 11:37, edited 1 time in total.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: MMO Player Variables

Postby Lapo » 24 Apr 2018, 14:31

Hi,
you can set variables for Players or Rooms from both client and server side.
To a degree it doesn't matter which side you use.

It might matter a bit in terms of security, if certain variables need to be controlled by the server side logic and could be hacked then creating them from server side would be better but, other than that, client or server is the same.

There is however one exception, which is MMOItems. MMOItems represent objects in a virtual world (could be anything: collectibles, health potions, door triggers ...). These objects can also be customized with multiple properties (MMOItemVariables) and they must be created from server side.

If you want to learn more I'd highly recommend these articles from our docs:
http://docs2x.smartfoxserver.com/Advanc ... /mmo-rooms
http://docs2x.smartfoxserver.com/Advanc ... ed-mmo-api

If there's any other questions let us know.
Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
OhMyOhmit
Posts: 18
Joined: 24 Apr 2018, 12:25

Re: MMO Player Variables

Postby OhMyOhmit » 28 Apr 2018, 10:03

Thank you for a reply.
I've read the docs that you've sent to me and many things seems more understandable now. However, I still do not understand how can I add a "health" variable to player :? I think that I have to add it when player enters the server, but can't find a way to do so.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: MMO Player Variables

Postby Lapo » 28 Apr 2018, 20:20

Setting a User variable is a matter of 1-2 lines of code.
I would recommend checking the documentation here --> http://docs2x.smartfoxserver.com/Develo ... -variables

You can always search using the search function at the top of the left side menu, if you're not finding what you need.

If you want to set the variable from server side, as soon as the player has logged in I would recommend reading about the server side events under the Java (or Javascript) Extension section.
There you will learn how to create server side code, and how to handle specific server side events so that you can react to them. This includes the login event when a player joins the server.

Take it one step at time, the examples will guide you. It's pretty simple :)

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 19 guests