Jump to content

Checking if a weapon have bullets inside?[Solved]


Snakeman

Recommended Posts

I need help to make a code like this...
if (instanceof(Item, "HandWeapon") and Item:getCondition() > 0) and (item:contains bullets inside) then....
    ForumMember: say("i need help with the red line. lol") :P
end

Edited by Snakeman
Link to comment
Share on other sites

  • 2 weeks later...
On 8/28/2016 at 5:03 PM, Snakeman said:

I need help to make a code like this...
if (instanceof(Item, "HandWeapon") and Item:getCondition() > 0) and (item:contains bullets inside) then....
    ForumMember: say("i need help with the red line. lol") :P
end

I knew I remembered something that I saw that had to do with this, this is what I found:

local player = getPlayer();
local primary = player:getPrimaryHandItem();

if primary:getModData().currentCapacity >= 1 or primary:getModData().roundChambered >= 1 then
	--do the stuff forum member wants
end

I didn't actually run a test on the roundChambered portion, but I believe it works the same. If not, you can remove that part and the function will work without taking accountability of whether or not there's a bullet in the chamber. Also, you'll probably get an error if this function is ran on an item that isn't a gun, but there are work arounds for that.

Link to comment
Share on other sites

9 hours ago, tommysticks said:

I knew I remembered something that I saw that had to do with this, this is what I found:


local player = getPlayer();
local primary = player:getPrimaryHandItem();

if primary:getModData().currentCapacity >= 1 or primary:getModData().roundChambered >= 1 then
	--do the stuff forum member wants
end

I didn't actually run a test on the roundChambered portion, but I believe it works the same. If not, you can remove that part and the function will work without taking accountability of whether or not there's a bullet in the chamber. Also, you'll probably get an error if this function is ran on an item that isn't a gun, but there are work arounds for that.

Thanks for your help!!! I solved that in another way :D

Link to comment
Share on other sites

  • 4 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...