Room Variables not Working - Please Help

Post here all your questions related with SmartFoxServer .Net/Unity3D API

Moderators: Lapo, Bax

kaligus
Posts: 45
Joined: 01 Sep 2009, 13:26

Room Variables not Working - Please Help

Postby kaligus » 05 Oct 2009, 10:44

Hello all,

please, I'm having a new issue... this one is related to room variables.
I made my login with a custom script. Then made a lobby room, etc.
When the user creates a new room (game room), it creates 2 variables. I checked into Admin Tool of SFS and the variables are all there, so, creating variables works.

But when I try to get the variables I got this error:

Code: Select all

InvalidCastException: Cannot cast from source type to destination type.
csFase_Core.OnGUI ()   (at Assets\Game\Scripts Gerais\Fases\csFase_Core.cs:207)
UnityEditor.EditorGUIUtility:RenderGameViewCameras(Rect, Rect, Boolean, Boolean)
UnityEditor.EditorGUIUtility:RenderGameViewCameras(Rect, Rect, Boolean, Boolean)
UnityEditor.GameView:OnGUI() (at C:\builds\unity-branches-2.5.x\unity-2.5.x\Editor\Mono\GameView\GameView.cs:192)
System.Reflection.MonoMethod:InternalInvoke(Object, Object[])
System.Reflection.MonoMethod:InternalInvoke(Object, Object[])
System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
System.Reflection.MethodBase:Invoke(Object, Object[])
UnityEditor.HostView:Invoke(String) (at C:\builds\unity-branches-2.5.x\unity-2.5.x\Editor\Mono\GUI\DockArea.cs:156)
UnityEditor.MaximizedHostView:OnGUI() (at C:\builds\unity-branches-2.5.x\unity-2.5.x\Editor\Mono\GUI\DockArea.cs:872)


The code where the errors occurs:

Code: Select all

Hashtable vars = room.GetVariables();
foreach (string v in vars.Values) {
   Debug.Log("Name: " + v + " Value: " + room.GetVariable(v));
}


The script above is the same from the documents...
What am I doing wrong? :cry:

Please help
kaligus
Posts: 45
Joined: 01 Sep 2009, 13:26

Postby kaligus » 06 Oct 2009, 13:37

Please, anyone?
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 06 Oct 2009, 17:31

A guess - is that the variable is of a type that cannot be cast to string without explicitly casting it.

Try to print the type of the variable key only and see if that gives a clue

/Thomas
kaligus
Posts: 45
Joined: 01 Sep 2009, 13:26

Postby kaligus » 06 Oct 2009, 19:06

I tried to put into the Debug from Unity... but it returns me another error... can you give me an example, please, Thomas?

EDIT: the variables are numeric... do I need to convert to string? If yes, how can I convert? But even numeric numbers works in Debug Logs, like Debug.Log ("Test: " + someNumericINteger);
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 06 Oct 2009, 20:33

If they are integers then try int.Parse(*string here*) - floats can do float.Parse() instead, but you might also have to set the Culture so that , and . as delimiters will be set correctly

/Thomas
kaligus
Posts: 45
Joined: 01 Sep 2009, 13:26

Postby kaligus » 07 Oct 2009, 10:32

Hello Thomas, thanks for the reply.

I tried a lot of ways here :lol: and still same error... I also tried to use a string into the room variable, it creates good, but it returns me the same error...
Sorry, what do you mean "set culture"?

Do you think could be a bug? Can you make some tests on your own in there, please?

I just dont understand why this does not work.
kaligus
Posts: 45
Joined: 01 Sep 2009, 13:26

Postby kaligus » 14 Oct 2009, 00:55

Hello again,

sorry keep bothering you guys with this, but it is getting anoying :lol:
I cant figure out what is the error...

Maybe a bug?
kaligus
Posts: 45
Joined: 01 Sep 2009, 13:26

Postby kaligus » 26 Oct 2009, 16:12

Ok, no answers so far... this "feature" is a "must in" in my game and it does not work (so far I think its a bug, no one asnwered me again), I cant buy SFS and I cant use the API with Unity because of this! Is Unity API supported by SFS Team? So far I know Thomas was the guy who created this (wonderful job) and he is not inside SFS team...

I'm now considering trying other backend, because this does not work.

Anyone tried this? I made a simple test, with examples from docs, tried diferent sintaxes and nothing... it just does not work!
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 21 Nov 2009, 13:39

Working on this one, and wanted to buzz you back that it seems like a genuine bug!

Last one on my list for stuff to fix, so expect new API version very soon

/Thomas
kaligus
Posts: 45
Joined: 01 Sep 2009, 13:26

Postby kaligus » 21 Nov 2009, 14:12

Thank you, Thomas.
I'm still using SFS with Unity, but making only the IA and NPC stuff now.

Return to “.Net / Unity3D API”

Who is online

Users browsing this forum: No registered users and 15 guests