new Str[193];
format(Str,104,"INSERT INTO `carros`(`IDCasa`, `IDCarro`, `Modelo`, `X`, `Y`, `Z`, `R`, `Cor1`, `Cor2`, `Senha`) VALUES");
format(Str,193,"%s ('%i','0','%i','1745.7778','-3607.4458','88.3851','0.0','-1','-1','0')",Str,HouseID,ABuyableVehicles[i][CarModel]);
mysql_function_query(Connect, Str, false, "", "");
AHouseData[HouseID][Veiculos] += 1;
new vid;
vid = CreateVehicle(ABuyableVehicles[i][CarModel], 1745.7778,-3607.4458,88.3851,0.0, -1, -1, 600);
//Check if have vehicles on House Slot 1
if(APlayerData[playerid][House1] != 0)
{
if(AHouseData[APlayerData[playerid][House1]][Veiculos] > 0)
{
new Strl[52];
format(Strl,52,"SELECT * FROM `carros` WHERE `IDCasa`='%i'",APlayerData[playerid][House1]);
mysql_function_query(Connect, Strl, true, "CarregarCarro","i",playerid);
}
}
forward CarregarCarro(playerid);
public CarregarCarro(playerid)
{
new rows, fields,temp[11],tempx[20],TotalCarros, vid;
cache_get_data(rows, fields);
carros_rows[playerid] = rows; //by Konstaninos
while(TotalCarros < rows) //
{
vid = CreateVehicle(400, 1745.7778,-3607.4458,88.3851,0.0, -1, -1, 600);
cache_get_row(TotalCarros, 1, temp), AVehicleData[vid][BelongsToHouse] = strval(temp);
cache_get_row(TotalCarros, 3, temp), AVehicleData[vid][Model] = strval(temp);
cache_get_row(TotalCarros, 4, temp), AVehicleData[vid][SpawnX] = floatstr(temp);
cache_get_row(TotalCarros, 5, temp), AVehicleData[vid][SpawnY] = floatstr(temp);
cache_get_row(TotalCarros, 6, temp), AVehicleData[vid][SpawnZ] = floatstr(temp);
cache_get_row(TotalCarros, 7, temp), AVehicleData[vid][SpawnRot] = floatstr(temp);
cache_get_row(TotalCarros, 8, temp), AVehicleData[vid][Color1] = strval(temp);
cache_get_row(TotalCarros, 9, temp), AVehicleData[vid][Color2] = strval(temp);
cache_get_row(TotalCarros, 10, temp), AVehicleData[vid][PaintJob] = strval(temp);
cache_get_row(TotalCarros, 11, temp), AVehicleData[vid][Nitro] = strval(temp);
cache_get_row(TotalCarros, 10, temp), AVehicleData[vid][Fuel] = strval(temp);
cache_get_row(TotalCarros, 11, tempx), format(AVehicleData[vid][Senha],20,tempx);
DestroyVehicle(vid);
AVehicleData[vid][Owned] = true;
format(AVehicleData[vid][Owner], 24, AHouseData[AVehicleData[vid][BelongsToHouse]][Owner]);// Save the player-file (and his houses)
vid = CreateVehicle(AVehicleData[vid][Model], AVehicleData[vid][SpawnX],AVehicleData[vid][SpawnY],AVehicleData[vid][SpawnZ],AVehicleData[vid][SpawnRot], AVehicleData[vid][Color1], AVehicleData[vid][Color2], 600);
TotalCarros++;
}
printf("Casa 1: %i Carros carregados na casa ID %i",TotalCarros, AVehicleData[vid][BelongsToHouse]);
return 1;
}
|
Under OnPlayerDisconnect() use the DestroyVehicle() function to destroy model id AVehicleData[vid][Model]. |