Give player weapons from name
#6

pawn Код:
dcmd_w2(playerid, params[])
{
    new idx, iString[128];
    iString = strtok(params, idx);

    if (!strlen(iString)) {
        SendClientMessage(playerid, COLOR_RED, "[USAGE]: /w2 WEAPONID/NAME (AMMO) or /weapon WEAPONID/NAME (AMMO)");
        return true;
    }

    new weaponid = GetWeaponModelIDFromName(iString);

    if (weaponid == -1) {
        weaponid = strval(iString);
        if (weaponid < 0 || weaponid > 47) {
            SendClientMessage(playerid, COLOR_RED, "[ERROR]: Invalid WEAPONID/NAME");
            return true;
        }
    }

    if (!strlen(params[idx+1])) {
        GivePlayerWeapon(playerid, weaponid, 500);

        format(iString, 128, "[SUCCESS]: You were given weapon %s (ID: %d) with 500 ammo.", aWeaponNames[weaponid], weaponid);
        SendClientMessage(playerid, COLOR_GREEN, iString);

        return true;
    }

    idx = strval(params[idx+1]);

    GivePlayerWeapon(playerid, weaponid, idx);

    format(iString, 128, "[SUCCESS]: You were given weapon %s (ID: %d) with %d ammo.", aWeaponNames[weaponid], weaponid, idx);
    SendClientMessage(playerid, COLOR_GREEN, iString);

    return true;
}
That's the /w2 command.

Check that out and maybe you'll get an idea.
Reply


Messages In This Thread
Give player weapons from name - by Snowman12 - 13.01.2012, 23:10
Re: Give player weapons from name - by Steven82 - 13.01.2012, 23:52
Re: Give player weapons from name - by Scenario - 13.01.2012, 23:54
Re: Give player weapons from name - by Snowman12 - 14.01.2012, 00:02
Re: Give player weapons from name - by Jakku - 14.01.2012, 00:04
Re: Give player weapons from name - by iGetty - 14.01.2012, 01:12
Re: Give player weapons from name - by Snowman12 - 14.01.2012, 01:46

Forum Jump:


Users browsing this thread: 1 Guest(s)