Weapon help
#1

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

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.
Reply
#3

how to check if it was between 1 and 46?
Reply
#4

PHP код:
new weaponid
if(weaponid || weaponid  46
Reply
#5

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
}
Reply
#6

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
	}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)