Jump to content

Get ped/player weapons and return a table with them


Recommended Posts

Posted

Well, the title said it all. I Would like to know if theres a specific client-side function to get all the player weapons, not the one he's currently using; and how can i make it return in a table. Thanks ;)

Posted
local playerWeapons = {} 
for slot = 0, 12 do 
local weapon = getPedWeapon(player, slot) 
table.insert(playerWeapons, weapon) 
end 

just a start.

Posted
function getPlayerWeapons(player) 
local weaponsTable = {} 
    for index=0, 13 do 
        local weapon = getPedWeapon(player,index) 
        local ammo = getPedTotalAmmo(player,index) 
        if ammo > 0 then 
            table.insert(weaponsTable, {weapon, ammo}) 
        end 
    end 
return weaponsTable 
end 

Should return a table of weapons (weapon model, ammo).

Posted
local playerWeapons = {} 
for slot = 0, 12 do 
local weapon = getPedWeapon(player, slot) 
table.insert(playerWeapons, weapon) 
end 

just a start.

Thanks brother. You help is appreciated :D

Edit: And thank you too Solidsnake14. You help is also appreciated xD

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...