SA-MP Forums Archive
Gun name to id - 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: Gun name to id (/showthread.php?tid=358900)



Gun name to id - SnG.Scot_MisCuDI - 12.07.2012

Anyone have the stock for Gun Name to ID? Im not sure if there is one.. But i would imagine its something like Car name to ID

so i can /givegun sawnoff


Re: Gun name to id - SuperViper - 12.07.2012

It's one of the many important functions included in here: https://sampforum.blast.hk/showthread.php?tid=348044.


Re: Gun name to id - SnG.Scot_MisCuDI - 12.07.2012

Quote:
Originally Posted by SuperViper
Посмотреть сообщение
It's one of the many important functions included in here: https://sampforum.blast.hk/showthread.php?tid=348044.
EDIT: found it.


Re: Gun name to id - SuperViper - 12.07.2012

pawn Код:
GetWeaponID(weaponName[], bool: ignoreCase = true, bool: useFind = false)
Use:

pawn Код:
GivePlayerWeapon(playerid, GetWeaponID(params));



Re: Gun name to id - SnG.Scot_MisCuDI - 12.07.2012

Quote:
Originally Posted by SuperViper
Посмотреть сообщение
pawn Код:
GetWeaponID(weaponName[], bool: ignoreCase = true, bool: useFind = false)
Can you show me an example of using it in a givegun command?


Re: Gun name to id - SuperViper - 12.07.2012

I edited my post before you posted, look above.


Re: Gun name to id - SnG.Scot_MisCuDI - 12.07.2012

that include is giving me a bunch of warnings "shadows at a preceding level"
Isnt there just a stock


Re: Gun name to id - SuperViper - 12.07.2012

I would appreciate it if you told me what warnings you're getting. If you want just the stock, here:

pawn Код:
stock GetWeaponID(weaponName[], bool: ignoreCase = true, bool: useFind = false)
{
    new weaponID = -1;
    if(useFind == false)
    {
        for(new i = 0, sof = sizeof(svAddons_WeaponNames); i < sof; i++)
        {
            if(!strcmp(svAddons_WeaponNames[i], weaponName, ignoreCase))
            {
                weaponID = i;
                break;
            }
        }
    }
    else if(useFind == true)
    {
        for(new i = 0, sof = sizeof(svAddons_WeaponNames); i < sof; i++)
        {
            if(strfind(svAddons_WeaponNames[i], weaponName, ignorecase) > -1)
            {
                weaponID = i;
                break;
            }
        }
    }
    return weaponID;
}



Re: Gun name to id - SnG.Scot_MisCuDI - 12.07.2012

pawn Код:
\pawno\include\svAddons.inc(120) : warning 219: local variable "interior" shadows a variable at a preceding level
\pawno\include\svAddons.inc(742) : warning 219: local variable "interior" shadows a variable at a preceding level
\pawno\include\svAddons.inc(752) : warning 219: local variable "interior" shadows a variable at a preceding level
\pawno\include\svAddons.inc(768) : warning 219: local variable "time" shadows a variable at a preceding level
\pawno\include\svAddons.inc(768) : warning 219: local variable "interior" shadows a variable at a preceding level
\pawno\include\svAddons.inc(784) : warning 219: local variable "interior" shadows a variable at a preceding level
\pawno\include\svAddons.inc(842) : warning 219: local variable "interior" shadows a variable at a preceding level
(3725) : error 035: argument type mismatch (argument 3)



Re: Gun name to id - SuperViper - 12.07.2012

You have common global variable names, which is a problem.