Sure, here is preceding code:
Код:
new MySQL;
public OnGameModeInit()
{
mysql_log(LOG_ALL);
MySQL = mysql_connect(HOST, USER, DB, PASSWORD);
if(mysql_errno(MySQL) != 0)
print("Nie polaczono z baza danych");
else
{
print("Polaczono z baza danych!");
}
LoadVeh();
return 1;
}
and LoadVeh() - its beta, dont get a scare
Код:
stock LoadVeh()
{
new query[128];
mysql_format(MySQL, query, sizeof(query), "SELECT * FROM `vehicle`");
mysql_tquery(MySQL, query, "LoadVeh2", "");
return 1;
Код:
forward LoadVeh2();
public LoadVeh2()
{
new rows, fields, i=0;
cache_get_data(rows, fields, MySQL);
while(i < rows)
{
vehicle[i][vUID] = cache_get_field_content_int(0, "UID");
vehicle[i][Owner] = cache_get_field_content_int(0, "Owner");
vehicle[i][ID] = cache_get_field_content_int(0, "ID");
vehicle[i][Color1] = cache_get_field_content_int(0, "Color1");
vehicle[i][Color2] = cache_get_field_content_int(0, "Color2");
vehicle[i][vHP] = cache_get_field_content_float(0, "HP");
vehicle[i][vX] = cache_get_field_content_float(0, "vX");
vehicle[i][vY] = cache_get_field_content_float(0, "vY");
vehicle[i][vZ] = cache_get_field_content_float(0, "vZ");
vehicle[i][vA] = cache_get_field_content_float(0, "vA");
CreateVehicle(vehicle[i][ID], vehicle[i][vX], vehicle[i][vY], vehicle[i][vZ], vehicle[i][vA], vehicle[i][Color1], vehicle[i][Color2], -1);
i++;
}
printf("vehicles : %d", rows);
return 1;
}
@edit If i have only connect function in code its too repeats two times.
MYSQL LOG FROM 1 CONNECTION!! I REPEAT, FROM 1!
Код:
[12:29:01] [DEBUG] mysql_connect - host: "127.0.0.1", user: "root", database: "game", password: "****", port: 3306, autoreconnect: false, pool_size: 2
[12:29:01] [DEBUG] CMySQLHandle::Create - creating new connection..
[12:29:01] [DEBUG] CMySQLHandle::CMySQLHandle - constructor called
[12:29:01] [DEBUG] CMySQLHandle::Create - connection created (id: 1)
[12:29:01] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[12:29:01] [DEBUG] CMySQLConnection::Connect - connection was successful
[12:29:01] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been disabled
[12:29:01] [DEBUG] mysql_errno - connection: 1
[12:29:01] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[12:29:01] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[12:29:01] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[12:29:01] [DEBUG] CMySQLConnection::Connect - connection was successful
[12:29:01] [DEBUG] CMySQLConnection::Connect - connection was successful
[12:29:01] [DEBUG] CMySQLConnection::Connect - connection was successful
[12:29:01] [DEBUG] mysql_connect - host: "127.0.0.1", user: "root", database: "game", password: "****", port: 3306, autoreconnect: false, pool_size: 2
[12:29:01] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been disabled
[12:29:01] [DEBUG] CMySQLHandle::Create - creating new connection..
[12:29:01] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been disabled
[12:29:01] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been disabled
[12:29:01] [WARNING] CMySQLHandle::Create - connection already exists
[12:29:01] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[12:29:01] [DEBUG] CMySQLConnection::Connect - connection was successful
[12:29:01] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been disabled
[12:29:01] [DEBUG] mysql_errno - connection: 1
[12:29:01] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[12:29:01] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[12:29:01] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[12:29:01] [DEBUG] CMySQLConnection::Connect - connection was successful
[12:29:01] [DEBUG] CMySQLConnection::Connect - connection was successful
[12:29:01] [DEBUG] CMySQLConnection::Connect - connection was successful
[12:29:01] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been disabled
[12:29:01] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been disabled
[12:29:01] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been disabled