16.06.2014, 12:44
Quote:
I have no idea how MySQL works and i'm getting pretty frustrated. What do you mean by MySQL non changing key to the ingame volatile vehicleid. You can't create your own ingame vehicleid, those go by order or am I wrong?.
|
pawn Код:
enum vehicleinfo
{
SQLID,
VehicleID,
Owner[MAX_PLAYER_NAME]
}
new VehicleInfo[MAX_VEHICLES][vehicleinfo];
pawn Код:
public LoadVehicles()
{
...
new string[128];
format(string, sizeof(string), "...", ...);
mysql_query(string);
mysql_store_result();
...
mysql_fetch_field("SQLID", string);
VehicleInfo[i][SQLID] = strval(string);
VehicleInfo[i][VehicleID] = CreateVehicle(...);
mysql_free_result();
return 1;
}
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(!ispassenger)
{
for(new i = 0; i < MAX_VEHICLES; i++)
{
if(VehicleInfo[i][VehicleID] == vehicleid)
{
new string[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
strmid(VehicleInfo[i][Owner], name, 0, strlen(name), MAX_PLAYER_NAME);
format(string, sizeof(string), "UPDATE `Vehicles` SET `Owner` = '%s' WHERE `SQLID` = %d", VehicleInfo[i][Owner], VehicleInfo[vehicleid][SQLID]);
mysql_query(string);
}
}
}
return 1;
}
Best regards,
Jesse