Posts: 70
	Threads: 23
	Joined: Nov 2010
	
Reputation: 
0
	 
	
	
		Here's the thing, I want to create a system in which you can purchase and unlock almost any skin you want, but I have no idea how will I be able to save the unlocked skin data, storing the data ingame would most likely be with an array or something, but how exactly should I save without creating thousands of variables? Is it possible with MySQL? Or is it better with .ini files or something?
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 325
	Threads: 14
	Joined: Aug 2014
	
Reputation: 
0
	 
	
	
		Here is something you can try. Create a table called skins. Add two columns, userid, skinid, purcahsed. When someone unlocks a skin, Add a new entry to the table and set the purchased to false. When he purchases it, Set the purchased to true. When you want to read data, You can select * from skins where userid = `playeruserid` and then store it in an array.
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 70
	Threads: 23
	Joined: Nov 2010
	
Reputation: 
0
	 
	
	
		Hmm, maybe. It was something I had in mind. I'm guessing mysql will have no problems storing this much skin data if lots of players are going to have lots of skins unlocked.
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 219
	Threads: 0
	Joined: Oct 2012
	
Reputation: 
0
	 
	
	
		If you're talking about my suggestion then you are right, mysql won't have any problem storing that information and it's easy to manipulate.
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 1,208
	Threads: 36
	Joined: Apr 2015
	
	
 
	
	
		312 Bytes string for all players, rly ?
PHP код:
/*
IsTogglePlayerSkin(playerid,skinid);
TogglePlayerSkin(playerid,skinid,toggle); //toggle 0/1
*/
new unlockedSkin[MAX_PLAYERS][GetConfigSize(312)]; //real size MAX_PLAYERS * 10
#define IsTogglePlayerSkin(%0,%1)        IsToggleConfigInformation(unlockedSkin[(%0)],(%1))
#define TogglePlayerSkin(%0,%1,%2)        ToggleConfigInformation(unlockedSkin[(%0)],(%1),(%2))
// mysql/ini data store
//0 - 9
for(new i = 0; i < GetConfigSize(312); i++){
    //get or save unlockedSkin[playerid][i]
} 
 10 x 4 Bytes integer values vs 312 Bytes String
BitFunctions:
https://sampforum.blast.hk/showthread.php?tid=591223
	
		
	
 
 
	
	
	
		
	Posts: 10,066
	Threads: 38
	Joined: Sep 2007
	
Reputation: 
0
	 
	
	
		Wow, a whole 1.2 megabytes for a 1000 player server. /s Seriously, trade off memory for increased speed rather than the other way around. It's not like you're pressed for space or anything. I use bitflags and char arrays sometimes as well but I'm not going to bother with anything else 
As far as I'm concerned, DarkSkull's method is still the best approach. Aly's approach may work too but it violates 1NF which states that each attribute may only contain exactly one atomic (indivisible) value.