SA-MP Forums Archive
Creating /giveweaponall? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Creating /giveweaponall? (/showthread.php?tid=323578)



Creating /giveweaponall? - Reklez - 06.03.2012

How to make /giveweaponall?

Code:
/giveweaponall <Weaponname/id>

ZCMD
Sscanf



Re: Creating /giveweaponall? - jameskmonger - 06.03.2012

pawn Code:
for(new p; p < GetMaxPlayers(); p++) {
   if(IsPlayerConnected(p)) {
      GivePlayerWeapon(playerid, id, 99999);
   }
}



Re: Creating /giveweaponall? - Reklez - 06.03.2012

the question is how about the ammo plus how to check if either WeaponID or WeaponName are type? not sure but thanks. meanwhile this is is my new question


Re: Creating /giveweaponall? - jameskmonger - 06.03.2012

Make an array containing all the weapon names, loop through it and find the correct ID for the name.


Re: Creating /giveweaponall? - Reklez - 06.03.2012

Is this correct?

pawn Code:
new WeaponName[][45] =
{
    "Brass Knuckles",
    "Golf Club",
    "Nightstick",
    "Knife",
    "Baseball Bat",
    "Shovel",
    "Pool Cue",
    "Katana",
    "Chainsaw",
    "Double-ended Dildo",
    "Dildo",
    "Vibrator",
    "Silver Vibrator",
    "Flowers",
    "Cane",
    "Grenade",
    "Tear Gas",
    "Molotov Cocktail",
    "9mm",
    "Silenced 9mm",
    "Desert Eagle",
    "Shotgun",
    "Sawnoff Shotgun",
    "Combat Shotgun",
    "Micro UZI",
    "MP5",
    "AK-47",
    "M4",
    "Tec-9",
    "Country Rifle",
    "Sniper Rifle",
    "RPG",
    "HS Rocket",
    "Flamethrower",
    "Minigun",
    "Satchel Charge",
    "Detonator",
    "Spraycan",
    "Fire Extinguisher",
    "Camera",
    "Night Vis Goggles",
    "Thermal Goggles",
    "Parachute"
};
i didn't include the frisk one. Next what should i do?


Re: Creating /giveweaponall? - jameskmonger - 06.03.2012

pawn Code:
new gunname[45];
if(!sscanf(params, "s[45]", gunname)) {
    for(new g; g < sizeof(WeaponName); g++) {
        if(strcmp(gunname, WeaponName[g], true)) {
            for(new p; p < GetMaxPlayers(); p++) {
                 if(IsPlayerConnected(p)) {
                     GivePlayerWeapon(playerid, g, 99999);
                 }
             }
        }
    }
}
You can implement it into a command.


Re: Creating /giveweaponall? - Reklez - 06.03.2012

pawn Code:
CMD:giveallweapon(playerid, params[])
{
    new string[128], pname[MAX_PLAYER_NAME], gunname[45];
    if(PlayerInfo[playerid][pAdmin] > 5)
    {
        if(!sscanf(params, "s[45]", gunname))
        {
            GetPlayerName(playerid, pname, sizeof(pname));
            for(new g; g < sizeof(WeaponName); g++)
            {
                if(strcmp(gunname, WeaponName[g], true))
                {
                    for(new p; p < GetMaxPlayers(); p++)
                    {
                        if(IsPlayerConnected(p))
                        {
                            GivePlayerWeapon(playerid, g, 4987);
                            format(string, sizeof(string), "ADMIN: %s for everyone!", g);
                            GameTextForAll(string);
                        }
                    }
                }
            }
        }
        else return SendClientMessage(playerid, COLOR_RED, "SYNTAX: /giveallweapon <WeaponName>");
    }
    else return SendClientMessage(playerid, COLOR_RED, "Your not administrator!");
    return 1;
}
i get this warning

Code:
C:\DOCUME~1\Reklez112\MYDOCU~1\ReGMS\filterscript\Admin.pwn(466) : warning 202: number of arguments does not match definition
C:\DOCUME~1\Reklez112\MYDOCU~1\ReGMS\filterscript\Admin.pwn(466) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Warnings.



Re: Creating /giveweaponall? - jameskmonger - 06.03.2012

Which line is 466?


Re: Creating /giveweaponall? - Reklez - 06.03.2012

never mind i found the error


Re: Creating /giveweaponall? - Reklez - 06.03.2012

Sorry for double posting but.

when i type

"/giveallweapon 22"

it gives me almost all weapons. How could i do something like

"/giveallweapon 22"

or

"/giveallweapon 9mm"

?