Electro88 Posted February 2, 2016 Share Posted February 2, 2016 Hello everyone i find vip jetpack system and i add bind key for jetpack but no work bad argument @ 'bindKey' [Expected player at argument 1, got string 'j' bindKey ( "J", "down", 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 ( "V.İ.P" ) ) 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 ) where the problem ? Link to comment
Bonus Posted February 2, 2016 Share Posted February 2, 2016 (edited) The way you use bindKey is clientsided, not serversided. You have to use player for 1. argument. You can put bindKey in onPlayerJoin like addEventHandler ( "onPlayerJoin", root, function ( ) bindKey ( source, "J", "down", giveJetpack_func ) end ) function giveJetpack_func ... Oh and you can delete the 2nd doesPedHaveJetPack. If you have a jetpack it gets removed and the function stops. So you can't get to row 13 with an Jetpack, thats why its totally useless. Edited February 2, 2016 by Guest Link to comment
KariiiM Posted February 2, 2016 Share Posted February 2, 2016 (edited) Try that addEventHandler ("onResourceStart", resourceRoot, function () for index, player in ipairs (getElementsByType ("player")) do bindKey ( player, "J", "down", toggleJetpack ) end end) function toggleJetpack( thePlayer ) --give him one if he has access local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) -- get his account name if isObjectInACLGroup ("user."..accName, aclGetGroup ( "V.İ.P" ) ) 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 else removePedJetPack ( thePlayer ) end end end Edited February 2, 2016 by Guest Link to comment
Bonus Posted February 2, 2016 Share Posted February 2, 2016 @KariiiM: With your code it gets binded only on resource start. If a player joines after the resource startet he won't get the bind for jetpack. Also there is no need for ipairs, it just slows the script for no reason. Better use: local players = getElementsByType ( "player" ) for i=1, #players do bindKey ( players[i] ... ... end or for index, player in pairs ( getElementsByType ( "player" ) do @Electro88: You can use row 1-6 in his code if you want to (re-)start the Resource while playing. Link to comment
Electro88 Posted February 2, 2016 Author Share Posted February 2, 2016 Worked Thanks! Link to comment
KariiiM Posted February 2, 2016 Share Posted February 2, 2016 I cleared it abit,Full code: addEventHandler ("onPlayerLogin", root, function () bindKey ( source, "P", "down", toggleJetpack ) end) addEventHandler ("onResourceStart", resourceRoot, function () for index, player in ipairs (getElementsByType ("player")) do bindKey ( player, "J", "down", toggleJetpack ) end end) function toggleJetpack( thePlayer ) --give him one if he has access local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) -- get his account name if isObjectInACLGroup ("user."..accName, aclGetGroup ( "V.İ.P" ) ) 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 else removePedJetPack ( thePlayer ) end end end Link to comment
Sir.BEEF Posted February 2, 2016 Share Posted February 2, 2016 Fixed or still bugged?? Link to comment
1LoL1 Posted February 2, 2016 Share Posted February 2, 2016 Fixed or still bugged?? Let's test.. do you think that there will be someone for you to test? Link to comment
Sir.BEEF Posted February 2, 2016 Share Posted February 2, 2016 man shut up... i was just asking if he it worked with him or not stop farming posts Link to comment
1LoL1 Posted February 2, 2016 Share Posted February 2, 2016 man shut up...i was just asking if he it worked with him or not stop farming posts You're so lazy that test? Be glad that you helped.. Link to comment
KariiiM Posted February 2, 2016 Share Posted February 2, 2016 You're so lazy that test? Be glad that you helped.. man shut up...i was just asking if he it worked with him or not stop farming posts Can you both stop fighting ? We already helped him and the code worked for him. Link to comment
#RooTs Posted February 2, 2016 Share Posted February 2, 2016 https://community.multitheftauto.com/in ... s&id=11405 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