sscanf error
#1

pawn Код:
CommandDescription<spawnweapon> = @"Spawn a weapon for the specified player.";
YCMD(GROUP_ADMIN, GROUP_MANAGEMENT, GROUP_RCON):spawnweapon(playerid, params[], help) {
    if(help) {
        SendClientMessage(playerid, COLOR_COMMAND_HELP, @"Spawn a weapon for a specified player");
    } else {
        new target, weapon, ammo;
        if(sscanf(params, "rk<weapon>i(-1)", target, weapon, ammo)) {
            SendClientMessage(playerid, COLOR_COMMAND_USAGE, @"* Usage: /spawnweapon [player] [weapon] [OPTIONAL: ammo-amount]");
        } else {
            if(playerid == INVALID_PLAYER_ID) {
                SendClientMessage(playerid, COLOR_COMMAND_ERROR, @"Invalid player ID");
                return 1;
            }
            if(weapon != -1) {
                if(ammo == -1) {
                    GivePlayerWeapon(target, weapon, 99999);
                    SendClientMessage(playerid, 0xFF87E9FF, @"You have given %p %w with unlimited ammo.", target, weapon);
                    SendClientMessage(target, 0xFF87E9FF, @"%p has given you %w with unlimited ammo.", playerid, weapon);
                } else {
                    GivePlayerWeapon(target, weapon, ammo);
                    SendClientMessage(playerid, 0xFF87E9FF, @"You have given %p %w with %d round of ammo.", target, weapon, ammo);
                    SendClientMessage(target, 0xFF87E9FF, @"%p has given you %w with %d rounds of ammo.", playerid, weapon, ammo);
                }
            } else {
                SendClientMessage(playerid, COLOR_COMMAND_ERROR, @"You entered an invalid weapon.");
            }
        }
    }
    return 1;
}
If I type /spawnweapon 1 24, it should assume the default ammo value (-1) and carry on with the code. However, it simply gives me the "Usage: /spawnweapon [player] [weapon] [OPTIONAL: ammo-amount]" message. Can someone help me?
Reply
#2

Bump
Reply
#3

pawn Код:
"rk<weapon>i(-1)"
//Changes to
"rk<weapon>I(-1)"
Reply
#4

Ah, thankyou. :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)