/giveweapon using names instead of id
#1

anyone no of any give script that uses the names of weapons instead of id please

like
pawn Код:
/giveweapon 0 ak47 500
the 500 is ammo obv
Reply
#2

I dont know where to d/l one
I know alot of GM's here have stuff like that

would be best to make your own,
simple array will do the trick as they are numbers 1 to 46

if you need help writing it ill help.
Reply
#3

i will need help writing it
Reply
#4

okay give me a min,
if i write it in a YCMD can you handle that?
brb
Reply
#5

yes ill just convert to zcmd
Reply
#6

He's right, try this:

pawn Код:
new WeaponNames[46][] = {
{"Fist"},{"Brass Knuckles"}, //continue in the right order of the weaps here just like me
};
The order is important, just continue where I stopped, you can find the weapon IDs here:

https://sampwiki.blast.hk/wiki/Weapons
Reply
#7

havent tested it yet

pawn Код:
new aWeapons[] =
{
"Fist",
"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 SMG/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"
};





YCMD:gweapon(playerid, params[], help)
{
    if (help)
    {
        SendClientMessage(playerid, 0xFF0000AA, "Give a player a weapon.");
    }
    else
    {
        new str[128], p1, p2[32], p3;
        if (isnull(params))
        {
            format(str, sizeof (str), "Usage: \"/%s [playerid] [weapon name] [ammo amount]\"", Command_GetDisplayNamed("gweapon", playerid));
            SendClientMessage(playerid, 0xFF0000AA, str);
        }
        else
        {
            if(!sscanf(params, "us[32]i", p1,p2,p3))
            {
                //
                for (new i = 0; i == sizeof(aWeapons); i++)
                {
                    if(strcmp(p2, aWeapons[i], true) == 0)
                    {
                        if(p1 != INVALID_PLAYER_ID)
                        {
                            GivePlayerWeapon(p1, i, p3);
                        }
                        return 1;
                    }

                }

            }
        }
    }
    return 1;
}
let me know how it works

could add some error checking and messages but this is the basic.
oh and Ima use this in my GM too.
Reply
#8

i just got errors i need it in this format how would i best convert it

pawn Код:
COMMAND:slap(playerid, params[])
{

    SendAdminText(playerid, "/slap", params);
    {
      new ID;
      if(APlayerData[playerid][PlayerLevel] < 1) return SendClientMessage(playerid, -1, "{ff0000}you are not admin");
      if(sscanf(params, "u", ID)) return SendClientMessage(playerid, -1, "{ff0000}Use: /slap [ID]");
      new Float:Pos[3];
      GetPlayerPos(ID, Pos[0], Pos[1], Pos[2]);
      SetPlayerPos(ID, Pos[0], Pos[1], Pos[2]+10);
    }
    return 1;
}
Reply
#9

try this not sure if it will work...

pawn Код:
COMMAND:gweapon(playerid, params[])
{

   new
        str[128],p1,p2[32],p3;
        if (isnull(params))
        {
            format(str, sizeof (str), "Usage: \"/%s [playerid] [weapon name] [ammo amount]\"", "gweapon");
            SendClientMessage(playerid, 0xFF0000AA, str);
        }
        else
        {
            if(!sscanf(params, "us[32]i", p1,p2,p3))
            {   //
                for (new i = 0; i == sizeof(aWeapons); i++)
                {
                    if(strcmp(p2, aWeapons[i], true) == 0)
                    {
                        if(p1 != INVALID_PLAYER_ID)
                        {
                            GivePlayerWeapon(p1, i, p3);
                        }
                        return 1;
                    }

                }


            {
        }
    return 1;
}
Reply
#10

this
pawn Код:
YCMD:gweapon(playerid, params[], help)
to this
pawn Код:
COMMAND:gweapon(playerid, params[])
and after deleting the help part
pawn Код:
COMMAND:gweapon(playerid, params[])
{
    new str[128], p1, p2[32], p3;
    if (isnull(params))
    {
        format(str, sizeof (str), "Usage: \"/%s [playerid] [weapon name] [ammo amount]\"", Command_GetDisplayNamed("gweapon", playerid));
        SendClientMessage(playerid, 0xFF0000AA, str);
    }
    else
    {
        if(!sscanf(params, "us[32]i", p1,p2,p3))
        {
            //
            for (new i = 0; i == sizeof(aWeapons); i++)
            {
                if(strcmp(p2, aWeapons[i], true) == 0)
                {
                    if(p1 != INVALID_PLAYER_ID)
                    {
                        GivePlayerWeapon(p1, i, p3);
                    }
                    return 1;
                }
            }
       }
    }
    return 1;
}
Quote:
Originally Posted by Madd Kat
Посмотреть сообщение
try this not sure if it will work...

pawn Код:
return 1;
                    }

                }


           { // uhm '}'?
        }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)