Jump to content

Limiting a command value


Forrest

Recommended Posts

Upon fail, or typing no value it doesn't output the syntax etc anymore.

It's kicking out ".lua:26: attempt to compare number with nil"

Current script

function llChange ( me, command, ll ) 
    if (exports.global:isPlayerAdmin(me)) then 
    ll = tonumber ( ll ) 
    local veh = getPedOccupiedVehicle ( me ) 
    if ll > 0.1 or ll < -0.45 then 
    outputChatBox ( "Don't be a twat", me, 255, 0, 0 ) 
    return 
    end 
    if ll and veh then  
        local success = setVehicleHandling ( veh, "suspensionLowerLimit", ll ) 
  
        if success then 
            outputChatBox ( "The vehicle's lower limit has been changed to: "..ll..".", me, 0, 255, 0 ) 
        else 
            outputChatBox ( "Changing lower limit failed. You're probably using an invalid limit.", me, 255, 0, 0 ) 
        end 
    elseif not veh then 
        outputChatBox ( "You're not in a vehicle", me, 255, 0, 0 ) 
    elseif not ll then 
        outputChatBox ( "Syntax: /sll [0.1 to -0.45]", me, 255, 0, 0 ) 
    end 
end 
end 
addCommandHandler ( "sll", llChange ) 

Link to comment
  • Moderators

Note: don't destroy your tabs, else it will be unclear for everybody.

  
function llChange ( me, command, ll ) 
    if (exports.global:isPlayerAdmin(me)) then 
        ll = tonumber ( ll ) 
        local veh = getPedOccupiedVehicle ( me ) 
        if ll and veh then 
            if ll > 0.1 or ll < -0.45 then 
                outputChatBox ( "Don't be a twat", me, 255, 0, 0 ) 
                return 
            end 
            local success = setVehicleHandling ( veh, "suspensionLowerLimit", ll ) 
            if success then 
                outputChatBox ( "The vehicle's lower limit has been changed to: ".. ll ..".", me, 0, 255, 0 ) 
            else 
                outputChatBox ( "Changing lower limit failed. You're probably using an invalid limit.", me, 255, 0, 0 ) 
            end 
        elseif not veh then 
            outputChatBox ( "You're not in a vehicle", me, 255, 0, 0 ) 
        elseif not ll then 
            outputChatBox ( "Syntax: /sll [0.1 to -0.45]", me, 255, 0, 0 ) 
        end 
    end 
end 
addCommandHandler ( "sll", llChange ) 
  
  

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