i try to deal with this code since yesterday and im lost right now so i try it here.
so im creating a table with few columns which works fine so far, also updating it works fine, the only problem which is not working correctly is reading the table, but only when i use the logical operators WHERE and AND, here is the code.
inline void ReadMaterialStorageNew(int UID, int MatIndex, int &MatAmount, int &MatSlot)
{
std::stringstream Select; sqlite3_stmt *stmt;
Select << "SELECT * FROM MaterialStorageNew WHERE UID = '" << UID << "' AND MatIndex = '" << MatIndex << "'";
if (sqlite3_prepare_v2(R3volutioN, Select.str().c_str(), -1, &stmt, 0) == SQLITE_OK)
{
sqlite3_step(stmt);
MatAmount = sqlite3_column_int(stmt,2);
MatSlot = sqlite3_column_int(stmt,3);
}
sqlite3_finalize(stmt);
}
my code im interacting with the code below is this one
// MaterialStorage - Item In
if (IPlayer.IsOnline() && IPlayer.GetPID() && IPlayer.GetUID() && MaterialStorageSystem.count(Quest.GetIndex()) && MaterialStorageSystem.find(Quest.GetIndex())->second.QIndex == Quest.GetIndex())
{
int MaterialCheck = CPlayer::FindItem(IPlayer.GetOffset(),MaterialStorageSystem.find(Quest.GetIndex())->second.MaterialIndex,1);
std::string MName = MaterialStorageSystem.find(Quest.GetIndex())->second.MaterialName;
int MIndex = MaterialStorageSystem.find(Quest.GetIndex())->second.MaterialIndex;
if (!MaterialCheck)
{
IPlayer.BoxMsg("You do not have any Material to Store");
return;
}
int MatIndex = 0, MatAmount = 0, MatSlot = 0;
MainSvrT::ReadMaterialStorageNew(IPlayer.GetUID(),MatIndex,MatAmount,MatSlot);
if (MatSlot == 1)
{
IPlayer.BoxMsg("Slot is in usage, remove the stored item first.");
return;
}
if (MatSlot == 0)
{
IItem IItem((void*)MaterialCheck);
int TurnInValue = MaterialCheck;
TurnInValue = IItem.GetAmount();
MainSvrT::UpdateMaterialStorageNew(IPlayer.GetUID(),MatIndex=MIndex,MatAmount+TurnInValue,MatSlot+1);
MainSvrT::ReadMaterialStorageNew(IPlayer.GetUID(),MatIndex,MatAmount,MatSlot);
IPlayer.DecreaseItemAmount(MIndex,TurnInValue);
IPlayer.BoxMsg("you storaged in " + MName + " and got a total of " + Int2String(MatAmount) + " in your Material Storage ");
return;
}
return;
}
when using the and operator it completely ignores my checks like if (MatSlot == 1). when i do not use the operator AND, and only select the UID, then it reads my checks.
ofcourse it doesnt do work that way as i have to select UID -> MatIndex to replace the correct values, the MatIndex is a UNIQUE index btw, as you can insert different indexes into the table with the same UID.
ive tried alot different logical operators, like changing = to IN, or used OR and not AND, but when using OR, it does read, but from the first entry in the table, and not the correct one, like ID 1 <- but it does read this one ID 2 <- this one i want to replace ID 3
hope anyone had to deal with that stuff before and can help me, thanks alot.