Example #1
0
        public void savePlayer(WorldClient client)
        {
            conn.Open();
            System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
            customCulture.NumberFormat.NumberDecimalSeparator    = ".";
            System.Threading.Thread.CurrentThread.CurrentCulture = customCulture;

            UInt32 charID = NumericalUtils.ByteArrayToUint32(client.playerInstance.CharacterID.getValue(), 1);
            string handle = StringUtils.charBytesToString_NZ(client.playerInstance.CharacterName.getValue());

            int [] rsiValues = client.playerData.getRsiValues();

            double x = 0; double y = 0; double z = 0;

            byte[] Ltvector3d = client.playerInstance.Position.getValue();
            NumericalUtils.LtVector3dToDoubles(Ltvector3d, ref x, ref y, ref z);

            int rotation = (int)client.playerInstance.YawInterval.getValue()[0];

            string sqlQuery = "update characters set x =" + x + " ,y=" + y + " ,z=" + z + " , rotation=" + rotation + ", districtId=" + client.playerData.getDistrictId() + " where handle='" + handle + "' ";

            queryExecuter.CommandText = sqlQuery;
            queryExecuter.ExecuteNonQuery();
            Output.WriteLine(StringUtils.bytesToString(StringUtils.stringToBytes(sqlQuery)));
            Output.writeToLogForConsole(queryExecuter.ExecuteNonQuery() + " rows affecting saving");

            string rsiQuery = "update rsivalues set sex='" + rsiValues[0] + "',body='" + rsiValues[1] + "',hat='" + rsiValues[2] + "',face='" + rsiValues[3] + "',shirt='" + rsiValues[4] + "',coat='" + rsiValues[5] + "',pants='" + rsiValues[6] + "',shoes='" + rsiValues[7] + "',gloves='" + rsiValues[8] + "',glasses='" + rsiValues[9] + "',hair='" + rsiValues[10] + "',facialdetail='" + rsiValues[11] + "',shirtcolor='" + rsiValues[12] + "',pantscolor='" + rsiValues[13] + "',coatcolor='" + rsiValues[14] + "',shoecolor='" + rsiValues[15] + "',glassescolor='" + rsiValues[16] + "',haircolor='" + rsiValues[17] + "',skintone='" + rsiValues[18] + "',tattoo='" + rsiValues[19] + "',facialdetailcolor='" + rsiValues[20] + "',leggins='" + rsiValues[21] + "' where charId='" + charID + "';";

            queryExecuter             = conn.CreateCommand();
            queryExecuter.CommandText = rsiQuery;
            Output.writeToLogForConsole("[WORLD DB ACCESS ]" + rsiQuery);
            queryExecuter.ExecuteNonQuery();
            conn.Close();
        }
Example #2
0
        public UInt32 getUserIdForCharId(byte[] charIdHex)
        {
            UInt32 charId = NumericalUtils.ByteArrayToUint32(charIdHex, 1);

            Output.OptWriteLine("[WORLD] Checking from DB:" + charId);
            string sqlQuery = "Select userid from characters where charid ='" + charId + "'";

            queryExecuter             = conn.CreateCommand();
            queryExecuter.CommandText = sqlQuery;
            dr = queryExecuter.ExecuteReader();

            UInt32 userId = new UInt32();

            while (dr.Read())
            {
                userId = (UInt32)dr.GetDecimal(0);
            }

            dr.Close();

            return(userId);
        }