[HELP] Delete the cars made by the command /v
#1

How to delete the cars made by the command /v

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
		// DCMD DEFINE's
		dcmd(help,4,cmdtext);
		dcmd(s,1,cmdtext); // 1 = amount of character
		dcmd(skin,4,cmdtext);
  	new cmd[256], tmp[256], idx;
  	cmd = strtok(cmdtext, idx);
  	
    if(strcmp(cmd, "/v", true, 3) == 0)
	  {
		new String[200];
		new Float:x, Float:y, Float:z,Float:a;
		GetPlayerFacingAngle(playerid, a);
		GetPlayerPos(playerid, x, y, z);

		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_RED, "USAGE:/v <Vehicle NAME|ID>");

		new vehicle = GetVehicleModelIDFromName(tmp);

		if(vehicle < 400 || vehicle > 611) return SendClientMessage(playerid,COLOR_RED, "ERROR: Invalid vehicle NAME/ID");
		if(IsPlayerInAnyVehicle(playerid))
		{
			SendClientMessage(playerid, COLOR_RED, "[VEHICLE]: You are already in a vehicle.");
			return 1;
		}
		else
		{
			GetXYInFrontOfPlayer(playerid, x, y, 1);
		}

		new Vid = AddStaticVehicleEx(vehicle,x, y,z, a, -1, -1, -1);
		PutPlayerInVehicle(playerid,Vid,0);
		LinkVehicleToInterior(Vid, GetPlayerInterior(playerid));
		SetVehicleVirtualWorld(Vid,GetPlayerVirtualWorld(playerid));

		format(String, sizeof(String), "%s has spawned a %s (ID:%i - MODEL ID: %i)", GetPName(playerid),aVehicleNames[vehicle - 400],Vid, vehicle);
		SendClientMessageToAll(COLOR_RED, String);
		return 1;
  	}
   	return 0;
}

Код:
if(strcmp(cmdtext, "/dv", true) == 0)
{
  new Vid;
  Vid = GetPlayerVehicleID(playerid);
  DestroyVehicle(Vid);
  return 1;
}
Reply
#2

Make a variable to store the vehicle there and then delete it .

pawn Код:
new MyVehicle[MAX_PLAYERS];
pawn Код:
MyVehicle[playerid] = CreateVehicle(411, 0.0, 0.0, 0.0, 0.0, -1, -1, -1);
pawn Код:
DestroyVehicle(MyVehicle[playerid]);
Reply
#3

SAWC™ if I create more than one they do not destroy vehicles only destroys the last one did.
How to destroy all vehicles made by the command /v.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)