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.
[CODE][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[/CODE]
here's the code that we think is causing the error[CODE]concommand.Add( "SpawnThatDankKOTHShit", function( pl, cmd, args )
if ( table.getn( args ) < 1 ) then
pl:PrintMessage( HUD_PRINTCONSOLE, "Invalid number of arguments. Bitch." )
return
end
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." )
return
end
local ent = ents.Create( "koth_point" )
ent:SetPos( pl:GetPos() )
ent:SetAngles( pl:GetAngles() )
ent:SetRadius( Vector( x, y, z ) )
ent:Spawn()
ent:Activate()
end )[/CODE]
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[CODE] 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 ) )
end[/CODE]
I'm guessing SetRadius is supposed to be a number and not a vector. Check your SetupDataTables code for the entity
[QUOTE=code_gs;51207745]I'm guessing SetRadius is supposed to be a number and not a vector. Check your SetupDataTables code for the entity[/QUOTE]
ok thanks! well take a look
Need to see the entity code. One of the NetworkVars fails
sure!
[editline]15th October 2016[/editline]
[url]http://hastebin.com/icehoyuqob.lua[/url]
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?
[QUOTE=Lawlypops;51207946]Could i get a Pastebin from entity.lua so i can find the line number the error points to?[/QUOTE]
sure
[url]http://pastebin.com/DYePdvcT[/url]
[QUOTE=Lawlypops;51207946]Could i get a Pastebin from entity.lua so i can find the line number the error points to?[/QUOTE]
[url]https://github.com/garrynewman/garrysmod/blob/master/garrysmod/lua/includes/extensions/entity.lua[/url]
[QUOTE=code_gs;51207945]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.[/QUOTE]
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]
[QUOTE=Robotboy655;51207956]I cannot reproduce the error with given code.
Try restarting your game.[/QUOTE]
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.
[url]https://www.dropbox.com/s/iw7uyaw7g7351i1/koth.7z?dl=0[/url]
[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?
[QUOTE=code_gs;51207982]Can you put it up on GitHub? I personally can't get it with uni internet[/QUOTE]
sure!
[editline]15th October 2016[/editline]
[QUOTE=Lawlypops;51207991]I got no error launching the gamemode. Maybe it's an addon conflict?[/QUOTE]
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]
[QUOTE=code_gs;51207982]Can you put it up on GitHub? I personally can't get it with uni internet[/QUOTE]
np
so is this the error you're trying to fix?
[CODE]
[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
[/CODE]
If so, the reason would be because you never created a function called SetArea, as it says
i dont have it installed, ive never used it before. this will take a minute.
[editline]15th October 2016[/editline]
[QUOTE=Lawlypops;51208004]so is this the error you're trying to fix?
[CODE]
[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
[/CODE]
If so, the reason would be because you never created a function called SetArea, as it says[/QUOTE]
hm...oh i see, friend said that is a value. change it to SetRadius
[editline]15th October 2016[/editline]
ooooh...
eh
heh
my uh friend said
you never renamed Radius to Area in the entity
so uh, i guess its fixed
[editline]15th October 2016[/editline]
nevertheless, thanks everyone for the help :)
After doing that, i get this (No Error):
I removed the image because it was much bigger than i thought it would be
[editline]15th October 2016[/editline]
Well, if it's fixed the good luck finishing it!
Sorry, you need to Log In to post a reply to this thread.