07.05.2013, 08:51
hy
how to create a database checkpoint random?
how to create a database checkpoint random?
SELECT * FROM table ORDER BY RAND() LIMIT 1;
public NewCP() { new posx[10],posy[10],posz[10]; format(g_szQuery, sizeof g_szQuery, "SELECT * FROM cp ORDER BY RAND() LIMIT 1;"); mysql_function_query(1, g_szQuery, false, "OnQueryFinish", ""); cache_get_row(0, 3, posx); cache_get_row(0, 4, posy); cache_get_row(0, 5, posz); SendFormatMessage(-1,RED,"asd: %f, %f , %f",posx,posy,posz); return 1; }
stock NewCP()
{
format(g_szQuery, sizeof g_szQuery, "SELECT * FROM cp ORDER BY RAND() LIMIT 1;");
mysql_function_query(1, g_szQuery, true, "OnNewCP", "");
}
forward OnNewCP();
public OnNewCP()
{
new rows, fields, posx[10], posy[10], posz[10];
cache_get_data(rows, fields);
if(rows)
{
cache_get_row(0, 3, posx);
cache_get_row(0, 4, posy);
cache_get_row(0, 5, posz);
SendFormatMessage(-1,RED,"asd: %f, %f , %f",posx,posy,posz);
}
}
CREATE TABLE IF NOT EXISTS `cp` ( `id` int(11) NOT NULL AUTO_INCREMENT, `x` float NOT NULL, `y` float NOT NULL, `z` float NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2;
stock NewCP() { format(g_szQuery, sizeof g_szQuery, "SELECT * FROM cp ORDER BY RAND() LIMIT 1;"); mysql_function_query(1, g_szQuery, true, "OnNewCP", ""); } forward OnNewCP(); public OnNewCP() { new rows, fields, posx[10], posy[10], posz[10]; cache_get_data(rows, fields); if(rows) { cache_get_row(0, 1, posx); cache_get_row(0, 2, posy); cache_get_row(0, 3, posz); SendFormatMessage(-1,RED,"asd: %f, %f , %f",posx,posy,posz); } }
stock NewCP()
{
format(g_szQuery, sizeof g_szQuery, "SELECT * FROM cp ORDER BY RAND() LIMIT 1;");
mysql_function_query(1, g_szQuery, true, "OnNewCP", "");
}
forward OnNewCP();
public OnNewCP()
{
new
rows,
fields,
fetch[12],
Float:pos[3];
cache_get_data(rows, fields);
if(rows)
{
cache_get_row(0, 1, fetch); pos[0] = floatstr(fetch);
cache_get_row(0, 2, fetch); pos[0] = floatstr(fetch);
cache_get_row(0, 3, fetch); pos[0] = floatstr(fetch);
SendFormatMessage(-1, RED, "asd: %f, %f, %f", pos[0], pos[0], pos[2]);
}
return 1;
}