SA-MP Forums Archive
Delete cars created by /veh - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Delete cars created by /veh (/showthread.php?tid=289977)



Delete cars created by /veh - TheNavigator - 13.10.2011

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;
	}



Re: Delete cars created by /veh - MonkZemun - 13.10.2011

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!");
            }
        }
    } 



Re: Delete cars created by /veh - TheNavigator - 13.10.2011

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


Re: Delete cars created by /veh - AeroBlast - 13.10.2011

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


Re: Delete cars created by /veh - TheNavigator - 13.10.2011

Emmmmmmmm

How to make the Veh Vehicles have the same ID then?


Re: Delete cars created by /veh - TheNavigator - 16.10.2011

Someone please?


Re: Delete cars created by /veh - Vince - 17.10.2011

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);
}



Re: Delete cars created by /veh - TheNavigator - 20.10.2011

Quote:

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

Explain this please


Re: Delete cars created by /veh - =WoR=Varth - 20.10.2011

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);
}



Re: Delete cars created by /veh - Vince - 20.10.2011

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.