stormchaser206 Posted August 11, 2012 Share Posted August 11, 2012 Hello, When ever i use this code, even if i add a number to the argument gaID, it always says "Usage: /garage (Garage ID)". function garageOpenOrClose(sourcePlayer, gaID) --Open Verdeant Meadows garage local gaID = tonumber(gaID) if(gaID) then if(type(gaID ) == "number") then if gaID < 0 or gaID > 49 then if not isGarageOpen(gaID) then setGarageOpen(gaID, true) outputChatBox("Garage opened!", sourcePlayer) else setGarageOpen(gaID, false) outputChatBox("Garage closed!", sourcePlayer) end end end else outputChatBox("Usage: /garage (Garage ID)", sourcePlayer, 255, 0, 0) end end Please help. Link to comment
Castillo Posted August 11, 2012 Share Posted August 11, 2012 Because the second argument of addCommandHandler is the command used. function garageOpenOrClose(sourcePlayer, gaID) should be: function garageOpenOrClose(sourcePlayer, command, gaID) Link to comment
stormchaser206 Posted August 11, 2012 Author Share Posted August 11, 2012 Still didn't work Link to comment
Castillo Posted August 11, 2012 Share Posted August 11, 2012 function garageOpenOrClose ( sourcePlayer, command, gaID ) --Open Verdeant Meadows garage local gaID = tonumber ( gaID ) if ( gaID ) then if ( gaID > 0 and gaID < 50 ) then local state = ( not isGarageOpen ( gaID ) ) setGarageOpen ( gaID, state ) outputChatBox ( "Garage ".. ( state and "opened" or "closed" ) .."!", sourcePlayer ) end else outputChatBox ( "Usage: /garage (Garage ID)", sourcePlayer, 255, 0, 0 ) end end addCommandHandler ( "garage", garageOpenOrClose ) That works. Link to comment
stormchaser206 Posted August 11, 2012 Author Share Posted August 11, 2012 function garageOpenOrClose ( sourcePlayer, command, gaID ) --Open Verdeant Meadows garage local gaID = tonumber ( gaID ) if ( gaID ) then if ( gaID > 0 and gaID < 50 ) then local state = ( not isGarageOpen ( gaID ) ) setGarageOpen ( gaID, state ) outputChatBox ( "Garage ".. ( state and "opened" or "closed" ) .."!", sourcePlayer ) end else outputChatBox ( "Usage: /garage (Garage ID)", sourcePlayer, 255, 0, 0 ) end end addCommandHandler ( "garage", garageOpenOrClose ) That works. Thanks 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