Y-Less / sscanf

SA:MP sscanf plugin originally made by @Y-Less
Other
122 stars 51 forks source link

Variants problem #61

Closed rizlone closed 10 months ago

rizlone commented 10 months ago

When i use the command /buy weapon 30 30 I get a message "Usage: ..." and "Unknown format specifier '|', skipping." in console When i use /buy armour i only get a message "Usage: ..."

I tried as a plugin or component the problem is the same

based on sscanf documentation

CMD:buy(playerid, params[])
{
    new
        alt,
        weapon,
        ammo,
        vehicle,
        colour1,
        colour2;
    if (sscanf(params, "'weapon'ii|'armour'|'health'|'vehicle'k<vehicle>I(-1)I(-1)", alt, weapon, ammo, vehicle, colour1, colour2))
    {
        SendClientMessage(playerid, -1, "Usage:");
        SendClientMessage(playerid, -1, " ");
        SendClientMessage(playerid, -1, "    /buy weapon <id> <ammo>");
        SendClientMessage(playerid, -1, "    /buy armour");
        SendClientMessage(playerid, -1, "    /buy health");
        SendClientMessage(playerid, -1, "    /buy vehicle <type> <colour1> <colour2>");
        SendClientMessage(playerid, -1, " ");
        return 1;
    }
    else switch (alt)
    {
        case 1:
        {
            SendClientMessage(playerid, -1, "You bought weapon %d with %d ammo", weapon, ammo);
        }
        case 2:
        {
            SendClientMessage(playerid, -1, "You bought armour");
        }
        case 3:
        {
            SendClientMessage(playerid, -1, "You bought health");
        }
        case 4:
        {
            SendClientMessage(playerid, -1, "You bought vehicle %d with colours %d, %d", vehicle, colour1, colour2);
        }
    }
        return 1;
}