Here is some of my wired coding with less mysql action so it won't make you server lagg much.
PHP Code:
RequestHandlers[3056] = new RequestHandler(InitializeWired);
RequestHandlers[3050] = new RequestHandler(RequestAddWired);
RequestHandlers[3051] = new RequestHandler(RequestAddTrigger);
RequestHandlers[3058] = new RequestHandler(GetFurniStates);
RequestHandlers[3052] = new RequestHandler(AddTriggerStatus);
RequestHandlers[3057] = new RequestHandler(RefreshWired);
RequestHandlers[3053] = new RequestHandler(DeleteWired);
RequestHandlers[3054] = new RequestHandler(DeleteWiredTrigger);
RequestHandlers[3055] = new RequestHandler(DeleteWiredAction);
PHP Code:
private void SerializeWired()
{
GetResponse().Init(650);
}
if (Data.Rows.Count == 0)
{
GetResponse().AppendStringWithBreak("H");
}
else
{
GetResponse().AppendInt32(Data.Rows.Count);
foreach (DataRow Row in Data.Rows)
{
GetResponse().AppendInt32(int.Parse(Row["slotid"].ToString()));
if (Row["triggertype"].ToString() == "say")
{
GetResponse().AppendStringWithBreak("HIH");
GetResponse().AppendStringWithBreak(Row["whattrigger"].ToString());
using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
{
if (Action["typeaction"].ToString() == "status")
{
GetResponse().AppendString("HHHI");
GetResponse().AppendInt32(int.Parse(Action["itemid"].ToString()));
Room Room = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);
RoomItem Item = Room.GetItem(uint.Parse(Action["itemid"].ToString()));
GetResponse().AppendString(Item.GetBaseItem().PublicName);
GetResponse().AppendStringWithBreak("");
GetResponse().AppendStringWithBreak(Action["whataction"].ToString());
GetResponse().AppendString("HHK");
}
else if (Action["typeaction"].ToString() == "kick")
{
GetResponse().AppendStringWithBreak("HHHIH");
GetResponse().AppendStringWithBreak("");
GetResponse().AppendString("HHJ");
}
}
else
{
GetResponse().AppendString("HHHH");
}
}
}
else if (Row["triggertype"].ToString() == "walkon")
{
GetResponse().AppendString("HI");
GetResponse().AppendInt32(int.Parse(Row["whattrigger"].ToString()));
Room Room = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);
RoomItem Item = Room.GetItem(uint.Parse(Row["whattrigger"].ToString()));
GetResponse().AppendStringWithBreak(Item.GetBaseItem().PublicName);
GetResponse().AppendStringWithBreak("");
using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
{
if (dbClient.findsResult("select * from wiredaction where slotid = '" + Row["slotid"].ToString() + "'"))
{
DataRow Action = null;
Action = dbClient.ReadDataRow("SELECT * from wiredaction where slotid = '" + Row["slotid"].ToString() + "'");
if (Action["typeaction"].ToString() == "status")
{
GetResponse().AppendString("HHII");
GetResponse().AppendInt32(int.Parse(Action["itemid"].ToString()));
Item = Room.GetItem(uint.Parse(Action["itemid"].ToString()));
GetResponse().AppendString(Item.GetBaseItem().PublicName);
GetResponse().AppendStringWithBreak("");
GetResponse().AppendStringWithBreak(Action["whataction"].ToString());
GetResponse().AppendString("HHK");
}
else if (Action["typeaction"].ToString() == "kick")
{
GetResponse().AppendStringWithBreak("HHIIH");
GetResponse().AppendStringWithBreak("");
GetResponse().AppendString("HHJ");
}
}
else
{
GetResponse().AppendString("HHIH");
}
}
}
else
GetResponse().AppendString("HHH");
}
GetResponse().AppendStringWithBreak("");
}
SendResponse();
}
private void InitializeWired()
{
SerializeWired();
}
private void RequestAddWired()
{
GetResponse().Init(650);
int SlotID = 0;
using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient();
{
using (DatabaseClient dbClient = UberEnviroment.GetDatabase().GetClient();
private void RequestAddTrigger()
{
uint SlotID = Request.PopWiredUInt();
int Chose = Request.PopWiredInt32();
string ExtraData = null;
string Type = "";
}
SerializeWired();
}
private void RequestAddTrigger()
{
uint SlotID = Request.PopWiredUInt();
int Chose = Request.PopWiredInt32();
string ExtraData = null;
string Type = "";
if (Chose==0)
{
Request.AdvancePointer(3);
Type = "say";
ExtraData = Request.PopFixedString();
}
if (Chose==1)
{
ExtraData = Request.PopWiredInt32().ToString();
Request.AdvancePointer(3);
Type = "walkon";
}
using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
{
dbClient.ExecuteQuery("update wiredtrigger set triggertype = '" + Type + "',whattrigger = '" + ExtraData + "' where slotid = '" + SlotID + "'");
}
SerializeWired();
}
private void GetFurniStates()
{
GetResponse().Init(651);
GetResponse().AppendStringWithBreak("JHI");
SendResponse();
}
private void AddTriggerStatus()
{
int slotID = Request.PopWiredInt32();
int Type = Request.PopWiredInt32();
int ItemID = 0;
string ItemName = "";
int status = 0;
if (Type == 3)
{
ItemID = Request.PopWiredInt32();
ItemName = Request.PopFixedString();
status = Request.PopFixedInt32();
using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
{
dbClient.ExecuteQuery("INSERT INTO wiredaction values ('" + slotID + "','status','" + status + "','" + ItemID + "')");
}
}
if (Type ==2)
{
ItemID = Request.PopWiredInt32();
ItemName = Request.PopFixedString();
status = Request.PopFixedInt32();
using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
{
dbClient.ExecuteQuery("INSERT INTO wiredaction values ('" + slotID + "','kick','','')");
}
}
SerializeWired();
}
private void DeleteWired()
{
int slotID = Request.PopWiredInt32();
using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
{
dbClient.ExecuteQuery("delete from wiredtrigger where slotid= '" + slotID+"'");
dbClient.ExecuteQuery("delete from wiredaction where slotid= '" + slotID + "'");
}
private void DeleteWiredTrigger()
{
int slotID = Request.PopWiredInt32();
using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
{
dbClient.ExecuteQuery("delete from wiredaction where slotid= '" + slotID + "'");
dbClient.ExecuteQuery("delete from wiredtrigger where slotid= '" + slotID + "'");
}
SerializeWired();
}
dbClient.ExecuteQuery("delete from wiredaction where slotid= '" + slotID + "'");
}
SerializeWired();
}