#define MaxOV 3 enum vInfo { vOwner[24], vId, vModel, Float:vPosX, Float:vPosY, Float:vPosZ, Float:vPosA, vSlot, } new VehicleInfo [MAX_PLAYERS][vInfo]; new OwnedVehicle [MaxOV];
public OnPlayerExitVehicle(playerid, vehicleid) { SaveVehicleData(playerid); return 1; }
stock LoadVehicleData(playerid) { GetPlayerName(playerid, pName, MAX_PLAYER_NAME); mysql_format(mysql, query, sizeof(query), "SELECT * FROM `vehicles` WHERE `owner` = '%e'", pName); mysql_pquery(mysql, query, "Vehicle", "i", playerid); } forward Vehicle(playerid); public Vehicle(playerid) { for(new i=0; i < cache_get_row_count(); i++) { cache_get_field_content(i, "owner", VehicleInfo[playerid][vOwner], mysql, 24); VehicleInfo[playerid][vId] = cache_get_field_content_int(i, "vid"); VehicleInfo[playerid][vModel] = cache_get_field_content_int(i, "model"); VehicleInfo[playerid][vPosX] = cache_get_field_content_int(i, "posx"); VehicleInfo[playerid][vPosY] = cache_get_field_content_int(i, "posy"); VehicleInfo[playerid][vPosZ] = cache_get_field_content_int(i, "posz"); VehicleInfo[playerid][vPosA] = cache_get_field_content_int(i, "posa"); VehicleInfo[playerid][vSlot] = cache_get_field_content_int(i, "slot"); OwnedVehicle[i] = CreateVehicle(VehicleInfo[playerid][vModel],VehicleInfo[playerid][vPosX],VehicleInfo[playerid][vPosY],VehicleInfo[playerid][vPosZ],VehicleInfo[playerid][vPosA],-1,-1,-1); } return 1; } stock SaveVehicleData(playerid) { if(PlayerLogged[playerid] == 1) { new vid, Float:x, Float:y, Float:z, Float:a; vid = GetPlayerVehicleID(playerid); GetVehiclePos(vid,x,y,z); GetVehicleZAngle(vid,a); mysql_format(mysql, query, sizeof(query), "UPDATE `vehicles` SET `posx` = '%f', `posy` = '%f', `posz` = '%f', `posa` = '%f' WHERE `slot` = '%d'", x,y,z,a,VehicleInfo[playerid][vSlot]); mysql_pquery(mysql, query, "", ""); } return 1; }
Try restarting the server and trying to save vehicle #3 or #1 before #2 and see if it works.
|