A rather odd error that we cant figure out :(

I just joined today, and we ran out of ideas for this error so I thought I would go create an account on here, but this error is something me and my friend can’t figure out. We are working on a kind of the hill gamemode and this comes up when we try to create the hill.

[ERROR] lua/includes/extensions/entity.lua:269: bad argument #2 to '__index' (number expected, got userdata)
  1. __index - [C]:-1
   2. SetRadius - lua/includes/extensions/entity.lua:269
    3. unknown - gamemodes/koth/gamemode/init.lua:71
     4. unknown - lua/includes/modules/concommand.lua:54

here’s the code that we think is causing the error

concommand.Add( "SpawnThatDankKOTHShit", function( pl, cmd, args )

	if ( table.getn( args ) < 1 ) then
		pl:PrintMessage( HUD_PRINTCONSOLE, "Invalid number of arguments. Bitch." )
	local x = tonumber( args[1] )
	local y = tonumber( args[2] )
	local z = tonumber( args[3] )
	if ( x == nil || y == nil || z == nil ) then
		pl:PrintMessage( HUD_PRINTCONSOLE, "Invalid x, y or z axis. Or your just gay." )
	local ent = ents.Create( "koth_point" )
	ent:SetPos( pl:GetPos() )
	ent:SetAngles( pl:GetAngles() )
	ent:SetRadius( Vector( x, y, z ) )

end )

more specifically, the local ent = ents.Create and in there, there line that says ent:SetRadius. removing it stops the error, but i get the same error but on the client when the entity is created.

[editline]15th October 2016[/editline]

Oh, here’s the code on the client that has to do with this

	function GM:PostDrawOpaqueRenderables( bDrawingDepth, bDrawingSkybox )

		local points = ents.FindByClass( "koth_point" )
		for _, point in pairs( points ) do
		render.DrawBox( point:GetPos(), point:GetAngles(), Vector( 0, 0, 0 ), point:GetRadius(), Color( 255, 0, 0 ) )

I’m guessing SetRadius is supposed to be a number and not a vector. Check your SetupDataTables code for the entity

ok thanks! well take a look

Need to see the entity code. One of the NetworkVars fails


[editline]15th October 2016[/editline]


Either that isn’t the code causing it or that’s the wrong entity code.

the code you want is the one copied from the base entity, right? or do you want the entity.lua, which the error says its coming from

I mean in that code Radius is defined as a Vector NWVar – the error you’re getting shouldn’t be happening under the code conditions you provided.

Could i get a Pastebin from entity.lua so i can find the line number the error points to?


the error is on the server, and for this gamemode i have init.lua, shared, cl_init, and koth_point.lua, which is the entity.

I cannot reproduce the error with given code.

Try restarting your game.

in the error it says 3. unknown - gamemodes/koth/gamemode/init.lua:71

line 71 on init.lua is ent:SetArea( Vector( x, y, z ) )

[editline]15th October 2016[/editline]

weve tried to figure it out for about a day now. ill try again, but ill link 4 pastebins to the init, shared, cl_init, and koth_point

That’s the first mention of SetArea. What are you even?

actually, ill link you to the entire gamemode file. rar file.

[editline]15th October 2016[/editline]

the setarea is going to be a red box which defines the area of the hill visually, so its not invisible for players. however, its not the first mention, its in the original post
"more specifically, the local ent = ents.Create and in there, there line that says ent:SetRadius. removing it stops the error, but i get the same error but on the client when the entity is created.

Can you put it up on GitHub? I personally can’t get it with uni internet

I got no error launching the gamemode. Maybe it’s an addon conflict?


[editline]15th October 2016[/editline]

oooooooh sorry, to cause the error, type SpawnThatDankKOTHShit (3 numbers, like 500 500 500)

and no my addons are disabled

[editline]15th October 2016[/editline]


so is this the error you’re trying to fix?

[ERROR] gamemodes/koth/gamemode/init.lua:71: attempt to call method 'SetArea' (a nil value)
  1. unknown - gamemodes/koth/gamemode/init.lua:71
   2. unknown - lua/includes/modules/concommand.lua:54

If so, the reason would be because you never created a function called SetArea, as it says