Array System To A Mysql System -
Robert_Crawford - 23.05.2012
pawn Код:
new Float:RandomFireSpawn[][][] =
{
{ {1182.5364,-1327.6281,13.5824}, {1862.2970,-1599.9858,13.7848}, {1860.0771,-1600.0739,13.5513}, {1859.2474,-1597.2838,13.5591} }, // fire 1
{ {1973.7946,-1985.4115,14.2503}, {1977.5442,-1984.6274,13.5469}, {1979.5101,-1986.4177,13.5469}, {1982.7335,-1988.6499,13.5469} }, // fire 2
{ {2266.7959,-2254.1270,13.5469}, {2272.7290,-2254.7043,13.5391}, {2269.3757,-2250.5195,13.6066}, {2266.6089,-2261.3516,14.7647} } //fire 3
};
The Spawn
pawn Код:
new rndfire = random(sizeof(RandomFireSpawn));
{
AddFire(RandomFireSpawn[rndfire][0][0], RandomFireSpawn[rndfire][0][1], RandomFireSpawn[rndfire][0][2]);
AddFire(RandomFireSpawn[rndfire][1][0], RandomFireSpawn[rndfire][1][1], RandomFireSpawn[rndfire][1][2]);
AddFire(RandomFireSpawn[rndfire][2][0], RandomFireSpawn[rndfire][2][1], RandomFireSpawn[rndfire][2][2]);
AddFire(RandomFireSpawn[rndfire][3][0], RandomFireSpawn[rndfire][3][1], RandomFireSpawn[rndfire][3][2]);
printf("Fire Spawned");
SetTimer("RandomFireKiller",900000,true);
}
I know nothing of sql and this seems something simple so if someone could explain what i would use and why i would much appreciate and +rep.
Re: Array System To A Mysql System -
Robert_Crawford - 24.05.2012
Bump - Bump
Re: Array System To A Mysql System -
Mauzen - 24.05.2012
Right, all in all it isnt that hard.
First, create a mysql table containing 9 float fields for your coordinates. This can easily be done with phpmyadmin, or take a look at CREATE if you dont got access to that.
Then insert your data with phpmyadmin or INSERT.
The script part also isnt hard. Heres a brief example:
pawn Код:
// Conenct to the MySQL server
mysql_connect(host, user, databasename, password);
// Now select a random row from your coordinates table
mysql_query("select * from TABLENAME order by rand() limit 1;");
// This basically results all coordinates in a random order and picks the first one
// Moves to the first result row for processing
mysql_retrieve_row();
// Now you can read all your coordinates from the row
new result[16];
mysql_fetch_field_row(result, "fieldname1"); // where fieldname1 is the name you gave one of the coordinate fields
// now you can parse result to get your coordinate and continue with the next one
mysql_fetch_field_row(result, "fieldname2");
// ...
// Alternatively to mysql_fetch_field_row you can use this
new result[128];
mysql_fetch_row_format(result, " ");
// It will return a single string containing all coordinates, separated by a space
// so you can use it for parsing with e.g. sscanf
Re: Array System To A Mysql System -
Robert_Crawford - 24.05.2012
Now could i do it to where You Have X,Y,Z,FIREGROUPID so that way each group that is spawned has varying amounts spawned?
Re: Array System To A Mysql System -
Robert_Crawford - 28.05.2012
Bumpty