03.01.2013, 19:12
pawn Code:
loadVehicle(playerid) {
format(query, sizeof query, "SELECT `id` FROM `vehicles` WHERE `owner` = '%s' AND `plate` = '15640'", pname);
mysql_function_query(yourConnectionHandleHere, query, true, "OnVehicleLoad", "d", playerid);
}
forward OnVehicleLoad(playerid);
public OnVehicleLoad(playerid)
{
new rows, fields;
cache_get_data(rows, fields);
if(!rows) return 0;
new content[11];
cache_get_row(0, 0, content, yourConnectionHandleHere);
UserInfo[playerid][uVehKey1] = strval(content);
SaveStats(playerid);
new rand = random(sizeof(VehicleSpawns)), query[500];
format(query, sizeof(query), "UPDATE `vehicles` SET `park_x` = '%f', `park_y` = '%f', `park_z` = '%f' WHERE `id` = '%d'", VehicleSpawns[rand][0], VehicleSpawns[rand][1], VehicleSpawns[rand][2], UserInfo[playerid][uVehKey1]);
mysql_function_query(yourConnectionHandleHere, query, false, "", "");
format(query, sizeof(query), "UPDATE `vehicles` SET `plate` = '*' WHERE `id` = '%d'", UserInfo[playerid][uVehKey1]);
mysql_function_query(yourConnectionHandleHere, query, false, "", "");
return 1;
}