Hashtable Add question

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

Moderators: Lapo, Bax

matrix211v1
Posts: 61
Joined: 16 Jan 2009, 14:48

Hashtable Add question

Postby matrix211v1 » 08 May 2009, 15:06

Hello All!

I am trying to add a Vector3 using the HashTable.Add, such as this:

Code: Select all

String ColorChoice;
String CharacterType;
String CharacterName;
Vector3 CharacterLocation;

client = GetClient();
Hashtable myHashtable = new Hashtable();
myHashtable.Add("ColorChoice", ColorChoice);
myHashtable.Add("CharacterType", CharacterType);
myHashtable.Add("CharacterName", CharacterName);
myHashtable.Add("Pos", CharacterLocation);
client.SetUserVariables(myHashtable);


The first 3 will go into the SetUserVariables just fine, but the Vector3 won't. I have also tried to break up the Vector3 as string but I was not allowed to convert Vector3 to a String such as:

String xPos = (String)CharacterLocation.x;

or

String xPos = (String)CharacterLocation[0];

It's simple. I just need to store the player spawnpoint in the SetUserVariables. Anything I am over looking?

Thanks!
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 08 May 2009, 21:32

Dont think you can cast a float to string that way in C#.

float.Parse(CharacterLocation.x) should do it (frsh from memory without a compiler to check syntax)

Edit:
Argh - its the other way around - a bit easier

CharacterLocation.x.ToString();

Might need to do some fiddling with the globalization settings due to a bug in the mono version that Unity uses though.

/T
Last edited by ThomasLund on 08 May 2009, 21:42, edited 1 time in total.
matrix211v1
Posts: 61
Joined: 16 Jan 2009, 14:48

Tried

Postby matrix211v1 » 08 May 2009, 21:34

I belived I tried that (float.Parse(CharacterLocation.x) but I don't think Unity liked it.
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 09 May 2009, 06:57

*poke*

See my edit :-)

(I saw on the date stamp that my edit came after your posting)

Return to “.Net / Unity3D API”

Who is online

Users browsing this forum: No registered users and 27 guests