murilo2929 Posted February 26, 2020 Posted February 26, 2020 148/5000 I have a car customization system, and when I enter the marker to customize some elements of the hud do not appear and these errors happen: Part of the code that contains error 867 addEventHandler("onClientKey", root, function(key, pressed) if panelState and enteredVehicle then if pressed then if key == "arrow_d" and not promptDialog["state"] and tuningCompleted then arrowFel = false --[[if szorzas <= maxRowsPerPage then szorzas = szorzas + 1 else szorzas = maxRowsPerPage end]] if #loopTable <= 4 then --- 867 line if szorzas ~= 4 then lastTick2 =getTickCount() end end if #loopTable > 4 then if szorzas ~= 8 then lastTick2 =getTickCount() end end if hoveredCategory > #loopTable or hoveredCategory == #loopTable then hoveredCategory = #loopTable else if hoveredCategory > maxRowsPerPage then currentPage = currentPage + 1 end hoveredCategory = hoveredCategory + 1 Function that appear the 1988 error function formatNumber(amount, spacer) if not spacer then spacer = "," end amount = math.floor(amount) --- 1988 error line local left, num, right = string.match(tostring(amount), "^([^%d]*%d)(%d*)(.-)$") return left .. (num:reverse():gsub("(%d%d%d)", "%1" .. spacer):reverse()) .. right end what can be?
murilo2929 Posted February 26, 2020 Author Posted February 26, 2020 15 minutes ago, -ffs-PLASMA said: loopTable doesnt exist or has no data. weird because looptable exist
The_GTA Posted February 26, 2020 Posted February 26, 2020 32 minutes ago, murilo2929 said: weird because looptable exist I don't want to be the guy to spot the obvious, but: in Lua, loopTable is a different variable than looptable because variable names are case-sensitive. Could you make sure you spelled "looptable" correctly in your code? --- About the second error, I cannot decipher the cause because you are not showing the code that called the function "formatNumber".
murilo2929 Posted February 26, 2020 Author Posted February 26, 2020 so I was checking everything here and I realized that if I change "amount" to some number it works all but there is only that number. function formatNumber(amount, spacer) if not spacer then spacer = "," end amount = math.floor(100) --- I edited the amount to 100 and now it works but the prices are all 100 (aesthetically). local left, num, right = string.match(tostring(amount), "^([^%d]*%d)(%d*)(.-)$") return left .. (num:reverse():gsub("(%d%d%d)", "%1" .. spacer):reverse()) .. right end
The_GTA Posted February 26, 2020 Posted February 26, 2020 (edited) 3 hours ago, murilo2929 said: so I was checking everything here and I realized that if I change "amount" to some number it works all but there is only that number. function formatNumber(amount, spacer) if not spacer then spacer = "," end amount = math.floor(100) --- I edited the amount to 100 and now it works but the prices are all 100 (aesthetically). local left, num, right = string.match(tostring(amount), "^([^%d]*%d)(%d*)(.-)$") return left .. (num:reverse():gsub("(%d%d%d)", "%1" .. spacer):reverse()) .. right end Dear murilo2929, 1) either "fix" the code by using the following function: function formatNumber(amount, spacer) if not spacer then spacer = "," end if not amount then amount = 0 end amount = math.floor(amount) local left, num, right = string.match(tostring(amount), "^([^%d]*%d)(%d*)(.-)$") return left .. (num:reverse():gsub("(%d%d%d)", "%1" .. spacer):reverse()) .. right end 2) or post your entire code as attachment so we can search for the formatNumber error. - Martin Edited February 26, 2020 by The_GTA disambiguation
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