Skip to content

Commit

Permalink
Fixed items being removed in a certain scenario nuclearsilo583#33
Browse files Browse the repository at this point in the history
Items would get removed from a player's inventory if they removed it then got it again in the same map.
This bug affected every store item.
  • Loading branch information
azalty authored and nuclearsilo583 committed Dec 28, 2022
1 parent bbe230c commit 2b365b6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions addons/sourcemod/scripting/store/store_functions.sp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ public void Store_SaveClientInventory(int client)
SQL_TVoid(g_hDatabase, m_szQuery);
} else if(g_eClientItems[client][i].bSynced && g_eClientItems[client][i].bDeleted)
{
g_eClientItems[client][i].bSynced = false; // Prevents the function from trying to delete the item again the next time it's called

// Might have been synced already but ID wasn't acquired
if(g_eClientItems[client][i].iId_Client_Item==-1)
Format(STRING(m_szQuery), "DELETE FROM store_items WHERE `player_id`=%d AND `type`='%s' AND `unique_id`='%s'", g_eClients[client].iId_Client, m_szType, m_szUniqueId);
Expand Down
2 changes: 2 additions & 0 deletions addons/sourcemod/scripting/store_combine.sp
Original file line number Diff line number Diff line change
Expand Up @@ -3919,6 +3919,8 @@ public void Store_SaveClientInventory(int client)
SQL_TVoid(g_hDatabase, m_szQuery);
} else if(g_eClientItems[client][i].bSynced && g_eClientItems[client][i].bDeleted)
{
g_eClientItems[client][i].bSynced = false; // Prevents the function from trying to delete the item again the next time it's called

// Might have been synced already but ID wasn't acquired
if(g_eClientItems[client][i].iId_Client_Item==-1)
Format(STRING(m_szQuery), "DELETE FROM store_items WHERE `player_id`=%d AND `type`='%s' AND `unique_id`='%s'", g_eClients[client].iId_Client, m_szType, m_szUniqueId);
Expand Down

0 comments on commit 2b365b6

Please sign in to comment.