/givegun
#1

Well, i'm having a problem with /givegun; The command works perfectly if it's a one-word weapon name, but if it's two (example: combat shotgun) it doesn't work right. Any ideas?

pawn Code:
COMMAND:givegun(playerid, params[])
{
    new
        WeaponName[50],
        WeaponAmmo,
        user
    ;
    if(sscanf(params, "us[50]i", user, WeaponName, WeaponAmmo))
        return SendClientMessage(playerid, white, "[USAGE] /givegun [playerid] [weapon name] [weapon ammo]");
    if(PVar[playerid][pAdmin] >= 3)
    {
        GivePlayerWeapon(user, GetWeaponModelIDFromName(WeaponName), WeaponAmmo);
        SendClientMessage(user, white, "You have been given a weapon.");
    }
    return 1;
}
Functions:

pawn Code:
new aWeaponNames[][32] =
{
    {"Unarmed (Fist)"}, {"Brass Knuckles"}, {"Golf Club"}, {"Night Stick"}, {"Knife"}, {"Baseball Bat"},
    {"Shovel"}, {"Pool Cue"}, {"Katana"}, {"Chainsaw"}, {"Purple Dildo"}, {"Big White Vibrator"},
    {"Medium White Vibrator"}, {"Small White Vibrator"}, {"Flowers"}, {"Cane"}, {"Grenade"}, {"Teargas"},
    {"Molotov"}, {"Empty Slot 1"}, {"Empty Slot 2"}, {"Empty Slot 3"}{"Colt 45"}, {"Colt 45 (Silenced)"},
    {"Desert Eagle"}, {"Normal Shotgun"}, {"Sawnoff Shotgun"}, {"Combat Shotgun"}, {"Micro Uzi (Mac 10)"},
    {"MP5"}, {"AK47"}, {"M4"}, {"Tec9"}, {"Country Rifle"}, {"Sniper Rifle"}, {"Rocket Launcher"},
    {"Heat-Seeking Rocket Launcher"}, {"Flamethrower"}, {"Minigun"}, {"Satchel Charge"}, {"Detonator"},
    {"Spray Can"}, {"Fire Extinguisher"}, {"Camera"}, {"Night Vision Goggles"}, {"Infrared Vision Goggles"},
    {"Parachute"}, {"Fake Pistol"}
};

GetWeaponModelIDFromName(wname[])
{
    for(new i = 0; i < 48; i++) {
        if (i == 19 || i == 20 || i == 21) continue;
        if (strfind(aWeaponNames[i], wname, true) != -1) {
            return i;
        }
    }
    return -1;
}
Reply
#2

Just put em into one word?
Reply
#3

Your weaponnames are insuficient.

suppost to be like. "name","name",
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)