Code:
bool cChat::WareCommand(LPOBJ gObj, char *Msg)
{
if (CheckCommand(gObj, Configs.Commands.IsMultyVault, GmSystem.NONE, Configs.Commands.ZenForChange, Configs.Commands.PcPointForChange, Configs.Commands.WCoinForChange, Configs.Commands.WebPointsForChange, 0, 1, 0, "Ware", "/ware <num>", Msg))
return true;
if (gObj->WarehouseSave != 0 && gObj->m_IfState.use != 0 && gObj->m_IfState.state != 0 && gObj->m_bMapSvrMoveReq != false && gObj->m_bMapSvrMoveQuit != false && gObj->m_State != 1)
{
MessageLog(1, c_Red, t_COMMANDS, gObj, "[Ware] Stop all you actions and try again!");
return true;
}
int WantSlot = 0;
int UsedSlot = 0;
sscanf(Msg, "%d", &WantSlot);
if (MuOnlineQuery.ExecQuery("SELECT UsedSlot FROM warehouse WHERE AccountID = '%s'", gObj->AccountID) == TRUE)
{
short result = MuOnlineQuery.Fetch();
if (result != SQL_NO_DATA && result != SQL_NULL_DATA)
{
UsedSlot = MuOnlineQuery.GetAsInteger("UsedSlot");
}
}
MuOnlineQuery.Close();
if (UsedSlot <= 0)
{
MuOnlineQuery.ExecQuery("UPDATE warehouse SET Items01 = Items, UsedSlot = 1 WHERE AccountID = '%s'", gObj->AccountID);
MuOnlineQuery.Close();
MessageLog(1, c_Red, t_COMMANDS, gObj, "[Ware] something went wrong please try again!");
return true;
}
else
{
if (WantSlot < 1 || WantSlot > Configs.Commands.NumberOfVaults)
{
MessageLog(1, c_Red, t_COMMANDS, gObj, "[Ware] You can use from 1 to %d ware!", Configs.Commands.NumberOfVaults);
return true;
}
if (UsedSlot == WantSlot)
{
MessageLog(1, c_Red, t_COMMANDS, gObj, "[Ware] You need to chose other vault number!");
return true;
}
TakeCommand(gObj, Configs.Commands.ZenForChange, Configs.Commands.PcPointForChange, Configs.Commands.WCoinForChange, Configs.Commands.WebPointsForChange, "Ware");
if (MuOnlineQuery.ExecQuery("UPDATE warehouse SET Items%02d = Items, Items = Items%02d, UsedSlot = %d WHERE AccountID = '%s'", UsedSlot, WantSlot, WantSlot, gObj->AccountID) == TRUE)
MessageLog(1, c_Red, t_COMMANDS, gObj, "[Ware] You successfully change vault from %d to %d!", UsedSlot, WantSlot);
else
MessageLog(1, c_Red, t_COMMANDS, gObj, "[Ware] something went wrong please try again!", UsedSlot, WantSlot);
MuOnlineQuery.Close();
}
return true;
}
i edit IA Julia code to make it more secure and friendly BTW the code its not tested but should work good