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

Deleted.
Reply
#2

pawn Код:
DestroyVehicle(PlayersVehicle);
Reply
#3

Deleted.
Reply
#4

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.
Reply
#5

Deleted.
Reply
#6

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.
Reply
#7

Deleted.
Reply
#8

Deleted.
Reply
#9

Deleted.
Reply
#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


Forum Jump:


Users browsing this thread: 1 Guest(s)