SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 28/11/2016, 11:20 AM   #1
CaRaM3LL
Little Clucker
 
Join Date: Mar 2012
Posts: 39
Reputation: 6
Default Mysql loop all data and store it

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[] ?

Last edited by CaRaM3LL; 28/11/2016 at 11:23 AM. Reason: update, add photo for table
CaRaM3LL is offline   Reply With Quote
Old 29/11/2016, 02:00 PM   #2
CaRaM3LL
Little Clucker
 
Join Date: Mar 2012
Posts: 39
Reputation: 6
Default Re: Mysql loop all data and store it

Okay, i solved ! Thx for the help.
CaRaM3LL is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What would be the best way to store data [mysql] PizzaPuntjes Scripting Help 8 02/08/2015 12:32 PM
MySQL store data bruxo00 Scripting Help 1 07/01/2015 08:32 PM
Store a data value thimo Scripting Help 4 10/05/2012 11:14 AM
save data using MySql in a loop +rep PawnoQ Scripting Help 1 30/01/2012 04:40 PM


All times are GMT. The time now is 04:46 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.