13.01.2017, 17:47
(
Последний раз редактировалось PeanutButter; 13.01.2017 в 18:17.
)
Hello, What do you guys think is the most efficient way of storing data for an inventory system?
The way I'm doing it right now is just creating a new row in the inventory db for each object of each player. The problem with that is that if the players own a lot of items it's going to take a long time for the code to loop through all the rows.
I tried to make something like GetLastInvID(playerid), which gets the last id for a specific player to reduce the amount of iterations. But that probably won't make a big difference.
How can I improve my code and/or database structure to get the fastest results?
The way I'm doing it right now is just creating a new row in the inventory db for each object of each player. The problem with that is that if the players own a lot of items it's going to take a long time for the code to loop through all the rows.
PHP код:
for(new i; i <= GetLastInvID(playerid); i++)
{
//this code checks if i, which is the id of the object in the database, is owned by the player. If yes the object is given to the player
}
How can I improve my code and/or database structure to get the fastest results?