Killing a player in a specified space.

[lua]
local meta = FindMetaTable( “Player” );

function meta:IsInBox( min, max )
local Result = ents.FindInBox( min, max );
for k,v in pairs( Result ) do
if( v && ValidEntity( v ) && v:IsPlayer() ) then
return true;
else
return false;
end
end
end

function KickDoucheBags1()
for k,v in pairs( player.GetAll() ) do
if( ValidEntity( v ) ) then
if v:IsInBox( Vector(1768,-146,268), Vector(1552,-739,538 ) ) then
v:KillSilent()
v:Spawn()
end
end
end
end
concommand.Add( “killdouches”, KickDoucheBags1() )
[/lua]

Can someone tell me why the KickDoucheBags1 function isn’t working? I just can’t figure it out! It is supposed to kill a player inside the box ( Vector(1768,-146,268), Vector(1552,-739,538 ) ), but it seems the function got an error. The command pops up in the console, but when i enter it, it just tells me it’s a unknown command.

Your IsInBox function is completely wrong as it will return true for all players if the first player to join is in the area, false if otherwise.

if( v && ValidEntity( v ) && v:IsPlayer() ) then

should be

if( v && ValidEntity( v ) && v == self ) then

really. and with no return false in the loop.

[lua]
local meta = FindMetaTable( “Player” );

function meta:IsInBox( min, max )
local Result = ents.FindInBox( min, max );
for k,v in pairs( Result ) do
if( v && ValidEntity( v ) && v == self ) then
return true;
end
end
end

function KickDoucheBags1()
for k,v in pairs( player.GetAll() ) do
if( ValidEntity( v ) ) then
if v:IsInBox( Vector(1768,-146,268), Vector(1552,-739,538 ) ) then
v:KillSilent()
v:Spawn()
end
end
end
end
concommand.Add( “killdouches”, KickDoucheBags1() )
[/lua]

Same thing, it just won’t work.

Add some debug text? Does the concommand exist? Also for concommand.Add it should be “KickDouchBags1” without the brackets.

A simple thing like that can mess up my code so much! Is was the brackets! Thankyou!