Plus Emu r2.1 [RP] [Project Butter C#]

Status
Not open for further replies.

Zodiak

recovering crack addict
Nov 18, 2011
453
417
Just a few tips for future reference;
1) Don't use SQL queries so much, cache/store not so important things.
2) If you're going to run queries clean them up e.g, "SELECT `1`,`2` FROM `table` WHERE `1` = 'whatever'; LIMIT 1"
3) If you're grabbing a row from a table, there's no point using datatable and foreach'ing it.
4) Use ['columnname'] instead of [0],[1],[2] on data rows, otherwise it'll take you a while to remember which columns which if you make a mistake and need to go back to it.
Code:
DataRow dRow = null;

using(IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().getQueryreactor())
{
   dbClient.setquery("SELECT * FROM `users` WHERE `id` = @id LIMIT 1");
   dbClient.addParameter('id', Id);

    dRow = dbClient.getRow();
  
    if(dRow != null)
    {
        Health = (int)dRow["health"];
                    Energy = Convert.ToInt32(dRow["energy"]);
                    Hunger = Convert.ToInt32(dRow["hunger"]);
                    Kills = Convert.ToInt32(dRow["kills"]);
                    XP = Convert.ToInt32(dRow["xp"]);
                    XPdue = Convert.ToInt32(dRow["xpdue"]);
                    Strength = Convert.ToInt32(dRow["strength"]);
                    Deaths = Convert.ToInt32(dRow["deaths"]);
                    Jailed = Convert.ToInt32(dRow["jailed"]);
                    Dead = Convert.ToInt32(dRow["dead"]);
                    Job = Convert.ToInt32(dRow["job"]);
                    Punches = Convert.ToInt32(dRow["punches"]);
                    Arrests = Convert.ToInt32(dRow["arrests"]);
                    Noob = Convert.ToInt32(dRow["noob"]);
    }
}
 

Sledmore

Chaturbate Livestreamer
Staff member
FindRetros Moderator
Jul 24, 2010
5,199
3,934
Thread closed due to lack of updates. Message me if you'd like this re-opening.
 
Status
Not open for further replies.

Users who are viewing this thread

Top