SA-MP Forums Archive
How To Delete Car - 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: How To Delete Car (/showthread.php?tid=623641)



How To Delete Car - TYDS - 03.12.2016

Hello Guys :
- How Can I Make A CMD to delete all car uninhabited vehicles in, on the server
- This Is My Spawn Car Command
Код:
CMD:layxe(playerid, params[]) 
{ 
    new Float:x,  
        Float:y, 
        Float:z, 
        Float:Angle, 
        vehicleid, 
        name[20 + EOS]; 

    if(!sscanf(params,"i", vehicleid)) 
     { 
        if(611 < vehicleid || vehicleid < 400)  
            return SendClientMessage(playerid, COLOR_RED, "ID Xe [400-611]"); 
    } 

    else if(!sscanf(params, "s[20]", name)) 
    { 
        if((vehicleid = GetVehicleIDFromName(name)) == INVALID_VEHICLE_ID) 
            return SendClientMessage(playerid, COLOR_RED, "Ten Khong Hop Le"); 
    } 
     
    else return SendClientMessage(playerid, COLOR_RED, "/layxe [id xe hoac ten xe]"); 
     
    if(IsPlayerInAnyVehicle(playerid)) RemovePlayerFromVehicle(playerid); 
    DestroyVehicle(vehicleid);
    GetPlayerPos(playerid, x, y, z); 
    GetPlayerFacingAngle(playerid, Angle); 
    vehicleid = CreateVehicle(vehicleid, x, y, z, Angle, -1, -1, -1); 
    PutPlayerInVehicle(playerid, vehicleid, 0);
    return 1; 
}



Re: How To Delete Car - TYDS - 03.12.2016

any one


Re: How To Delete Car - ReshiramZekrom - 03.12.2016

You can do this way:


PHP код:
IsVehicleEmpty(vehicleid)
{
    for(new 
0GetPlayerPoolSize(); <= ji++)
    {
        if(
IsPlayerInVehicle(ivehicleid)) return 0;
    }
    return 
1;
}
COMMAND:destroyveh(playerid,params[])
{
    for(new 
1GetVehiclePoolSize(); <= ji++) // vehicleids start at 1
    
{
        if(
IsVehicleEmpty(i)) DestroyVehicle(i);
    }
    return 
1;




Re: How To Delete Car - AnthonyDaBestt - 03.12.2016

PHP код:
COMMAND:destroycar(playerid,params[]) 
     {
          new 
vehicleid GetPlayerVehicleID(playerid);
          
DestroyVehicle(vehicleid);
          return 
1;
     }
 
     return 
0;