Jump to content

next and previous weapon


MultiNo

Recommended Posts

Posted
Use the event
  
onPlayerWeaponSwitch 
  

@ Max: It will only get the current weapon! Not previous .

Yeah , You'r Right , that event should do the job ,

Posted

"onPlayerWeaponSwitch" will not return the next weapon.

You can use these functions:

Client

function getPreviousWeapon() 
    local tempSlot = {} 
    local curSlot = getPedWeaponSlot(localPlayer) 
    if (curSlot == 0) and (getPedWeapon(localPlayer) == 0 or getPedWeapon(localPlayer) == 1) then 
        curSlot = 13 
    end 
     
    tempSlot["ID"] = 12 + 1 
    repeat 
        tempSlot["ID"] = tempSlot["ID"]-1 
    until (tempSlot["ID"] < curSlot) and not (tempSlot["ID"] ~= 0 and getPedWeapon(localPlayer, tempSlot["ID"]) == 0) 
    return getPedWeapon(localPlayer, tempSlot["ID"]) 
end 
  
function getNextWeapon() 
    local tempSlot = {} 
    local curSlot = getPedWeaponSlot(localPlayer) 
    if (curSlot == 12) then 
        curSlot = - 1 
    end 
     
    tempSlot["ID"] = - 1 
    repeat 
        tempSlot["ID"] = tempSlot["ID"] + 1 
        if tempSlot["ID"] == 13 then 
            tempSlot["ID"] = -1 
            curSlot = -1 
        end 
    until (tempSlot["ID"] > curSlot) and not (tempSlot["ID"] ~= 0 and getPedWeapon(localPlayer, tempSlot["ID"]) == 0) 
    return getPedWeapon(localPlayer, tempSlot["ID"]) 
end 

I don't know if it's the best way to do that, but it should work without problems.

Posted

I tried this but not working

    if ( 'getPreviousWeapon' == 1 ) then  
        dxDrawImage ( x, y, x, y, "img/1.png" ) 
    end 

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