SA-MP Forums Archive
Remove vehicle by ID - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Remove vehicle by ID (/showthread.php?tid=235852)



Remove vehicle by ID - Unknown123 - 06.03.2011

When you do /dl you get something like this in the vehicles:
Код:
ID: x, type: x, Health: 1000.0...
How to remove (DestroyVehicle) by typnig the ID (Without sitting in the vehicle)

Like:

/rvehicle 15 - Removes the vehicle ID 15 till you restart the server


Re: Remove vehicle by ID - Serbish - 06.03.2011

pawn Код:
if(strcmp(cmd, "/rvehicle", true) == 0)
{
    new string[128], vehicleid;
    tmp = strtok(cmdtext, idx);
    vehicleid = strval(tmp);
    if(strlen(tmp))
    {
        if(IsNumeric(tmp))
        {
            DestroyVehicle(vehicleid);
            return 1;
        }
        else
        {
            SendClientMessage(playerid, COLOR_WARNING, "Invalid vehicle ID.");
            return 1;
        }
    }
    else
    {      
        SendClientMessage(playerid, COLOR_WARNING, "Type: /rvehicle [vehicleid]");
        return 1;
    }
}



Re: Remove vehicle by ID - Unknown123 - 06.03.2011

I made a similar Command in dcmd:

pawn Код:
dcmd_rvehicle(playerid, params[])
{
    if(IsPlayerAdmin(playerid)|| PlayerData[playerid][AdminLevel] > 3)
    {
        new string[128], vehicleid;

        if(sscanf(params, "u", vehicleid)) return SendClientMessage(playerid, COLOR_USAGE, "USAGE: /rvehicle (id)");
        else
        {
            format(string, sizeof(string), "You removed vehicle nr.%d", vehicleid);
            SendClientMessage(playerid, COLOR_INFO, string);
           
            DestroyVehicle(vehicleid);
            return 1;
        }
    }
    return 0;
}
But ths is not working


Re: Remove vehicle by ID - Calgon - 06.03.2011

You need to use U for player IDs and NOT vehicle IDs. Replace 'u' with 'd' and remove the 'else {' and '}' as the sscanf client message return will dismiss the command if the parameters aren't right.


Re: Remove vehicle by ID - Unknown123 - 06.03.2011

Quote:
Originally Posted by Calg00ne
Посмотреть сообщение
You need to use U for player IDs and NOT vehicle IDs. Replace 'u' with 'd' and remove the 'else {' and '}' as the sscanf client message return will dismiss the command if the parameters aren't right.
Like this:

pawn Код:
dcmd_rvehicle(playerid, params[])
{
    if(IsPlayerAdmin(playerid)|| PlayerData[playerid][AdminLevel] > 3)
    {
        new string[128], vehicleid;
        if(sscanf(params, "d", vehicleid)) return SendClientMessage(playerid, COLOR_USAGE, "USAGE: /rvehicle (id)");
        {
            format(string, sizeof(string), "You removed vehicle nr.%d", vehicleid);
            SendClientMessage(playerid, COLOR_INFO, string);
           
            DestroyVehicle(vehicleid);
            return 1;
        }
    }
    return 0;
}



Re: Remove vehicle by ID - Calgon - 06.03.2011

No, REMOVE the EXTRA brackets.


Re: Remove vehicle by ID - Skylar Paul - 06.03.2011

pawn Код:
dcmd_rvehicle(playerid, params[])
{
    if(IsPlayerAdmin(playerid) || PlayerData[playerid][AdminLevel] > 3)
    {
        new string[128], vehicleid;
        if(!sscanf(params, "d", vehicleid))
        {
            format(string, sizeof(string), "You have removed Vehicle ID %d.", vehicleid);
            SendClientMessage(playerid, COLOR_INFO, string);
            DestroyVehicle(vehicleid);
        }
        else return SendClientMessage(playerid, COLOR_INFO, "USAGE: /rvehicle [Vehicle ID]");
    }
    else return SendClientMessage(playerid, COLOR_RED, "ERROR: You are not authorized!");
    return 1;
}