Command help
#8

Yes, it formats only once now. But you still declare variables or get the name of weapon before checking if the weapon is valid. Notice how I placed them inside the allowed weapons:

pawn Код:
CMD:fight(playerid, params[])
{
    new wep_id;

    if (sscanf(params, "d", wep_id)) return SCM(playerid, COLOR_GREEN, "* [USAGE]: /fight [weapon id]");

    switch (wep_id)
    {
        case 2..13, 15, 16, 18, 22..39, 41, 42:
        {
            new string[32], gunname[19];

            GetWeaponName(wep_id, gunname, sizeof(gunname));
            format(string, sizeof(string), "~g~%s ~w~fight!", gunname);

            foreach(new i: Player)
            {
                GivePlayerWeapon(i, wep_id, 9999);
                GameTextForPlayer(i, string, 3000, 4);
            }
        }
        default:
        {
            SCM(playerid, COLOR_RED, "* Invalid weapon ID.");
        }
    }
    return 1;
}
Another alternative is `GameTextForAll` function so you will only have to give weapon in the foreach loop.
Reply


Messages In This Thread
Command help - by SymonClash - 30.01.2019, 08:56
Re: Command help - by Calisthenics - 30.01.2019, 08:59
Re: Command help - by SymonClash - 30.01.2019, 09:05
Re: Command help - by Calisthenics - 30.01.2019, 09:07
Re: Command help - by SymonClash - 30.01.2019, 09:15
Re: Command help - by Calisthenics - 30.01.2019, 09:26
Re: Command help - by SymonClash - 30.01.2019, 10:36
Re: Command help - by Calisthenics - 30.01.2019, 10:49
Re: Command help - by SymonClash - 30.01.2019, 10:58

Forum Jump:


Users browsing this thread: 4 Guest(s)