23.09.2017, 17:28
So for some reason, when a player drops/buys an item, after the delete/insert query it shows an item or 2 out of your inventory in another players inventory.
I can't seem to see the issue.
Load Query:
function:Query_LoadInvItems:
AddToInv(the insert query after purchasing an item):
I can't seem to see the issue.
Load Query:
PHP Code:
mysql_format(ourConnection, query, sizeof(query), "SELECT * FROM inventory_items WHERE char_id = %i", PlayerInfo[playerid][pDBID]);
mysql_tquery(ourConnection, query, "Query_LoadInvItems", "i", PlayerInfo[playerid][pDBID]);
PHP Code:
function:Query_LoadInvItems(playerid, invid)
{
new rows, fields;
cache_get_row_count(rows);
cache_get_field_count(fields);
for (new i = 0; i < rows; i++)
{
cache_get_value_name_int(i, "items_id", InvItems[i][iItemsID]);
cache_get_value_name_int(i, "char_id", InvItems[i][iCharID]);
cache_get_value_name_int(i, "modelid", InvItems[i][iModelID]);
cache_get_value_name(i, "item_name", InvItems[i][iItemName], 50);
cache_get_value_name_int(i, "item_amount", InvItems[i][iItemAmount]);
}
}
PHP Code:
function:AddToInv(playerid, modelid, itemname[], itemamount)
{
new newinv = ReturnInvItems(playerid);
new query[256];
if(newinv < 16)
{
mysql_format(ourConnection, query, sizeof(query), "INSERT INTO inventory_items (char_id, modelid, item_name, item_amount) VALUES(%i, %i,'%s', %i)", PlayerInfo[playerid][pDBID], modelid, itemname, itemamount);
mysql_query(ourConnection, query);
}
else return SendErrorMessage(playerid, "SERVER: Your inventory is full.");
return 1;
}