saluta Posted May 20, 2021 Posted May 20, 2021 How to fix this error addEventHandler("onClientGUIClick", resourceRoot, function() if (source == Grid_VS) then local carName = guiGridListGetItemText(Grid_VS, guiGridListGetSelectedItem(Grid_VS), 1) local carID = getVehicleModelFromNewName(carName) or getVehicleModelFromName(carName) local c1, c2, c3, c4 = unpack(vehicleSpeeds[carID]) guiSetText(cLbl[1], "Stoke. speed: "..c1.." km/h.") guiSetText(cLbl[2], "Max. speed: "..c2.." km/h.") guiSetText(cLbl[3], "Acceleration 0-100 for "..c3.." s.") guiSetText(cLbl[4], "Drive unit: "..c4..".") end end) Spoiler https://imgur.com/a/MWIAKr5 photo
Moderators IIYAMA Posted May 20, 2021 Moderators Posted May 20, 2021 1 hour ago, saluta said: How to fix this error You should first check if the table exist. If not, fill in the blanks. local blankValue = "-" local c1, c2, c3, c4 = blankValue, blankValue, blankValue, blankValue local speedData = vehicleSpeeds[carID] if speedData then c1, c2, c3, c4 = unpack(speedData) end guiSetText(cLbl[1], "Stoke. speed: "..c1.." km/h.") guiSetText(cLbl[2], "Max. speed: "..c2.." km/h.") guiSetText(cLbl[3], "Acceleration 0-100 for "..c3.." s.") guiSetText(cLbl[4], "Drive unit: "..c4..".") Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
saluta Posted May 21, 2021 Author Posted May 21, 2021 12 hours ago, IIYAMA said: You should first check if the table exist. If not, fill in the blanks. local blankValue = "-" local c1, c2, c3, c4 = blankValue, blankValue, blankValue, blankValue local speedData = vehicleSpeeds[carID] if speedData then c1, c2, c3, c4 = unpack(speedData) end guiSetText(cLbl[1], "Stoke. speed: "..c1.." km/h.") guiSetText(cLbl[2], "Max. speed: "..c2.." km/h.") guiSetText(cLbl[3], "Acceleration 0-100 for "..c3.." s.") guiSetText(cLbl[4], "Drive unit: "..c4..".") Thank you so much, low bow. 1
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