Velaski
winner
- Aug 4, 2015
- 562
- 165
Ok, title may be a bit confusing I will explain.
I have my code here:
And I want that "ID" to match the current userid, and I'm coding the manager. This is my current code:
I also want it to start as default:
ID = Default userid
HP = 100
Kills = 0
Deaths = 0
Can anybody help real quick?
@JayCustom @Sledmore @Altercationz @Meap
I have my code here:
Code:
class Character
{
public int Id { get; set; }
public int HP { get; set; }
public int Kills { get; set; }
public int Deaths { get; set; }
public Character(int Id, int HP, int Kills, int Deaths)
{
this.Id = Id;
this.HP = HP;
this.Kills = Kills;
this.Deaths = Deaths;
}
}
Code:
using log4net;
using Plus.Database.Interfaces;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Plus.HabboHotel.Minigames
{
class CharacterManager
{
private static readonly ILog log = LogManager.GetLogger("Plus.HabboHotel.Minigames.CharacterManager");
private readonly Dictionary<int, Character> _character = new Dictionary<int, Character>();
public CharacterManager()
{
}
public void Init()
{
if (this._character.Count > 0)
this._character.Clear();
using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
{
dbClient.SetQuery("SELECT * FROM `userminigame_stats`;");
DataTable GetCharacter = dbClient.getTable();
if (GetCharacter != null)
{
foreach (DataRow Row in GetCharacter.Rows)
{
if (!this._character.ContainsKey(Convert.ToInt32(Row["id"])))
this._character.Add(Convert.ToInt32(Row["id"]), new Character(Convert.ToInt32(Row["id"]), Convert.ToInt32(Row["hp"]), Convert.ToInt32(Row["kills"]), Convert.ToInt32(Row["deaths"])));
}
}
}
log.Info("Loaded " + this._character.Count + " Minigame Character Codes.");
}
}
}
I also want it to start as default:
ID = Default userid
HP = 100
Kills = 0
Deaths = 0
Can anybody help real quick?
@JayCustom @Sledmore @Altercationz @Meap