Two questions

I’m using my gamemode which is a highly modified DarkRP, when opening the F4 Menu I get flooded with the message;
[lua]
[lua\includes\extensions\math.lua:207] attempt to perform arithmetic on local ‘num’ (a nil value)
[[/lua]

Yet everything on the menu works perfectly?

Also, each time you level up you receive +100HP, when on level two your hp will display as ‘%200’, although once you reach level 3 your HP is 300 yet the HP bar is displayed as ‘%100’?

Show your code maybe?

Fixed the 2nd problem, and what piece of code do you want, I don’t know whats causing this.

lua\includes\extensions\ doesn’t exist.

It exists in the GCF, http://glua.me/bin/
Check what function is at that row, look where you’re running that function, see if there’s any problem.

He’s trying to use a operator on a number that doesn’t exit. I’m assuming this is an addon that hasn’t been looked over.

Found his problem :
[lua]
function math.Round(num, idp)

local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult

end
[/lua]
You are using a nil number in a round function “somewhere”.

So an addon, this isn’t actually in my gamemode? - Checking it over now.

I have no addons, this is the only math.Round I have in my gamemode.

[lua]
local ep = math.Round((e / em) * 100);

Line 235: local Border = math.Min(6, math.pow(2, math.Round(3*DrawHealth)))

Line 239: draw.DrawText(math.Max(0, math.Round(LocalPlayer():Health())), "TargetID", RelativeX + 4 + (HUDWidth - 8)/2, RelativeY - 32, ConVars.HealthText, 1)

Line 252: 	local Border = math.Min(6, math.pow(2, math.Round(3*DrawArmor)))

Line 258: 		draw.DrawText(math.Max(0, math.Round(Armor)).."", "TargetID", RelativeX + 4 + (HUDWidth - 8)/2, RelativeY - 3, Color( 255, 255, 255 ), 1)

[/lua]

Thanks for trying to help guys.

What is e and em?

[lua]
local e = LocalPlayer():GetNWInt(“experience”);
local em = LocalPlayer():GetNWInt(“maxexperience”);[/lua]

One of those is nil because the NWInt Doesn’t exist for it/them.

…Shit

Both of them do exist?, This is so frustrating, add me on steam man ‘glow2008’

Can I just say this gamemode worked fine before garry’s updates.

  • Still not fixed, multiple have tried, all have failed.

Comment out each of those lines (and make a temporary replacement) and uncomment them one by one untill the error comes up. Now you’ve located the line, look up all the variables it uses, make sure they are not nil. If they are nil, and you can’t do anything about it in any other place, use the “or” operator:
[lua]
e = e or 0
[/lua]
If e is nil, e will become 0. Meaning it will never be nil.

Will try this as soon as I get home, thanks for the help mate.

Not sure but would it be better to do this going by your example:
[lua]
local e = LocalPlayer():GetNWInt(“experience”) or 0;
local em = LocalPlayer():GetNWInt(“maxexperience”) or 0;
[/lua]

Yeah you’re right, I was just showing him a solution.
It’s better getting something to work and understand what it does, so you know where else to use it, than microoptimizations.

Alright I was just checking wasn’t sure if that’s what you meant by your example.

Have tried changing them, and searched for any nils, nothing.

If anyone wants to help out,

That’s my cl_hud.lua which contains that code.

Where is LocalPlayer():GetNWInt(“experience”) coming from it’s not include inside of DarkRP so it has to be an addon. You sure you don’t have any addons? It would only be returning nil because it isn’t being set to a certain number when the player joins. Then the cl_hud is trying to draw something that isn’t a number. Use [lua] [/lua] around code btw :stuck_out_tongue: