GetWeaponIDFromName? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: GetWeaponIDFromName? (
/showthread.php?tid=245205)
GetWeaponIDFromName? -
Skylar Paul - 30.03.2011
I remember seeing this function somewhere, but can't seem to find it with vBulletin's useless search function. Could someone help me find the function and perhaps post an example of how it works? Thank you in advance.
Re: GetWeaponIDFromName? -
xir - 30.03.2011
Here it is
pawn Код:
GetWeaponModelIDFromName(wname[])
{
for(new i = 0; i < 48; i++) {
if (i == 19 || i == 20 || i == 21) continue;
if (strfind(aWeaponNames[i], wname, true) != -1) {
return i;
}
}
return -1;
}
You can try make a code with it, and if it fails, you can post it here for others to help you
Re: GetWeaponIDFromName? -
Skylar Paul - 30.03.2011
Quote:
Originally Posted by xir
Here it is
pawn Код:
GetWeaponModelIDFromName(wname[]) { for(new i = 0; i < 48; i++) { if (i == 19 || i == 20 || i == 21) continue; if (strfind(aWeaponNames[i], wname, true) != -1) { return i; } } return -1; }
You can try make a code with it, and if it fails, you can post it here for others to help you 
|
Thank you very much. Incase anyone had the same question as me, here's a "sellgun" command with it working properly.
pawn Код:
COMMAND:sellgun(playerid, params[])
{
new WeaponName[30], user;
if(sscanf(params, "us[30]", user, WeaponName))
return SendClientMessage(playerid, white, "[USAGE] /sellgun [playerid] [weapon name]");
GivePlayerWeapon(playerid, GetWeaponModelIDFromName(WeaponName), 300);
return 1;
}