Mysql loop all data and store it - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Mysql loop all data and store it (
/showthread.php?tid=622944)
Mysql loop all data and store it -
CaRaM3LL - 28.11.2016
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[] ?
Re: Mysql loop all data and store it -
CaRaM3LL - 29.11.2016
Okay, i solved ! Thx for the help.