goofie88 Posted May 13, 2013 Posted May 13, 2013 function allowORnot (player, key) if isObjectInACLGroup("user."..getAccountName( getPlayerAccount( player ) ), aclGetGroup( "Pirate" ) ) then if (key = nil) then key = 0 removeEventHandler("onVehicleStartEnter", getRootElement(), pirateBoat) end elseif (key = 0) then addEventHandler ( "onVehicleStartEnter", getRootElement(), pirateBoat) key = nil end end addCommandHandler ("cannon", allowORnot) I don't see what I'm doing wrong, is it my syntax? Error: Loading script failed restriction.lua:3: ')' expected near '='
csiguusz Posted May 13, 2013 Posted May 13, 2013 function allowORnot (player, key) if isObjectInACLGroup("user."..getAccountName( getPlayerAccount( player ) ), aclGetGroup( "Pirate" ) ) then if (key == nil) then key = 0 removeEventHandler("onVehicleStartEnter", getRootElement(), pirateBoat) end elseif (key == 0) then addEventHandler ( "onVehicleStartEnter", getRootElement(), pirateBoat) key = nil end end addCommandHandler ("cannon", allowORnot)
goofie88 Posted May 13, 2013 Author Posted May 13, 2013 thanks(no errors now) but the command seems to not respond, added outputChatBox after key = 0 and key = nil and nothing im trying to figure out my mistake but i dont even imagine what the error could be
goofie88 Posted May 13, 2013 Author Posted May 13, 2013 i want it with a command to remove and add events removeEventHandler("onVehicleStartEnter", getRootElement(), pirateBoat) addEventHandler ( "onVehicleStartEnter", getRootElement(), pirateBoat) like a toggable command not cannonopen, cannonclose
goofie88 Posted May 13, 2013 Author Posted May 13, 2013 key is nothing its just so i can use it as a toggle
goofie88 Posted May 13, 2013 Author Posted May 13, 2013 key is like cur, if you know what i mean. I wont post full code coz it wont rly fix. All im trying to do is a toggable command to add and remove the handler
PaiN^ Posted May 13, 2013 Posted May 13, 2013 csiguusz's code is fine . Show us the 'pirateBoat' function .
goofie88 Posted May 13, 2013 Author Posted May 13, 2013 function allowORnot (player, key) outputChatBox("check") if isObjectInACLGroup("user."..getAccountName( getPlayerAccount( player ) ), aclGetGroup( "Pirate" ) ) then if (key == nil) then key = 0 outputChatBox("go") removeEventHandler("onVehicleStartEnter", getRootElement(), pirateBoat) end elseif (key == 0) then addEventHandler ( "onVehicleStartEnter", getRootElement(), pirateBoat) key = nil outputChatBox("stop") end end addCommandHandler ("cannon", allowORnot) csiguusz's code isn't fine , tried with checks, it "check" then "go" but doesnt go to "stop" and after that it just "check"
Castillo Posted May 13, 2013 Posted May 13, 2013 The second argument of addCommandHandler is the command name, not "nil" nor a number.
goofie88 Posted May 13, 2013 Author Posted May 13, 2013 so is there a way I can make it toggable? I understood what you said Solidsnake14 but it didnt rly help me
Castillo Posted May 13, 2013 Posted May 13, 2013 You can use a table. local state = { } function allowORnot ( player ) outputChatBox ( "check" ) if isObjectInACLGroup ( "user.".. getAccountName ( getPlayerAccount ( player ) ), aclGetGroup( "Pirate" ) ) then if ( state [ player ] ) then state [ player ] = nil outputChatBox ( "go" ) removeEventHandler ( "onVehicleStartEnter", getRootElement(), pirateBoat ) else state [ player ] = true addEventHandler ( "onVehicleStartEnter", getRootElement(), pirateBoat ) outputChatBox ( "stop" ) end end end addCommandHandler ( "cannon", allowORnot )
goofie88 Posted May 13, 2013 Author Posted May 13, 2013 Wow thank you Solidsnake that's exactly what i wanted thanks for you help!!
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