SA-MP Forums Archive
How to destroy created vehicles? (+REP) - 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: How to destroy created vehicles? (+REP) (/showthread.php?tid=473966)



Deleted. - iFiras - 05.11.2013

Deleted.


Re: How to destroy created vehicles? (+REP) - Kaperstone - 05.11.2013

pawn Код:
DestroyVehicle(PlayersVehicle);



Deleted. - iFiras - 05.11.2013

Deleted.


Re: How to destroy created vehicles? (+REP) - Kaperstone - 05.11.2013

the one that the admin created.

EDIT: oh,you want to delete all vehicles,sorry for misunderstanding ...
You can add [MAX_PLAYERS] to where you create the PlayersVehicle array is
pawn Код:
new PlayersVehicle[MAX_PLAYERS];
and then when they spawn you store the id in the array where his playerid belongs to:
pawn Код:
PlayersVehicle[playerid] = CreateVehicle(vehicle, x, y, z, a+90, -1, -1, -1);
And now just create a command and in it add a loop which will go from 0 to MAX_PLAYERS or the number of slots your server has,in it add the DestroyVehicle function when the playerid in the PlayerVehicle array is i or whatever your array is set to in the loop.


Deleted. - iFiras - 05.11.2013

Deleted.


Re: How to destroy created vehicles? (+REP) - Kaperstone - 05.11.2013

Quote:
Originally Posted by xkirill
Посмотреть сообщение
the one that the admin created.

EDIT: oh,you want to delete all vehicles,sorry for misunderstanding ...
You can add [MAX_PLAYERS] to where you create the PlayersVehicle array is
pawn Код:
new PlayersVehicle[MAX_PLAYERS];
and then when they spawn you store the id in the array where his playerid belongs to:
pawn Код:
PlayersVehicle[playerid] = CreateVehicle(vehicle, x, y, z, a+90, -1, -1, -1);
And now just create a command and in it add a loop which will go from 0 to MAX_PLAYERS or the number of slots your server has,in it add the DestroyVehicle function when the playerid in the PlayerVehicle array is i or whatever your array is set to in the loop.
sorry I just misunderstood,edited my previous message.


Deleted. - iFiras - 05.11.2013

Deleted.


Deleted. - iFiras - 05.11.2013

Deleted.


Deleted. - iFiras - 05.11.2013

Deleted.


Re: How to destroy created vehicles? (+REP) - AlonzoTorres - 05.11.2013

@xkirill that would overwrite the first slot every time, since the playerid is not increased.

pawn Код:
new PlayersVehicle[MAX_PLAYERS];
new amount_of_vehicles = 0;
pawn Код:
if(strcmp(cmd, "/createveh", true, 10) == 0)
    {
        if(AdminLevel[playerid] < 5) return SCM(playerid,COLOR_WHITE,"{FF0000}[ERROR] {FFFFFF}You don't have an appropriate administration to use this command.");
        new String[200];
        new tmp[256];
        new Float:x, Float:y, Float:z;

        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, ""COL_ORANGE"[USAGE] {FFFFFF}/createveh [VEHICLE_NAME]");

        new vehicle = GetVehicleModelIDFromName(tmp);

        if(vehicle < 400 || vehicle > 611) return SendClientMessage(playerid, COLOR_WHITE, "{FF0000}[ERROR] {FFFFFF}Invalid vehicle name.");

        new Float:a;
        GetPlayerFacingAngle(playerid, a);
        GetPlayerPos(playerid, x, y, z);

        if(IsPlayerInAnyVehicle(playerid) == 1)
        {
            GetXYInFrontOfPlayer(playerid, x, y, 8);
        }
        else
        {
            GetXYInFrontOfPlayer(playerid, x, y, 5);
        }
        PlayersVehicle[amount_of_vehicles] = CreateVehicle(vehicle, x, y, z, a+90, -1, -1, -1);
        amount_of_vehicles++;
        LinkVehicleToInterior(PlayersVehicle, GetPlayerInterior(playerid));

        format(String, sizeof(String), ""COL_ADMIN"[ADMIN] {FFFFFF}You have spawned a \"%s\"", aVehicleNames[vehicle - 400]);
        SendClientMessage(playerid, COLOR_WHITE, String);
        return 1;
    }
pawn Код:
for(new x = 0; x < amount_of_vehicles; x++){
DestroyVehicle(PlayersVehicle[x]);
}