namespace Holo.Virtual.Users.Items { using Holo; using Ion.Storage; using System; using System.Text; internal class virtualSongEditor { private int machineID; private int[] Slot; private int userID; internal virtualSongEditor(int machineID, int userID) { this.machineID = machineID; this.userID = userID; this.Slot = new int[4]; this.loadSoundsets(); } internal void addSoundset(int soundSetID, int slotID) { this.Slot[slotID - 1] = soundSetID; using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient()) { dbClient.runQuery(string.Concat(new object[] { "UPDATE furniture SET roomid = '-3',soundmachine_machineid = '", this.machineID, "',soundmachine_slot = '", slotID, "' WHERE ownerid = '", this.userID, "' AND soundmachine_soundset = '", soundSetID, "' ORDER BY id ASC LIMIT 1" })); } } internal string getSoundsets() { int Amount = 0; StringBuilder Soundsets = new StringBuilder(); for (int slotID = 0; slotID < 4; slotID++) { int Soundset = this.Slot[slotID]; if (Soundset > 0) { Soundsets.Append(Encoding.encodeVL64(slotID + 1) + Encoding.encodeVL64(Soundset) + "QB"); int v = (Soundset * 9) - 8; for (int j = v; j <= (v + 8); j++) { Soundsets.Append(Encoding.encodeVL64(j)); } Amount++; } } return ("PA" + Encoding.encodeVL64(Amount) + Soundsets.ToString()); } internal void loadSoundsets() { using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient()) { this.Slot[0] = dbClient.getInt("SELECT soundmachine_soundset FROM furniture WHERE soundmachine_machineid = '" + this.machineID + "' AND soundmachine_slot = '1'"); this.Slot[1] = dbClient.getInt("SELECT soundmachine_soundset FROM furniture WHERE soundmachine_machineid = '" + this.machineID + "' AND soundmachine_slot = '2'"); this.Slot[2] = dbClient.getInt("SELECT soundmachine_soundset FROM furniture WHERE soundmachine_machineid = '" + this.machineID + "' AND soundmachine_slot = '3'"); this.Slot[3] = dbClient.getInt("SELECT soundmachine_soundset FROM furniture WHERE soundmachine_machineid = '" + this.machineID + "' AND soundmachine_slot = '4'"); } } internal void removeSoundset(int slotID) { this.Slot[slotID - 1] = 0; using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient()) { dbClient.runQuery(string.Concat(new object[] { "UPDATE furniture SET roomid = '0',soundmachine_machineid = NULL,soundmachine_slot = NULL WHERE ownerid = '", this.userID, "' AND soundmachine_machineid = '", this.machineID, "' AND soundmachine_slot = '", slotID, "' LIMIT 1" })); } } internal bool slotFree(int slotID) { return (this.Slot[slotID - 1] == 0); } } }