How to destroy created vehicles? (+REP)
#10

@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]);
}
Reply


Messages In This Thread
Deleted. - by iFiras - 05.11.2013, 15:12
Re: How to destroy created vehicles? (+REP) - by Kaperstone - 05.11.2013, 15:14
Deleted. - by iFiras - 05.11.2013, 15:20
Re: How to destroy created vehicles? (+REP) - by Kaperstone - 05.11.2013, 15:27
Deleted. - by iFiras - 05.11.2013, 15:32
Re: How to destroy created vehicles? (+REP) - by Kaperstone - 05.11.2013, 15:33
Deleted. - by iFiras - 05.11.2013, 15:42
Deleted. - by iFiras - 05.11.2013, 16:05
Deleted. - by iFiras - 05.11.2013, 16:51
Re: How to destroy created vehicles? (+REP) - by AlonzoTorres - 05.11.2013, 16:57

Forum Jump:


Users browsing this thread: 1 Guest(s)