remove admin spawned cars
#1

Hi.

I was wandering if it was possible to make a /vehdestroy that will destroy all the admin spawned cars?
Here is the command to spawn them:
Код:
CMD:veh(playerid, params[])
{
	if(IsPlayerConnected(playerid))
	{
		if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, COLOR_GRAD1, "You are not authorized to use this command-");
		new car, col1, col2, string[126];
		if(sscanf(params, "iii", car, col1, col2)) return SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /veh [carid] [color1] [color2]");
		if(car < 400 || car > 611) return SendClientMessage(playerid, COLOR_GREY, "Vehicle number can't be below 400 or above 611!");
		if(col1 < 0 || col1 > 256) return SendClientMessage(playerid, COLOR_GREY, "Color number can't be below 0 or above 256!");
		new Float:X,Float:Y,Float:Z;
		GetPlayerPos(playerid, X,Y,Z);
		new carid = AddStaticVehicleEx(car, X+2,Y+2,Z+1, 0.0, col1, col2, 60000);
		format(string, sizeof(string), "Vehicle %d spawned.", carid);
		SendClientMessage(playerid, COLOR_GREY, string);
	}
	return 1;
}
Is it possible to make a command to destroy the vehicles that command creates? and if so How?

Thanks
Reply
#2

Try using this https://sampwiki.blast.hk/wiki/DestroyVehicle
Reply
#3

Thanks +REP
Reply
#4

I'd suggest making a variable which stores the value of the cars created by admins, and when destroying, just loop through the variable and destroy everything.

Example below.

pawn Код:
new pCarSpawned[MAX_PLAYERS];
CMD:car(playerid,params[])
{
    new id,c1,c2;
    if(sscanf(params,"ddd",id,c1,c2)) return SendClientMessage(playerid,0xFFFFFFFF,"/car [veh_id] [c1] [c2]");
    if(!(399 < id < 612)) return SendClientMessage(playerid,0xCCCCCCCC,"Invalid Vehicle ID");
    switch(pCarSpawned[playerid])
    {
        case 0:
        {
            pCarSpawned[playerid] = CreateVehicle(id,Pos[0],Pos[1],Pos[2],Pos[3],c1,c2,60);
            PutPlayerInVehicle(playerid,pCarSpawned[playerid],0);
           
        }
        case 1:
        {
            DestroyVehicle(pCarSpawned[playerid]);
            pCarSpawned[playerid] = CreateVehicle(id,Pos[0],Pos[1],Pos[2],Pos[3],c1,c2,60);
            PutPlayerInVehicle(playerid,pCarSpawned[playerid],0);
        }
    }
    return 1;
}
CMD:destroyallcars(playerid,params[])
{
    for(new i = 0; i < MAX_PLAYES; i++) DestroyVehicle(pSpawned[i]);
    return 1;
}
Reply
#5

pawn Код:
new AdminCars[200],carid;

CMD:veh(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, COLOR_GRAD1, "You are not authorized to use this command-");
    if(carid > sizeof(AdminCars)-1) return SendClientMessage(playerid, COLOR_GRAD1, "You must use /vehdestroy because is now maximum Admin cars");
    new car, col1, col2, string[126];
    if(sscanf(params, "iii", car, col1, col2)) return SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /veh [carid] [color1] [color2]");
    if(car < 400 || car > 611) return SendClientMessage(playerid, COLOR_GREY, "Vehicle number can't be below 400 or above 611!");
    if(col1 < 0 || col1 > 256) return SendClientMessage(playerid, COLOR_GREY, "Color number can't be below 0 or above 256!");
    new Float:X,Float:Y,Float:Z;
    GetPlayerPos(playerid, X,Y,Z);
    AdminCars[carid] = AddStaticVehicleEx(car, X+2,Y+2,Z+1, 0.0, col1, col2, 60000);
    format(string, sizeof(string), "Vehicle %d spawned.", AdminCars[carid]);
    SendClientMessage(playerid, COLOR_GREY, string);
    ++carid;
    return 1;
}

CMD:vehdestroy(playerid,params[])
{
    if(!carid) return SendClientMessage(playerid, COLOR_GRAD1, "There is 0 Admin Cars created");
    for(new i = 0; i < sizeof(AdminCars); i++)
        if(AdminCars[i] > 0)
        {
            DestroyVehicle(AdminCars[i]);
            AdminCars[i] = 0;
        }

    carid = 0;
    return 1;
}
Reply
#6

Код:
CMD:veh(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, COLOR_GRAD1, "You are not authorized to use this command-");
    if(carid > sizeof(AdminCars)-1) return SendClientMessage(playerid, COLOR_GRAD1, "You must use /vehdestroy because is now maximum Admin cars");
    new car, col1, col2, string[126];
    if(sscanf(params, "iii", car, col1, col2)) return SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /veh [carid] [color1] [color2]");
    if(car < 400 || car > 611) return SendClientMessage(playerid, COLOR_GREY, "Vehicle number can't be below 400 or above 611!");
    if(col1 < 0 || col1 > 256) return SendClientMessage(playerid, COLOR_GREY, "Color number can't be below 0 or above 256!");
    new Float:X,Float:Y,Float:Z;
    GetPlayerPos(playerid, X,Y,Z);
    AdminCars[carid] = AddStaticVehicleEx(car, X+2,Y+2,Z+1, 0.0, col1, col2, 60000);
    format(string, sizeof(string), "Vehicle %d spawned.", AdminCars[carid]);
    SendClientMessage(playerid, COLOR_GREY, string);
    ++carid;
    return 1;
}

CMD:vehdestroy(playerid,params[])
{
    if(!carid) return SendClientMessage(playerid, COLOR_GRAD1, "There is 0 Admin Cars created");
    for(new i = 0; i < sizeof(AdminCars); i++)
        if(AdminCars[i] > 0)
        {
            DestroyVehicle(AdminCars[i]);
            AdminCars[i] = 0;
        }

    carid = 0;
    return 1;
}
Error: Undefined symbol "carid"
Reply
#7

Quote:
Originally Posted by Jefff
Посмотреть сообщение
pawn Код:
new AdminCars[200],carid;
Add on top
Reply
#8

Thanks Jefff it woks +REP
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)