SkiZo Posted January 8, 2017 Share Posted January 8, 2017 addCommandHandler ( "jp", function ( thePlayer ) if doesPedHaveJetPack ( thePlayer ) then -- If the player have a jetpack already, remove it removePedJetPack ( thePlayer ) -- Remove the jetpack return -- And stop the function here end -- Otherwise, give him one if he has access local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) -- get his account name if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then -- Does he have access to Admin functions? if not doesPedHaveJetPack ( thePlayer ) then -- If the player doesn't have a jetpack give it. givePedJetPack ( thePlayer ) -- Give the jetpack end end end ) How Can I Add bindKey ?? Keep the command & and bindKey "j" ?? Thanks Quote Link to comment
myonlake Posted January 8, 2017 Share Posted January 8, 2017 How about you do that yourself, since it's not that hard. Here's the function you need: https://wiki.multitheftauto.com/wiki/BindKey Link to comment
SkiZo Posted January 8, 2017 Author Share Posted January 8, 2017 (edited) i know about scripting ! but every time i add bindKey (thePlayer,"j",down,{Function Name} nothing happend :\ i tried more thatn 20 but no work So i request Help ! @myonlake Edited January 8, 2017 by S.W.A.T Link to comment
koragg Posted January 8, 2017 Share Posted January 8, 2017 (edited) function JetPack(thePlayer) if doesPedHaveJetPack(thePlayer) then -- Check if the player already has a jetpack. removePedJetPack(thePlayer) -- Remove the jetpack if he has one. return -- And stop the function here. end -- Otherwise, give him a jetpack if he is an admin. local accName = getAccountName(getPlayerAccount(thePlayer)) -- Get his account name. if isObjectInACLGroup("user."..accName, aclGetGroup("Admin")) then -- Check if he's admin. if not doesPedHaveJetPack(thePlayer) then -- If the player doesn't have a jetpack, give it. givePedJetPack(thePlayer) -- Give him a jetpack. end end end addCommandHandler("jp", JetPack) -- Bind the key here for every player as soon as he joins your server. function bindKeys() bindKey(source, "j", "down", JetPack) addEventHandler("onPlayerJoin", root, bindKeys) Edited January 8, 2017 by koragg Link to comment
Addlibs Posted January 8, 2017 Share Posted January 8, 2017 (edited) @koragg's code omits a necessary 'end' between the lines 19 and 20. The correct version, plus additional functionality to bind the key to people already connected (not those who join after the resource is running) -- Bind the key here for every player as soon as he joins your server. function bindKeys() bindKey(source, "j", "down", "jp") -- bind key to command 'jp' so that the bind can be changed in MTA settings > binds end addEventHandler("onPlayerJoin", root, bindKeys) -- Bind the key here for every player already connected to your server. for k, v in ipairs(getElementsByType("player")) do -- loop through already connected players bindKey(v, "j", "down", "jp") -- bind key to command 'jp' end Edited January 8, 2017 by MrTasty 1 Link to comment
SkiZo Posted January 8, 2017 Author Share Posted January 8, 2017 (edited) Thanks @MrTasty & @koragg =) I Will test Them @koragg No Work Edited January 8, 2017 by S.W.A.T Link to comment
koragg Posted January 8, 2017 Share Posted January 8, 2017 3 hours ago, S.W.A.T said: 16 minutes ago, S.W.A.T said: Thanks @MrTasty & @koragg =) I Will test Them @koragg No Work Yea, I missed the "end" as @MrTasty mentioned. But better use his code as it's updated version of what I wrote. Link to comment
SkiZo Posted January 8, 2017 Author Share Posted January 8, 2017 @MrTasty Thanks It's Work @koragg I added the "end" But Did Not Work ! But Thanks For Helping Bro <3 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