Hashtable tutorial?

Options
I need some way to store kills and deaths, SetCustomProperties seems like the way to do it. But I've never really used Hashtables before. Can someone point me to a tutorial or guide. The ones I've found here or on Google give me this error, when I try to SetCustomProperties() . error CS1503: Argument `#1' cannot convert `System.Collections.Hashtable' expression to type `ExitGames.Client.Photon.Hashtable'

Here is some of my code so far

[code2=csharp]using UnityEngine;
using System.Collections;

public class MPKillDeathCountPing : Photon.MonoBehaviour {

public int killCount;
public int deathCount;
public Hashtable PlayerCustomProperties = new Hashtable();
//Add the kill part to when a player is hit and health is 0 or less.

// Use this for initialization
void Awake () {
if (photonView.isMine == true)
{
PlayerCustomProperties.Add("Kills", killCount);
// ERROR RIGHT HERE
PhotonNetwork.player.SetCustomProperties(PlayerCustomProperties);
killCount = 0;
deathCount = 0;
}
else
{
enabled = false;
}

}

// Update is called once per frame
void Update () {

}
void OnGUI()
{
GUILayout.Space(20);
GUILayout.Label("Ping: " + PhotonNetwork.GetPing().ToString());
GUILayout.Space(5);
GUILayout.Label("Kills: " + killCount.ToString());
GUILayout.Space(5);
GUILayout.Label("Deaths: " + deathCount.ToString());


}


void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if (stream.isWriting)
{
// We own this player: send the others our data
}
else
{
// Network player, receive data
}
}
}[/code2]
Thanks.

Comments

  • cj31387
    Options
    Btw where is code insert in this forum? Don't see it.
  • Tobias
    Options
    You have to define that you want to use Photon's Hashtable class. This is done by adding a "using" statement at the top of your class. Like so:

    [code2=csharp]using UnityEngine;
    using System.Collections;
    using Hashtable = ExitGames.Client.Photon.Hashtable;[/code2]

    For code insertions: The "full" editor has a drop down "Code". Select your code, then pick the fitting language from the Code dropdown.
    Keep in mind that less code is better for us to read and answer at all.
  • cj31387
    Options
    That worked thanks!!