unity client doesnt get uservar of type sfsobject

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

Moderators: Lapo, Bax

Robbilie
Posts: 190
Joined: 04 Sep 2010, 19:48
Location: Ratingen, Germany
Contact:

unity client doesnt get uservar of type sfsobject

Postby Robbilie » 05 Jul 2011, 13:27

hey guys

mayxbe i found annother bug, on server i create a new uservariable and put in a sfsobject

i also try to read data from the uservariable and trtace it out and it works, but in unity client this is returns the warning:

if(smartFox.MySelf.GetVariable("inv") == null){
Debug.LogWarning("uservar doesnt exist :( ");
}

so the client cant find the variable...

Whats the prob?

Greetz
Robert
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 05 Jul 2011, 14:44

1. how do you set the var on the server side ?
2. what error are you getting on the client ?
3. what happens if you debug the var :
Debug.Log(smartFox.MySelf.GetVariable("inv"));
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 06 Jul 2011, 06:42

Yes please - paste code snippets :-)
Full Control - maker of Unity/C# and Java SFS API and indie games
Follow on twitter: http://twitter.com/thomas_h_lund
Robbilie
Posts: 190
Joined: 04 Sep 2010, 19:48
Location: Ratingen, Germany
Contact:

Postby Robbilie » 06 Jul 2011, 09:02

ok here some code, i cant post the extra methods since they are to complicated and very important for our project....:

server code:

Code: Select all


ISFSObject inv = extension.getPlayersInv(sfsUser);
                UserVariable uvar = new SFSUserVariable("inv", inv);
                if(inv == null){
                    uvar.setNull();
                    extension.trace("inv == null");
                }

                try{
                    sfsUser.setVariable(uvar);
                }
                catch(SFSVariableException excp){
                    extension.trace(excp);
                }

                extension.trace("Reading UVAR:" + sfsUser.getVariable("inv").getSFSObjectValue().getInt("length"));


server trace:

Code: Select all

05 Jul 2011 14:25:35,446 INFO  [com.smartfoxserver.v2.controllers.ExtensionController-1] Extensions     - {sfsFps}: returning inv
05 Jul 2011 14:25:35,446 INFO  [com.smartfoxserver.v2.controllers.ExtensionController-1] Extensions     - {sfsFps}: Reading UVAR:24


client code:

Code: Select all

Debug.LogWarning("inloader");
      ISFSObject inv = new SFSObject();
      if(smartFox.MySelf.GetVariable("inv") == null){
         Debug.LogWarning("uservar doesnt exist :( ");
      }
      else{
      inv = smartFox.MySelf.GetVariable("inv").GetSFSObjectValue();
      Debug.LogWarning("hasloaded");
      int length = inv.GetInt("length");
blabla }



client trace:

Code: Select all

Debug.LogWarning("inloader");
Debug.LogWarning("uservar doesnt exist :( ");


that was it....

and i dont call the method on startup where maybe the var doesnt exist yet, it doesnt matter when i call it...


enough info?

hope you can help me ;)
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 06 Jul 2011, 10:53

it's been a while since i used vars but your setting the var on the user object, if i remember right you should push it in the api :

getApi().setUserVariables(user, vars);
the server will send updates to the clients
Robbilie
Posts: 190
Joined: 04 Sep 2010, 19:48
Location: Ratingen, Germany
Contact:

Postby Robbilie » 06 Jul 2011, 11:18

arrrrr right everywhere else i use a uservar list to set...
Ill try later , thanks appels ;)

Do u have a project right now?

Greetz
Robert
Robbilie
Posts: 190
Joined: 04 Sep 2010, 19:48
Location: Ratingen, Germany
Contact:

Postby Robbilie » 06 Jul 2011, 13:52

nope sorry guys, still having the same problem :(
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 06 Jul 2011, 15:00

when you have set the var, can you see it in the SFS2x webtool ?
Robbilie
Posts: 190
Joined: 04 Sep 2010, 19:48
Location: Ratingen, Germany
Contact:

Postby Robbilie » 06 Jul 2011, 15:29

it is shown...
also size is right...

and i was rly shocked about the geo location :O
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 06 Jul 2011, 16:00

I just tested it out on RC3 and it works fine :

Server side:

User user = (User) event.getParameter(SFSEventParam.USER);
UserVariable uID = new SFSUserVariable("id", 1);
uID.setHidden(false);
List<UserVariable> vars = Arrays.asList(uID);
getApi().setUserVariables(user, vars);

client side:

Debug.Log(sfClient.MySelf.GetVariable("id"));

client debug :

[UVar: id, type: INT, value: 1]
Robbilie
Posts: 190
Joined: 04 Sep 2010, 19:48
Location: Ratingen, Germany
Contact:

Postby Robbilie » 06 Jul 2011, 17:11

2 things:
First, the var is nit hidden
Second and more important: integer and strings work fine for me too ;) but not sfsobject...
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 06 Jul 2011, 17:26

Maybe your client code is run before the var is actually sent to the client?

/Thomas
Full Control - maker of Unity/C# and Java SFS API and indie games

Follow on twitter: http://twitter.com/thomas_h_lund
Robbilie
Posts: 190
Joined: 04 Sep 2010, 19:48
Location: Ratingen, Germany
Contact:

Postby Robbilie » 06 Jul 2011, 17:40

nope, the code is run every time the inventory is opened and when i see the server running on my second screen passed the uvar i try...

Also i used the advanced setuservariables to enable fireclient event
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 07 Jul 2011, 05:44

Will look into it!

/T
Full Control - maker of Unity/C# and Java SFS API and indie games

Follow on twitter: http://twitter.com/thomas_h_lund
Robbilie
Posts: 190
Joined: 04 Sep 2010, 19:48
Location: Ratingen, Germany
Contact:

Postby Robbilie » 18 Jul 2011, 09:56

thomas i rly need this :D

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 8 guests