Jump to content

checkWeapon


Recommended Posts

Hey there, i don't use to ask for help, but right now i'm a bit confused, this function keeps returning wrong,

function checkWeapon(player,cat) 
melee = {1,10} 
primary = {3,5,6} 
secondary = {2,4} 
projectiles = {7,8} 
if cat == "Melee" then 
for i,v in pairs(melee) do 
if getPedTotalAmmo ( player, v ) == 0 then 
return true 
else 
outputChatBox("You already have a weapon of this category!",player,255,0,0) 
return false 
   end 
end 
elseif cat == "Primary" then 
for i,v in pairs(primary) do 
if getPedTotalAmmo ( player, v ) == 0 then 
return true 
else 
outputChatBox("You already have a weapon of this category!",player,255,0,0) 
return false 
   end 
end 
elseif cat == "Secondary" then 
for i,v in pairs(secondary) do 
if getPedTotalAmmo ( player, v ) == 0 then 
return true 
else 
outputChatBox("You already have a weapon of this category!",player,255,0,0) 
return false 
   end 
end 
elseif cat == "Projectiles" then 
for i,v in pairs(projectiles) do 
if getPedTotalAmmo ( player, v ) == 0 then 
return true 
else 
outputChatBox("You already have a weapon of this category!",player,255,0,0) 
return false 
      end 
    end 
  end 
end 

It's used to check if i have a weapon in the desired category or not, but somehow it keeps returning that i don't have, any help is appreciated.

Thanks in advance.

Link to comment

lol, i tryied that already, now i'm using this: if getPedTotalAmmo ( player, v ) == 0 or not getPedTotalAmmo(player) or not getPedWeapon(player,v) then, for now seems to work, but it may get buggy after a while.

Link to comment

Uhm, no.. i've closed my RPG server long time ago, remade some stuff from it some weeks ago, but nothing else, still thinking if i will re-open it or not, but this script isn't for me really, just for my client (working for a guy for $$).

Link to comment

This thing is still bugged :roll: , i'm out of ideas, i don't know why it won't work, here's the new code.

Edit: Remp helped me in the IRC channel, and seems to work fine his code, thanks to everyone, specially to Remp :)

Link to comment

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...