Jump to content

[HELP] attempt to perform arithmetic on a nil value


Recommended Posts

function getHourlyRentalCost(vehicle)
	local payment
	local _vehicle
	
	if isElement(vehicle) then
		_vehicle = getElementModel(vehicle)
	else
		_vehicle = vehicle
	end
	
	payment = math.floor(exports.vehicles:getVehicleCost(_vehicle) / 333) or 0
	if (payment > MAX_HR_PAYMENT) then payment = MAX_HR_PAYMENT end
	
	return payment
end

 

attempt to perform arithmetic on a nil value

Edited by 99isme
Link to post
exports.vehicles:getVehicleCost(_vehicle) / 333

maybe do like

 

(exports.vehicles:getVehicleCost(_vehicle) or 0) / 333

Either way, make sure that it returns something, that error means the vehicle price you retrieved is nil.

Link to post

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