SA-MP Forums Archive
[HELP] Create Vehicle.OK Destroy Vehicles.Fail - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [HELP] Create Vehicle.OK Destroy Vehicles.Fail (/showthread.php?tid=531854)



[HELP] Create Vehicle.OK Destroy Vehicles.Fail - iryston - 15.08.2014

Hello!

I need a help, i have a system of houses with vehicles. When the player buy a vehicle he is created perfectly,
when he login, the vehicles load perfectly, but, i want when player logout the vehicles created to he Destroy.

Per player are, 5 house slots, and 5 cars per house. i put the just one case, house1 to work based it.

So...
When buy.. OK
pawn Код:
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);
When login.. OK
pawn Код:
//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);
            }
        }
pawn Код:
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;
}
But, how destroy the vehicles created for he? Without mix with the other vehicles players.

Sorry for my english, i'm from brazil and I'm not very good at it.

Very very thanks!


Re: [HELP] Create Vehicle.OK Destroy Vehicles.Fail - Faisal_khan - 15.08.2014

Under OnPlayerDisconnect() use the DestroyVehicle() function to destroy model id AVehicleData[vid][Model].


Re: [HELP] Create Vehicle.OK Destroy Vehicles.Fail - iryston - 15.08.2014

Quote:

Under OnPlayerDisconnect() use the DestroyVehicle() function to destroy model id AVehicleData[vid][Model].

Ok, but, if have others vehicle with same Model?


Re: [HELP] Create Vehicle.OK Destroy Vehicles.Fail - iryston - 15.08.2014

Or another way to make it?

Someone?


Re: [HELP] Create Vehicle.OK Destroy Vehicles.Fail - Norrin - 16.08.2014

Destroy using the vids.


Re: [HELP] Create Vehicle.OK Destroy Vehicles.Fail - Faisal_khan - 16.08.2014

AVehicleData[vid][Model] is unique for every vehicle regardless of model.