SA-MP Forums Archive
Weapon help - 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: Weapon help (/showthread.php?tid=632460)



Weapon help - silverms - 14.04.2017

is there a way to check if like this number 12342 is a weapon id?


Re: Weapon help - AndreiWow - 14.04.2017

If you want to make a givegun weapon or something like that you can check if the weapon id is between 1 and 46 otherwise the id is not good.


Re: Weapon help - silverms - 14.04.2017

how to check if it was between 1 and 46?


Re: Weapon help - ISmokezU - 14.04.2017

PHP код:
new weaponid
if(weaponid || weaponid  46



Re: Weapon help - AndreiWow - 14.04.2017

Well for example if you want to make a give weapon cmd you can do something like this

Let's say that your command is /givewep <playerid> <weaponid>

We will use weaponid to see what the player inserted, of course we'll use sscanf for that which you can find here: https://sampwiki.blast.hk/wiki/Fast_Commands

PHP код:
if (sscanf(params"ud"idweaponid)) SendClientMessage(playerid0xFF0000AA"Usage: \"/givewep <playerid/partname> <weaponid>\""); 
define id and weaponid to avoid any errors

And you can check if the id that the player inserted is valid by doing this

if(weaponid >=1 && weaponid <= 46)
{
code here
}
else
{
code here if he inserted an invalid it
}


Re: Weapon help - LEOTorres - 14.04.2017

Just checking inbetween the values would not work here, because there are values inbetween the ranges you have listed which aren't actually weapons.

Код:
new example = 57;

	if (example >= 0 && example <= 46 && example != 19 && example != 20 && example != 21)
	{
		//variable holds valid weaponid
	}
	
	else
	{
		//variable does not hold valid weaponid
	}