Jump to content
  • 0

Question

Posted

Problemă întâlnită (descriere): Vreau sa stiu cum pot face un import la masini  ?
Ero(area / rile) / warning-(ul / urile): Nici una
Liniile de cod / sursa / script-ul: N/A
Imagini / Video (optional): N/A
Aţi încercat să rezolvaţi singur?: Da, dar nu inteleg dece nu da import. 

"Mulţi programatori buni fac programare nu pentru că se aşteaptă să câştige bani sau să fie lăudaţi de public, ci pentru că e amuzant să programezi." - Linus Torvalds

10 answers to this question

Recommended Posts

  • Administrator
Posted

Asa este bine.

 

Pune la mysql_tquery si celalalt primul parametru sql in loc de 1.

Posted

Problema e ca nu da erori :|

Codurile:

#define MAX_CARS 100

enum cInfo
{
	cID,
	cOwner,
	cModel,
	cPrice,
	Float:cPosx,
	Float:cPosy,
	Float:cPosz,
	Float:cPosa,
	cPaint,
	c3DText,
 	cCol1,
 	cCol2,
 	cTPart,
 	cRTime,
 	cKM
}
new VehicleInfo[MAX_CARS][cInfo];

Forward:
forward OnLoadVehicle();
forward OnGetVehicle(vehid);
forward OnLoadCVehicle(vehid);

stock LoadVehicles()
{
	new query[255], id;
	mysql_format(1, query, sizeof(query), "SELECT `ID`, `Owner`, `Model`, `Price`, `PosX`, `PosY`, `PosZ`, `PosA`, `3DText`, `Color1`, `Color2`, `PaintJob`, `RespawnTime`, `KM`, `TPart` FROM `vehicles` WHERE `ID`='%d' LIMIT 1", id);
	mysql_tquery(1, query, "OnGetVehicle", "i", id);
}

OnGameModeInit:
LoadVehicles();

Public Functions:
public OnGetVehicle(vehid)
{
    cache_get_data(rows, fields, sql);
    if(rows)
    {
		LoadedInfo[vehid] = MAX_CARS;
		CreateVehicle(VehicleInfo[vehid][cModel], VehicleInfo[vehid][cPosx], VehicleInfo[vehid][cPosy], VehicleInfo[vehid][cPosz], VehicleInfo[vehid][cPosa], VehicleInfo[vehid][cCol1], VehicleInfo[vehid][cCol2], VehicleInfo[vehid][cRTime]);
  		printf("Import of databse %d vehicle", LoadedInfo[vehid]);
	}
	return 1;
}

public OnLoadCVehicle(vehid)
{
    VehicleInfo[vehid][cID]    = cache_get_field_content_int(0, "ID", sql);
    VehicleInfo[vehid][cOwner] = cache_get_field_content_int(0, "Owner", sql);
    VehicleInfo[vehid][cModel] = cache_get_field_content_int(0, "Model", sql);
    VehicleInfo[vehid][cPrice] = cache_get_field_content_int(0, "Price", sql);
    VehicleInfo[vehid][cPosx]  = cache_get_field_content_float(0, "PosX", sql);
    VehicleInfo[vehid][cPosy]  = cache_get_field_content_float(0, "PosY", sql);
    VehicleInfo[vehid][cPosz]  = cache_get_field_content_float(0, "PosZ", sql);
    VehicleInfo[vehid][cPosa]  = cache_get_field_content_float(0, "PosA", sql);
    VehicleInfo[vehid][c3DText]= cache_get_field_content_int(0, "3DText", sql);
    VehicleInfo[vehid][cCol1]  = cache_get_field_content_int(0, "Color1", sql);
    VehicleInfo[vehid][cCol2]  = cache_get_field_content_int(0, "Color2", sql);
    VehicleInfo[vehid][cPaint] = cache_get_field_content_int(0, "PaintJob", sql);
    VehicleInfo[vehid][cRTime] = cache_get_field_content_int(0, "RespawnTime", sql);
    VehicleInfo[vehid][cKM]	   = cache_get_field_content_int(0, "KM", sql);
    VehicleInfo[vehid][cTPart] = cache_get_field_content_int(0, "TPart", sql);
	return 1;
}

"Mulţi programatori buni fac programare nu pentru că se aşteaptă să câştige bani sau să fie lăudaţi de public, ci pentru că e amuzant să programezi." - Linus Torvalds

  • Administrator
Posted

mysql_format si mysql_tquery trebuie sa aiba primul parametru conexiunea catre baza de date, nu numarul 1.

Posted
mysql_tquery(sql, query, "OnGetVehicle", "i", id);

adica asa ?

"Mulţi programatori buni fac programare nu pentru că se aşteaptă să câştige bani sau să fie lăudaţi de public, ci pentru că e amuzant să programezi." - Linus Torvalds

Posted

la mine 

sql = mysql_connect(sql,host {etc...});

"Mulţi programatori buni fac programare nu pentru că se aşteaptă să câştige bani sau să fie lăudaţi de public, ci pentru că e amuzant să programezi." - Linus Torvalds

Posted (edited)

Ce am eu pt connect

static sql, Name[MAX_PLAYERS][32], IP[MAX_PLAYERS][16];
/* MySQL Host */
MySQLHost(); mysql_log(LOG_DEBUG | LOG_ERROR | LOG_WARNING,LOG_TYPE_HTML);
/* MySQL Host */

stock MySQLHost()
{
	sql = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_DB, MYSQL_PASS);
	if(mysql_errno(sql) != 0)
	{
	    printf("MySQL Database");
	    printf("---------------");
	    printf("  MySQL Database has not respond.n");
	}
	else
	{
	    printf("MySQL Database");
	    printf("---------------");
	    printf("  MySQL Database has been respond.n");
	}
	return 1;
}
Edited by sRk7

"Mulţi programatori buni fac programare nu pentru că se aşteaptă să câştige bani sau să fie lăudaţi de public, ci pentru că e amuzant să programezi." - Linus Torvalds

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.