Jump to content

Scrolling on jetpack


Recommended Posts

Here --

E to slot forward, Q to slot backwards.

  
function NextWeapon (player) 
if doesPedHaveJetPack (player) then 
local slot = getPedWeaponSlot(player) 
if slot == 12 then 
setPedWeaponSlot (player,0) 
else 
setPedWeaponSlot (player,slot+1) 
end 
end 
end 
  
function PreWeapon (player) 
if doesPedHaveJetPack (player) then 
local slot = getPedWeaponSlot(player) 
if slot == 0 then 
setPedWeaponSlot (player,12) 
else 
setPedWeaponSlot (player,slot-1) 
end 
end 
end 
  
function BindKeys () 
for i,v in pairs(getElementsByType("player")) do 
  bindKey ( v, "e", "down", NextWeapon )    
  bindKey ( v, "q", "down", PreWeapon )    
end 
end 
  
addEventHandler ( "onResourceStart", resourceRoot, BindKeys ) 
  
function BindKeys2 () 
  bindKey ( source, "e", "down", NextWeapon )    
  bindKey ( source, "q", "down", PreWeapon )    
end 
  
addEventHandler ( "onPlayerJoin", getRootElement(),BindKeys2) 
  
  
  

Link to comment
function switch (player,key) 
    if doesPedHaveJetPack (player) then 
        local slot = getPedWeaponSlot(player) 
        if key == "mouse_wheel_up" then 
            if slot == 12 then 
                setPedWeaponSlot (player,0) 
            else 
                setPedWeaponSlot (player,slot+1) 
            end 
        elseif key == "mouse_wheel_down" then  
            if slot == 0 then 
                setPedWeaponSlot (player,12) 
            else 
                setPedWeaponSlot (player,slot-1) 
            end  
        end 
    end 
end 
  
  
function bindOnStart () 
    for i,v in pairs(getElementsByType("player")) do 
        bindKeys(v) 
    end 
end 
addEventHandler ( "onResourceStart", resourceRoot, bindOnStart) 
  
function bindKeyOnjoin () 
    bindKeys(source) 
end 
addEventHandler ( "onPlayerJoin", getRootElement(),bindKeyOnjoin) 
  
function bindKeys(player) 
    if player and isElement(player) then  
        bindKey ( player, "mouse_wheel_up", "down", switch )   
        bindKey ( player, "mouse_wheel_down", "down", switch )   
    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...