Giveweapon issues
#1

Okay, basically, I am trying to create a command that can spawn a selected player a weapon with a defined amount of ammo, this issue is: Whenever I try to spawn a weapon it either breaks the command, says that a "Fist" is spawned and no weapon spawns or nothing happens at all..

Here is all relevant code:

pawn Код:
new WeaponNames[47][] =
{
    "Fist","BrassKnuckles","Golfclub","Nitestick","Knife","BaseballBat","Shovel","Poolcue","Katana","Chainsaw","PurpleDildo","SmallWhiteVibrator","LargeWhiteVibrator","SilverVibrator",
    "Flowers","Cane","Grenade","Tearcas Grenade","Molotov Cocktail","Jetpack"," "," ","9mm","Silenced9mm","Deagle","Shotgun","Sawn-OffShotgun","SPAS-12",
    "MicroUzi","MP5","AK-47","M4","Tec-9","Rifle","Sniperrifle","RPG","Heatseeker","Flamethrower","Minigun","SatchelCharge","Detonator","SprayCan","FireExtinguisher",
    "Camera","NightvisionGoggles", "ThermalGoggles","Parachute"
};
^^ Above is the weapon name declarations and having them in the correct order in the array to read them properly.

pawn Код:
command(giveweapon, playerid, params[])
{
    new sWeapon;
    new str[128];
    new wepid, id, ammo;
   
    if(sscanf(params, "udd", id, wepid, ammo)) return SendClientMessage(playerid, 0x66666666, "Usage: /giveweapon [Player ID] [Weapon ID] [Ammo] * You can only give 5000 ammo with the weapon *");
    {
        //sWeapon = GetWeaponModelIDFromName(wepid);
        //if(sWeapon < 1 || sWeapon > 47) return SendClientMessage(playerid, 0x66666666, "That weapon model or ID doesn't exist.");
        if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0x66666666, "That player is not connected.");
        if(ammo > 5000 || ammo < 0) return SendClientMessage(playerid, 0x66666666, "You can only give between 1-5000 ammo");
        if(playerid == id)
        {
            format(str, sizeof(str), "You have given yourself a %s [ID %d] with '%d' ammo.", WeaponNames[sWeapon], sWeapon, ammo);
            SendClientMessage(id, 0x99000000, str);
            GivePlayerWeapon(id, wepid, ammo);
        }
        else
        {
            format(str, sizeof(str), "You have given %s a '%s [ID %d]' with '%d' ammo.", RemoveUnderScore(id), WeaponNames[sWeapon], sWeapon, ammo);
            SendClientMessage(playerid, 0x99000000, str);
            format(str, sizeof(str), "You have been given a '%s [ID %d]' with '%d' ammo by %s", WeaponNames[sWeapon], sWeapon, ammo, RemoveUnderScore(playerid));
            SendClientMessage(id, 0x99000000, str);
            GivePlayerWeapon(id, wepid, ammo);
        }
    }
    return 1;
}
^^ That is the actual command script, it is not finished as you can clearly see, I am having issue with it

pawn Код:
GetWeaponModelIDFromName(wname[])
{
    for(new i = 0; i < 47; i++)
    {
        if (i == 19 || i == 20 || i == 21) continue;
        if (strfind(WeaponNames[i], wname, true) != -1)
        {
            return i;
        }
    }
    return 1;
}
^^ That is the stock I use to actually read the correct name from the array..

Any / immediate help would be appreciated.
Reply


Messages In This Thread
Giveweapon issues - by vIBIENNYx - 18.05.2012, 21:47
Re: Giveweapon issues - by vIBIENNYx - 18.05.2012, 22:01
Re: Giveweapon issues - by MP2 - 18.05.2012, 22:04
Re: Giveweapon issues - by vIBIENNYx - 18.05.2012, 22:07
Re: Giveweapon issues - by vIBIENNYx - 18.05.2012, 22:24
AW: Re: Giveweapon issues - by Nero_3D - 18.05.2012, 22:43
Re: AW: Re: Giveweapon issues - by vIBIENNYx - 18.05.2012, 22:57
Re: AW: Re: Giveweapon issues - by vIBIENNYx - 18.05.2012, 23:09
AW: Re: AW: Re: Giveweapon issues - by Nero_3D - 19.05.2012, 01:33
Re: Giveweapon issues - by vIBIENNYx - 19.05.2012, 01:49

Forum Jump:


Users browsing this thread: 1 Guest(s)