Gravestone Posted July 20, 2016 Share Posted July 20, 2016 Is there anyway I can allow players to scroll weapons on jetpack? I enabled all the weapons on jetpack but now I want to enable scrolling too. Link to comment
Tox Posted July 21, 2016 Share Posted July 21, 2016 you'll use; bindKey https://wiki.multitheftauto.com/wiki/SetPedWeaponSlot Link to comment
Gravestone Posted July 21, 2016 Author Share Posted July 21, 2016 How should I use it? Link to comment
Captain Cody Posted July 21, 2016 Share Posted July 21, 2016 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
Captain Cody Posted July 21, 2016 Share Posted July 21, 2016 But if you want to scroll, replace E and Q with mouse_wheel_up and mouse_wheel_down Link to comment
Walid Posted July 21, 2016 Share Posted July 21, 2016 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
Gravestone Posted July 22, 2016 Author Share Posted July 22, 2016 Both the codes are not working good. I can't figure out what's wrong. Link to comment
Captain Cody Posted July 22, 2016 Share Posted July 22, 2016 I tested mine, it works just fine, unless you were holding a gun that cannot be shot in jetPack when getting the jet pack Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now