General > Developers Corner
Random Script errors (read before presuming please)
DankNessProvides:
I am making a HUD which is now complete and working fine no problems but in single line of code I am getting the error "cl_hud.lua:703: attempt to concatenate a nil value"
--- Code: --- draw.DrawText ( "$" .. LocalPlayer():getDarkRPVar( "money" ), "Trebuchet24", ScrW() / 3 + 85, ScrH () - 110, Color(255,255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP)
--- End code ---
The error doesn't effect anything but just creates a bunch of script errors with the same error over and over again all I am looking for is a quick answer as to why this code might be creating script errors as I cannot for the life of me figure this out
Bytewave:
--- Code: ---LocalPlayer():getDarkRPVar( "money" )
--- End code ---
is nil somehow. Only thing that's being concatenated.
DankNessProvides:
--- Quote from: Bytewave on April 09, 2016, 08:34:46 PM ---
--- Code: ---LocalPlayer():getDarkRPVar( "money" )
--- End code ---
is nil somehow. Only thing that's being concatenated.
--- End quote ---
That's what is confusing me it just giving me a random error and it's just irritating to see that.
Buzzkill:
Why do you assume its random? Take the error at face value. As ByteWave said, the only thing getting concatenated there is the "money" var value to a literal dollar sign. So... I would start by confirming that LocalPlayer():getDarkRPVar("money") is or is not truly null when it throws the error, by adding a print statement (or your debugging method of choice) immediately before the concat call.
If these errors occur during or immediately after initial spawn, I would assume that the vars haven't fully initialized yet. You should probably be testing and trapping null values.
Promptitude:
Try checking if the car actually exists before you execute that code, if it doesn't, bail. As its in the hud paint hook it'll just not draw the money until it's not nil.
Navigation
[0] Message Index
[#] Next page
Go to full version