How to delete a specific vehicle ID?
#3

You're using ZCMD oddly. You don't need if(isnull) sscanf already has a built in null checker.

pawn Code:
CMD:deleteveh(playerid, params[])
{
    new vehicle;
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, KLEUR_WIT, "You are not an Administrator.");
    if(sscanf(params,"i",vehicle)) return SendClientMessage(playerid, KLEUR_WIT, "{B4B5B7}USAGE: /deleteveh [vehicleid]");
    if(vehicle == INVALID_VEHICLE_ID) return SendClientMessage(playerid,KLEUR_WIT,"Vehicle not found.");
    else
    {
        DestroyVehicle(vehicle);
        new string[128];
        format(string, sizeof(string), "You succesfully deleted vehicle ID: %i", vehicle);
        SendClientMessage(playerid,KLEUR_WIT,string);
        return 1;
    }
    return 1;
}
================================================== ===================
pawn Code:
new vehicle;
Defines a variable that will hold the vehicleid.

pawn Code:
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, KLEUR_WIT, "You are not an Administrator.");
Checks if the player is Admin. The ! is if IsPlayerAdmin returns false. So basically. If a player is not admin then send them the message.

pawn Code:
if(sscanf(params,"i",vehicle)) return SendClientMessage(playerid, KLEUR_WIT, "{B4B5B7}USAGE: /deleteveh [vehicleid]");
Checks if they left the command empty.

pawn Code:
if(vehicle == INVALID_VEHICLE_ID) return SendClientMessage(playerid,KLEUR_WIT,"Vehicle not found.");
Checks if the vehicleid they typed is not in the script.

pawn Code:
else
    {
        DestroyVehicle(vehicle);
    }
    return 1;
}
If everything else passes, then DestroyVehicle(vehicle) will the destroy the vehicle with variable they typed inside.

pawn Code:
new string[128];
        format(string, sizeof(string), "You succesfully deleted vehicle ID: %i", vehicle);
        SendClientMessage(playerid,KLEUR_WIT,string);
Formats the string and Sends the client the string as a message.
Goodluck.
Reply


Messages In This Thread
How to delete a specific vehicle ID? - by jessejanssen - 17.02.2012, 23:41
Re : How to delete a specific vehicle ID? - by ricardo178 - 18.02.2012, 00:12
Re: How to delete a specific vehicle ID? - by ReneG - 18.02.2012, 00:17
Re: How to delete a specific vehicle ID? - by Fj0rtizFredde - 18.02.2012, 00:21
Re: Re : How to delete a specific vehicle ID? - by ReneG - 18.02.2012, 00:21
Re : Re: Re : How to delete a specific vehicle ID? - by ricardo178 - 18.02.2012, 00:22
Re: How to delete a specific vehicle ID? - by Jefff - 18.02.2012, 00:32
Re: How to delete a specific vehicle ID? - by jessejanssen - 18.02.2012, 01:09

Forum Jump:


Users browsing this thread: 2 Guest(s)