[HELP] Creating optional command parameters
#3

@bondowocopz: Really? Don't ever post untested commands/codes. It's not optional in your code.
The proper code would be:
pawn Код:
CMD:car(playerid,params[])
{
    new string[128],cID,cID2,vID;
    new Float:x,Float:y,Float:z;
    if(PInfo[playerid][Level] < 1)
    return SendClientMessage(playerid,STEALTH_BLUE,"You need to be level 2 to use this command.");
    if(sscanf(params,"dI(0)I(0)",vID,cID,cID2))
    return SendClientMessage(playerid,COLOR_INDIANRED,"USAGE /car [NAME] Optional: [COLOR1] [COLOR2]");
    if(vCar[playerid] != -1)
        {
            DestroyVehicle(vCar[playerid]);
        }
    CMDMessageToAdmins(playerid,"CAR");
    GetPlayerPos(playerid,x,y,z);
    vCar[playerid] = CreateVehicle(vID,x+2,y,z,0,cID,cID2,0);
    PutPlayerInVehicle(playerid,vCar[playerid], 0);
    LinkVehicleToInterior(vCar[playerid], GetPlayerInterior(playerid));
    format(string,sizeof(string),"You have spawned vehicle %d with color %d and %d.",vID,cID,cID2);
    SendClientMessage(playerid,COLOR_GREENYELLOW,string);
        return 1;
}
INFO:
pawn Код:
if(sscanf(params,"dI(0)I(0)",vID,cID,cID2))
I(0) - If nothing has been entered by the user, it chooses 0 as the color. You can change that (0) to any vehicle color value.
Reply


Messages In This Thread
[HELP] Creating optional command parameters - by Nabster - 08.03.2015, 07:41
Re: [HELP] Creating optional command parameters - by X337 - 08.03.2015, 07:51
Re: [HELP] Creating optional command parameters - by biker122 - 08.03.2015, 08:20
Re: [HELP] Creating optional command parameters - by Nabster - 08.03.2015, 09:00

Forum Jump:


Users browsing this thread: 3 Guest(s)