Weapon Name by ID - Help?
#1

Hello again guys...i want to make something in /stats to show the Weapon Name by his ID! Can somebody give me an example? REP++;
Reply
#2

you can use
https://sampwiki.blast.hk/wiki/GetWeaponName

but you have to take in account ids 18, 44 and 45.
https://sampwiki.blast.hk/wiki/Weapons
Reply
#3

That works in PublicOnPlayerDeath
Reply
#4

pawn Код:
if(!strcmp(cmdtext,"/myweapon"))
{
    new GunName[32], VBString[64];
    GetWeaponName(GetPlayerWeapon(playerid),GunName,sizeof GunName);
    format(VBString,sizeof VBString,"Your current gun : %s", GunName);
    SendClientMessagel(playerid, -1, VBString);
    return true;
}
\/ He only asked for one example, nothing more
Reply
#5

that will break on id 18,44,45 Vini

heres a stock i just wrote for this
pawn Код:
stock GetWeaponNameByID(wid)
{
    new gunname[32];
    switch (wid)
    {
        case    1 .. 17,
                22 .. 43,
                46 :        GetWeaponName(wid,gunname,sizeof(gunname));
        case    0:          format(gunname,32,"%s","Fist");
        case    18:         format(gunname,32,"%s","Molotov Cocktail");
        case    44:         format(gunname,32,"%s","Night Vis Goggles");
        case    45:         format(gunname,32,"%s","Thermal Goggles");
        default:            format(gunname,32,"%s","Invalid Weapon Id");
   
    }
    return gunname;
}

//usage

new str[47];
format(str,sizeof str, "Your weapon : %s" ,GetWeaponNameByID(wid));

EDIT:

I updated the stock as it did not account for invalid ID's
should be perfect now, if anyone see's anything wrong please post.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)