Jump to content

Errors with multiple argument command


Recommended Posts

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
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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...