Remove vehicle by ID
#1

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
Reply
#2

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;
    }
}
Reply
#3

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
Reply
#4

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.
Reply
#5

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;
}
Reply
#6

No, REMOVE the EXTRA brackets.
Reply
#7

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


Forum Jump:


Users browsing this thread: 1 Guest(s)