Delete cars created by /veh
#1

How can I do that?

That's my /veh code

Код:
	if(strcmp(cmd, "/veh", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
	        if (PlayerInfo[playerid][pAdmin] < 5)
			{
			    SendClientMessage(playerid, COLOR_GRAD1, "   You are not authorized to use that command!");
			    return 1;
			}
            ShowPlayerDialog(playerid, CARMENU, DIALOG_STYLE_LIST, "Vehicles","Heavy Trucks\nTrucks\n2Doors\n4Doors\nPlans\nBoats\nTrailers\nGovernment\nRC\nTransportation\nMotorCycles", "Spawn", "Cancel");
		}
		return 1;
	}
Reply
#2

PHP код:
    if(strcmp(cmd"/destroycar"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
           {
            if (
PlayerInfo[playerid][pAdmin] >= 5)
               {
                
DestroyVehicle(GetPlayerVehicleID(playerid));
                 return 
1;
               }
              else
              {
                
SendClientMessage(playeridCOLOR_WHITE"You are not Admin!");
            }
        }
    } 
Reply
#3

Thanks a lot It works perfectly

But I won't something else

I want it to not disappear if it's not made by /veh

Other thing, I want a command that deletes all vehicles made by /veh
Reply
#4

pawn Код:
new VehVehicle; //At the top of your script

VehVehile = CreateVehicle(bla,bla,...); //Where you create the vehicle

if(strcmp(cmd, "/destroycar", true) == 0)
    {
        if(IsPlayerConnected(playerid))
           {
            if (PlayerInfo[playerid][pAdmin] >= 5)
               {
                    if(GetPlayerVehicleID(playerid) == VehVehicle)
                    {
                        DestroyVehicle(GetPlayerVehicleID(playerid));
                        return 1;
                    }
               }
              else
              {
                SendClientMessage(playerid, COLOR_WHITE, "You are not Admin!");
            }
        }
    }
Didn't test it
Reply
#5

Emmmmmmmm

How to make the Veh Vehicles have the same ID then?
Reply
#6

Someone please?
Reply
#7

pawn Код:
// Top:
new
    gStaticCars;

// GameModeInit:
gStaticCars = AddStaticVehicle(...); // This line should declare the last vehicle in OnGameModeInit, and only the last!

// Your delete cmd (single vehicle):
new
    vehicleid = GetPlayerVehicleID(playerid);

if(vehicleid > gStaticCars)
{
    DestroyVehicle(vehicleid);
}

// Your delete cmd (all vehicles):
for(new i = gStaticCars+1; i < MAX_VEHICLES; i++)
{
    if(!GetVehicleModel(i)) continue;
    DestroyVehicle(i);
}
Reply
#8

Quote:

// GameModeInit:
gStaticCars = AddStaticVehicle(...); // This line should declare the last vehicle in OnGameModeInit, and only the last!

Explain this please
Reply
#9

pawn Код:
new bool:IsVehicleVeh[MAX_VEHICLES];

//Under your OnDialofResponse. Show us your code if you have no idea where to put this
IsVehicleVeh[vehicleidhere]++;

//Command to delete vehicle
for(new i=1;i<=MAX_VEHICLES;i++)
{
    if(IsVehicleVeh[i]) DestroyVehicle(i);
}
Reply
#10

Quote:
Originally Posted by TheNavigator
Посмотреть сообщение
Explain this please
It simply assigns the vehicleid of the last created vehicle to that variable, so you know what the static cars are and what the dynamic cars are. Let's say that you have 100 cars in your gamemode, then the gStaticCars variable would hold the value 100. Anything less or equal than that is considered a static car. Anything greater than that is a dynamically created car.

Quote:
Originally Posted by =WoR=Varth
Посмотреть сообщение
pawn Код:
blah blah
Just go away with your inefficient code.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)