remove admin spawned cars -
Blademaster680 - 11.01.2014
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
Re: remove admin spawned cars -
Ace155 - 11.01.2014
Try using this
https://sampwiki.blast.hk/wiki/DestroyVehicle
Re: remove admin spawned cars -
Blademaster680 - 11.01.2014
Thanks +REP
Re: remove admin spawned cars -
Tayab - 11.01.2014
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;
}
Re: remove admin spawned cars -
Jefff - 11.01.2014
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;
}
Re: remove admin spawned cars -
Blademaster680 - 12.01.2014
Код:
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"
Re: remove admin spawned cars -
Jefff - 12.01.2014
Quote:
Originally Posted by Jefff
pawn Код:
new AdminCars[200],carid;
|
Add on top
Re: remove admin spawned cars -
Blademaster680 - 12.01.2014
Thanks Jefff it woks +REP