Mysql loop all data and store it
#1

Like the title says .. i need to load and store all data at once and i tried this:

Code:
stock IncarcaSkinSelector()
{	
	mysql_tquery(connectionHandle, "SELECT * FROM skin_selector", "LoadModelSelectionMenu", "d", INITMSELECTION_THREAD_ID);
	return 1;
}
The table: https://imgur.com/a/aWM2r

Code:
//-------------------
function LoadModelSelectionMenu()
{
	new rows = cache_num_rows();
	counted = 0;
	if(rows) 
	{
		SkinSelectorInfo[0][ssSkinid] = cache_get_row_int(0, 1);
		SkinSelectorInfo[1][ssSkinid] = cache_get_row_int(1, 1);
		SkinSelectorInfo[2][ssSkinid] = cache_get_row_int(2, 1);
		SkinSelectorInfo[3][ssSkinid] = cache_get_row_int(3, 1);
		SkinSelectorInfo[4][ssSkinid] = cache_get_row_int(4, 1);
		SkinSelectorInfo[5][ssSkinid] = cache_get_row_int(5, 1);
		SkinSelectorInfo[6][ssSkinid] = cache_get_row_int(6, 1);
		SkinSelectorInfo[7][ssSkinid] = cache_get_row_int(7, 1);
		SkinSelectorInfo[8][ssSkinid] = cache_get_row_int(8, 1);
		SkinSelectorInfo[9][ssSkinid] = cache_get_row_int(9, 1);
		SkinSelectorInfo[10][ssSkinid] = cache_get_row_int(10, 1);
		SkinSelectorInfo[11][ssSkinid] = cache_get_row_int(11, 1);
	}
	counted = rows;
	printf("[Skin Selector] WARN ! Loaded %d skins from skin_selector", counted); //
	return 1;
}
And the command to display all data

Code:
COMMAND:changeskin(playerid, params [])
{
	for(new i; i < counted; i++) 
	{
		ShowModelSelectionMenuEx(playerid, SkinSelectorInfo[i][ssSkinid], counted, "Select Skin", CUSTOM_SKINS_MENU, 16.0, 0.0, -55.0);
	}
	return 1;
}
To store the data (the data it is just some numbers, the numbers are skin id)

Code:
ShowModelSelectionMenuEx(playerid, items_array[], item_amount, header_text[], extraid, Float:Xrot = 0.0, Float:Yrot = 0.0, Float:Zrot = 0.0, Float:mZoom = 1.0, dialogBGcolor = 0x4A5A6BBB, previewBGcolor = 0x88888899 , tdSelectionColor = 0xFFFF00AA)
So, the question is ! Can i store all data at once looping and then store it into items_array[] ?
Reply
#2

Okay, i solved ! Thx for the help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)