02.01.2014, 09:55
Dear Members,
I recently updated to BlueG's MYSQL Plugin R34. I somehow managed to make a player registration system successfully with the use of all the new cache functions but am still not sure as i wanted to load settings data of the server from 'settings' table. It will have only 1 row of data to load from. I coded it all and nothing loaded actually. I think i am doing something wrong. I thought maybe i should take some help. Therefore am posting the codes here.
Structure of the table.
This code creates the table successfully if it doesn't exists.
Loading data from settings table.
Now when this code executes, it does not write any value in the printf other then zero's and nulls.
I am sure that there is something am doing wrong. I am trying to load the data WHERE id=0. Hope someone call tell me what is wrong which am doing.
Regards,
Ballu Miaa
I recently updated to BlueG's MYSQL Plugin R34. I somehow managed to make a player registration system successfully with the use of all the new cache functions but am still not sure as i wanted to load settings data of the server from 'settings' table. It will have only 1 row of data to load from. I coded it all and nothing loaded actually. I think i am doing something wrong. I thought maybe i should take some help. Therefore am posting the codes here.
Structure of the table.
pawn Код:
mysql_function_query(g_Database, "CREATE TABLE IF NOT EXISTS `settings` ( \
`id` int(5) NOT NULL, \
`servername` varchar(24) NOT NULL, \
`defaultX` float NOT NULL, \
`defaultY` float NOT NULL, \
`defaultZ` float NOT NULL, \
`defaultA` float NOT NULL, \
`interior` int(5) NOT NULL, \
`vw` int(20) NOT NULL, \
`skin` int(5) NOT NULL, \
`cash` int(5) NOT NULL, \
`bank` int(5) NOT NULL, \
PRIMARY KEY (`id`) \
)", false, "EmptyQuery", "");
Loading data from settings table.
pawn Код:
forward LoadSettings();
public LoadSettings()
{
new query[158];
format(query, sizeof(query), "SELECT * FROM `settings` WHERE `id` = 0");
mysql_function_query(g_Database, query, true, "SendQuery", "");
cache_get_row(0, 1, g_ServerInfo[sServername], g_Database, 170);
g_ServerInfo[sPos][0] = cache_get_row_float(0, 2, g_Database);
g_ServerInfo[sPos][1] = cache_get_row_float(0, 3, g_Database);
g_ServerInfo[sPos][2] = cache_get_row_float(0, 4, g_Database);
g_ServerInfo[sPos][3] = cache_get_row_float(0, 5, g_Database);
g_ServerInfo[sInterior] = cache_get_row_int(0, 6, g_Database);
g_ServerInfo[sVirtualWorld] = cache_get_row_int(0, 7, g_Database);
g_ServerInfo[sSkin] = cache_get_row_int(0, 8, g_Database);
g_ServerInfo[sCash] = cache_get_row_int(0, 9, g_Database);
g_ServerInfo[sBank] = cache_get_row_int(0, 10, g_Database);
printf("<!> %s,%f,%f,%f,%f,%d,%d,%d,%d,%d"
,g_ServerInfo[sServername]
,g_ServerInfo[sPos][0]
,g_ServerInfo[sPos][1]
,g_ServerInfo[sPos][2]
,g_ServerInfo[sPos][3]
,g_ServerInfo[sInterior]
,g_ServerInfo[sVirtualWorld]
,g_ServerInfo[sSkin]
,g_ServerInfo[sCash]
,g_ServerInfo[sBank]);
return 1;
}
I am sure that there is something am doing wrong. I am trying to load the data WHERE id=0. Hope someone call tell me what is wrong which am doing.
Regards,
Ballu Miaa