28.10.2010, 20:37
Not tested
try.:
try.:
pawn Код:
#include <a_samp>
#include <a_mysql>
#include <sscanf2>
enum
Cars_Enum
{
Id,
Owner[24],
Model,
Float:X,
Float:Y,
Float:Z,
Float:Angle,
HP,
Fuel,
Color1,
Color2,
Lock,
tune0,
tune1,
tune2,
tune3,
tune4,
tune5,
tune6,
tune7,
tune8,
tune9,
tune10,
tune11,
tune12
};
new
vInfo[MAX_VEHICLES][Cars_Enum];
stock
LoadVehicles_Mysql()
{
if(!mysql_ping()) return 0;
new
FetchLine[512],
index = 0;
mysql_query("SELECT * FROM `vehicles`"); // select from all vehicles database
mysql_store_result(); // store result
if(mysql_num_rows() > 0)
{
while(mysql_fetch_row(FetchLine))
{
sscanf(FetchLine, "e<p<|>is[25]dffffdddddddddddddddddd>", vInfo[index]);
CreateVehicle( vInfo[index][Model],
vInfo[index][X],
vInfo[index][Y],
vInfo[index][Z],
vInfo[index][Angle],
vInfo[index][Color1],
vInfo[index][Color2],
60000
);
index++;
if(index == MAX_VEHICLES - 1) break;
}
} print("ERROR 0 row's sql database");
mysql_free_result(); // free result
return 1;
}
public
// OnFilterScriptInit()
// or
OnGameModeInit()
{
ConnectMySQL();
LoadVehicles_Mysql();
return 1;
}