Jump to content

getPedAllWeaponsInHand xD


CowTurbo

Recommended Posts

how to get player all weapons what he got ?

getPedWeapon(player,slot)

For all weapons:

function giveAllPedWeaposn(player) 
local playerWeapons = {} 
for sl = 0,12 do 
local weap = getPedWeapon(player,sl) 
if weap == 0 then 
else 
table.insert(playerWeapons,weap) 
end 
end 
return playerWeapons 
end 

Its function returns all ped weapons in table

Link to comment

This is how deathpickups does it:

  
local droppedWeapons = {} 
local weaponSlots = {0,1,2,3,4,5,6,7,8,9,10,11,12} 
     
for i, slot in ipairs(weaponSlots) do 
    local ammo = getPedTotalAmmo ( localPlayer, slot )  
    if ( getPedWeapon ( localPlayer, slot ) ~= 0 ) then 
         local weapon = getPedWeapon ( localPlayer, slot ) 
         local ammo = getPedTotalAmmo ( localPlayer, slot ) 
         table.insert(droppedWeapons, {weapon, ammo})         
    end 
end 

Even better now:

local droppedWeapons = {} 
for slot=0, 12 do 
    local ammo = getPedTotalAmmo(source, slot)  
    if (getPedWeapon(source, slot) ~= 0) then 
        local weapon = getPedWeapon(source, slot) 
        local ammo = getPedTotalAmmo(source, slot) 
        table.insert(droppedWeapons, {weapon, ammo})                     
    end 
end 

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