----------------------------
-- CakeScript (March 29, 2008)
-- by LuaBanana
--
-- Alpha Version
-- util.lua
--
-- *******NOTE********
-- remember to add any new commands here to the table of commands in cl_adminMenu.lua
--
----------------------------

-- DONT REMOVE MAH STEAMID. EVAR.
SuperAdmins = {
--"STEAM_0:1:5947214" removed, wat now
};

Admins = {
};

function IsConsole( ent )
	
	if(ent:EntIndex() == 0) then return true; end
	return false;
	
end


function ccKick(ply, cmd, args)

	if( IsConsole(ply) or ply:IsAdmin() or ply:IsSuperAdmin()  ) then
	
		if( args[1] == nil ) then
		
			CAKE.Notify(ply, "Format: admin_kick <name> <reason> put the reason in quotes." );
			return;
			
		end
		
		local target = nil;
		if( string.match( args[1], "STEAM" ) != nil ) then
		
			target = CAKE.SearchForPlayer(2, args[1]);
			
		else
		
			target = CAKE.SearchForPlayer(1, args[1]);
		
		end

		if(target != nil and target != "err") then -- Target found, is player
			
			game.ConsoleCommand("kickid " .. target:UserID() .. "\"Kicked (" .. ply:Name() .. ": " .. (args[2] or "kicked") .. ")\"\n");
		
		elseif(target == nil) then -- Target was not found
		
			CAKE.Notify(ply, "Cannot find target!");
			
		elseif(target == "err") then -- More than one player of the same name
		
			CAKE.Notify(ply, "Multiple targets selected!");
			
		end
	
	end

end
concommand.Add("admin_kick", ccKick);

function ccBan(ply, cmd, args)

	if( IsConsole(ply) or ply:IsAdmin() or ply:IsSuperAdmin() ) then
	
		if( args[1] == nil or args[2] == nil ) then
		
			CAKE.Notify(ply, "Format: admin_ban <name> <time> 0 for perma ban <optional reason>." );
			return;
			
		end
	
		if(!ply:IsSuperAdmin() and (tonumber(args[2]) > 10080 or tonumber(args[2]) == 0)) then
			CAKE.Notify(ply, "You cannot ban for more than 10080 (1 week) minutes!");
			return;
		end

		local target = nil;
		if( string.match( args[1], "STEAM" ) != nil ) then
		
			target = CAKE.SearchForPlayer(2, args[1]);
			
		else
		
			target = CAKE.SearchForPlayer(1, args[1]);
		
		end

		if(target != nil and target != "err") then -- Target found, is player
			
			game.ConsoleCommand("banid " .. args[2] .. " " .. target:UserID() .. "\n");
			game.ConsoleCommand("kickid " .. target:UserID() .. "\"Banned for " .. args[2] .. " minutes (" .. ply:Name() .. ": " .. (args[3] or "banned") .. ")\"\n");
			game.ConsoleCommand("writeid\n");
		
		elseif(target == nil) then -- Target was not found
		
			CAKE.Notify(ply, "Cannot find target!");
			
		elseif(target == "err") then -- More than one player of the same name
		
			CAKE.Notify(ply, "Multiple targets selected!");
			
		end
	
	end

end
concommand.Add("admin_ban", ccBan);
			
function ccSetMoney(ply, cmd, args)

	if( IsConsole(ply) or ply:IsAdmin() or ply:IsSuperAdmin() ) then
	
		if( args[1] == nil or args[2] == nil ) then
		
			CAKE.Notify(ply, "Format: admin_setmoney <name> <amount>" );
			return;
			
		end
	
		local target = CAKE.SearchForPlayer(1, args[1])
		
		if(target != nil and target != "err") then -- Target found, is player
			
			target:SetField("money", args[2]);
			CAKE.DayLog(ply .. " [" .. ply:SteamID() .. "] set " .. target:Name() .. " [" .. target:SteamID() .. "] money to " .. args[2]);
		
		elseif(target == nil) then -- Target was not found
		
			CAKE.Notify(ply, "Cannot find target!");
			
		elseif(target == "err") then -- More than one player of the same name
		
			CAKE.Notify(ply, "Multiple targets selected!");
			
		end
		
	end

end
concommand.Add("admin_setmoney", ccSetMoney);

function ccSetFlags(ply, cmd, args)

	-- ply:IsAdmin(), made it superadmin to reset someone's flag table
	if( IsConsole(ply) or ply:IsAdmin() or ply:IsSuperAdmin() ) then
	
		if( args[1] == nil or args[2] == nil ) then
		
			CAKE.Notify(ply, "Format: admin_setflags <name> <new flag table values> This overwrites all old flags." );
			return;
			
		end
	
		local target = CAKE.SearchForPlayer(1, args[1])
		
		if(target != nil and target != "err") then -- Target found, is player
		
			local flagtable = {}
			
			table.remove(args, 1)
			
			for k,v in pairs(args) do
			
				table.insert(flagtable, v);
				
			end
			
			target:SetField("flags", flagtable, true);
			
		elseif(target == nil) then -- Target was not found
		
			CAKE.Notify(ply, "Cannot find target!");
			
		elseif(target == "err") then -- More than one player of the same name
		
			CAKE.Notify(ply, "Multiple targets selected!");
			
		end
		
	end

end
concommand.Add("admin_setflags", ccSetFlags);

-- Add flags to target player's table
function ccAddFlag(ply, cmd, args)

	if( IsConsole(ply) or ply:IsAdmin() or ply:IsSuperAdmin() ) then
	
		if( args[1] == nil or args[2] == nil ) then
		
			CAKE.Notify(ply, "Format: admin_addflag <name> <Flag to add to table>" );
			return;
			
		end
	
		local target = CAKE.SearchForPlayer(1, args[1])
		
		if(target != nil and target != "err") then -- Target found, is player -- Target found, is player
	
			if(target != nil and target:IsPlayer()) then -- Target found, is player
	
				local flagtable = target:GetField("flags");
				
				-- either they don't have a table, or something bad happened, I hope its not something bad :x
				if( flagtable == nil ) then
					flagtable = {};
				end
			
				table.remove(args, 1)
			
				for k,v in pairs(args) do
			
					-- don't doubly insert flags, I don't know how that'll react, but it can't be good.
					-- and if an admin is setting random crap in here kick their ass
					if( !table.HasValue(flagtable, v ) ) then	
						table.insert(flagtable, v);
					end
				
				end
				
				target:SetField("flags", flagtable, true);
			
			end
			
		elseif(target == nil) then -- Target was not found
		
			CAKE.Notify(ply, "Cannot find target!");
			
		elseif(target == "err") then -- More than one player of the same name
		
			CAKE.Notify(ply, "Multiple targets selected!");
			
		end
		
	end

end
concommand.Add("admin_addflag", ccAddFlag);

function ccToolTrust(ply, cmd, args)

	if( IsConsole(ply) or ply:IsAdmin() or ply:IsSuperAdmin() ) then
	
		if( args[1] == nil or args[2] == nil ) then
		
			CAKE.Notify(ply, "Format: admin_tooltrust <name> <value>. 0 takes away, 1 gives." );
			return;
			
		end
	
		if(table.getn(args) > 2) then
		
			CAKE.Notify(ply, "Too many arguments given!");
			return;
			
		end;
		
		local target = CAKE.SearchForPlayer(1, args[1])
		
		if(target != nil and target != "err" and target:IsPlayer()) then -- Target found, is player
		
			target:SetAccField("tooltrust", args[2]);
			if(args[2] == "1") then
				target:Give("gmod_tool");
				target:SetAccField("tooltrust", args[2], true );
				CAKE.Notify(target, ply:GetName() .. " gave you tooltrust!");
			elseif(args[2] == "0") then
				target:StripWeapon("gmod_tool");
				target:SetAccField("tooltrust", args[2], true );
				CAKE.Notify(target, ply:GetName() .. " took away your tooltrust!");
			end
			
		elseif(target == nil) then -- Target was not found
		
			CAKE.Notify(ply, "Cannot find target!");
			
		elseif(target == "err") then -- More than one player of the same name
		
			CAKE.Notify(ply, "Multiple targets selected!");
			
		end
		
	end
	
end
concommand.Add("admin_tooltrust", ccToolTrust);

function ccSetTeam(ply, cmd, args)

	if( IsConsole(ply) or ply:IsAdmin() or ply:IsSuperAdmin() ) then
	
		if( args[1] == nil or args[2] == nil ) then
		
			CAKE.Notify(ply, "Format: admin_setteam <name> <teamNumber> Really shouldn't be using this..." );
			return;
			
		end
	
		local target = CAKE.SearchForPlayer(1, args[1])
		
		if(target != nil and target != "err" and target:IsPlayer()) then -- Target found, is player
		
			target:SetTeam(tonumber(args[2]))
			target:Spawn();
			
		elseif(target == nil) then -- Target was not found
		
			CAKE.Notify(ply, "Cannot find target!");
			
		elseif(target == "err") then -- More than one player of the same name
		
			CAKE.Notify(ply, "Multiple targets selected!");
			
		end
		
	end
	
end
concommand.Add("admin_setteam", ccSetTeam);

function ccDoorOwner(ply, cmd, args)

	if(ply:IsAdmin() or ply:IsSuperAdmin()) then
	
		local tr = ply:GetEyeTrace()
		local trent = tr.Entity;
	
		if(!CAKE.IsDoor(trent)) then 
			CAKE.Notify(ply, "Not a door."); 
			return;
		else
			CAKE.Notify(ply, "Owner is: " .. trent:GetNWString("owner"));
		end
		
	end
end
concommand.Add("admin_findowner", ccDoorOwner);

function ccUnownDoor(ply, cmd, args)

	if(ply:IsAdmin() or ply:IsSuperAdmin()) then
	
		local tr = ply:GetEyeTrace()
		local trent = tr.Entity;
	
		if(!CAKE.IsDoor(trent)) then 
			CAKE.Notify(ply, "Not a door."); 
			return;
		else
			CAKE.AdminLog(ply:Name() .. " [" .. ply:SteamID() .. "] forcibly unowned door " .. args[1]);
			trent:SetNWString("owner", "");
			CAKE.Notify(ply, "Door forcibly unowned.");
		end
		
	end

end
concommand.Add("admin_unowndoor", ccUnownDoor);

function ccListTT(ply, cmd, args)

	if( IsConsole(ply) or ply:IsAdmin() or ply:IsSuperAdmin() ) then
	
		CAKE.Notify(ply, "Listing all players and their TT value to your console.");
		
		for k, v in pairs(player.GetAll()) do
		
			ply:PrintMessage( HUD_PRINTCONSOLE, v:Name() .. " [" .. v:SteamID() .. "] : " .. v:GetAccField("tooltrust") );
		
		end
	
	end

end
concommand.Add("admin_getTT", ccListTT);

function ccAddMoney(ply, cmd, args)

	if( IsConsole(ply) or ply:IsAdmin() or ply:IsSuperAdmin() ) then
	
		if( args[1] == nil or args[2] == nil ) then
		
			CAKE.Notify(ply, "Format: admin_addmoney <name> <amount>" );
			return;
			
		end
	
		local target = CAKE.SearchForPlayer(1, args[1])
		
		if(target != nil and target != "err") then -- Target found, is player
		
			local newmoney = tonumber( args[2] );
			local oldmoney = tonumber( target:GetField("money") );
			
			target:SetField("money", tostring( newmoney + oldmoney ) );
			CAKE.Notify(ply, "Player given money: " .. args[2] );
			CAKE.Notify(target, ply:Name() .. " gave you money: " .. tostring( newmoney + oldmoney ));
			
			CAKE.AdminLog(ply:Name() .. " [" .. ply:SteamID() .. "] added " .. args[2] .. " money to " .. target:Name() .. " [" .. target:SteamID() .. "]");
		
		elseif(target == nil) then -- Target was not found
		
			CAKE.Notify(ply, "Cannot find target!");
			
		elseif(target == "err") then -- More than one player of the same name
		
			CAKE.Notify(ply, "Multiple targets selected!");
			
		end
		
	end

end
concommand.Add("admin_addmoney", ccAddMoney);

function ccConSay( ply, cmd, args )

	if( !IsConsole(ply) ) then 
		return; 
	end

	local msg = "";

	for n = 1, #args do
	
		msg = msg .. args[n] .. " ";
	
	end
	
	CAKE.SendChat( false, "Console AT SEND: " .. msg, 1, Vector(0,0,0) );

end
concommand.Add( "consay", ccConSay );
concommand.Add( "csay", ccConSay );
concommand.Add( "cs", ccConSay );

function ccSetPlayerModel( ply, cmd, args )
	
	if( IsConsole(ply) or ply:IsAdmin() or ply:IsSuperAdmin() ) then
	
		if( args[1] == nil or args[2] == nil ) then
		
			CAKE.Notify(ply, "Format: admin_setplayermodel <name> <mdl>" );
			return;
			
		end
	
		local target = CAKE.SearchForPlayer(1, args[1])
		
		if(target != nil and target != "err") then -- Target found, is player
		
			target:SetModel(string.lower(args[2]));
			target:SetField("info.model", args[2]);
			CAKE.Notify(ply, "Model set to: " .. args[2]);
			CAKE.Notify(target, ply:Name() .. " set your model to: " .. args[2]);
			
			CAKE.AdminLog(ply:Name() .. " [" .. ply:SteamID() .. "] set " .. target:Name() .. " [" .. target:SteamID() .. "] model to " .. args[2]);
		
		elseif(target == nil) then -- Target was not found
		
			CAKE.Notify(ply, "Cannot find target!");
			
		elseif(target == "err") then -- More than one player of the same name
		
			CAKE.Notify(ply, "Multiple targets selected!");
			
		end
		
	end

end
concommand.Add( "admin_setplayermodel", ccSetPlayerModel );

function ccSetDefaultModel( ply, cmd, args )

	if( IsConsole(ply) or ply:IsAdmin() or ply:IsSuperAdmin() ) then
	
		if( args[1] == nil or args[2] == nil ) then
		
			CAKE.Notify(ply, "Format: admin_setdefaultmodel <name> <mdl>" );
			return;
			
		end
	
		local target = CAKE.SearchForPlayer(1, args[1])
		
		if(target != nil and target != "err") then -- Target found, is player

			target:SetField("defaultModel", args[2]);
			CAKE.Notify(ply, "Target model set to: " .. args[2]);
			CAKE.Notify(target, ply:Name() .. " set your default model to: " .. args[2]);
			
			CAKE.AdminLog(ply:Name() .. " [" .. ply:SteamID() .. "] set " .. target:Name() .. " [" .. target:SteamID() .. "] default model to " .. args[2]);
		
		elseif(target == nil) then -- Target was not found
		
			CAKE.Notify(ply, "Cannot find target!");
			
		elseif(target == "err") then -- More than one player of the same name
		
			CAKE.Notify(ply, "Multiple targets selected!");
			
		end
		
	end

end
concommand.Add( "admin_setdefaultmodel", ccSetDefaultModel );

-- Utility function for bring goto and send
-- copied from ULX
local function playerSend( from, to, force )
	if not to:IsInWorld() and not force then return false end -- No way we can do this one

	local yawForward = to:EyeAngles().yaw
	local directions = { -- Directions to try
		math.NormalizeAngle( yawForward - 180 ), -- Behind first
		math.NormalizeAngle( yawForward + 90 ), -- Right
		math.NormalizeAngle( yawForward - 90 ), -- Left
		yawForward,
	}

	local t = {}
	t.start = to:GetPos() + Vector( 0, 0, 32 ) -- Move them up a bit so they can travel across the ground
	t.filter = { to, from }

	local i = 1
	t.endpos = to:GetPos() + Angle( 0, directions[ i ], 0 ):Forward() * 47 -- (33 is player width, this is sqrt( 33^2 * 2 ))
	local tr = util.TraceEntity( t, from )
    while tr.Hit do -- While it's hitting something, check other angles
    	i = i + 1
    	if i > #directions then  -- No place found
			if force then
				return to:GetPos() + Angle( 0, directions[ 1 ], 0 ):Forward() * 47
			else
				return false
			end
		end

		t.endpos = to:GetPos() + Angle( 0, directions[ i ], 0 ):Forward() * 47

		tr = util.TraceEntity( t, from )
    end

	return tr.HitPos
end

function ccGotoPlayer( ply, cmd, args )

	if(ply:IsAdmin() or ply:IsSuperAdmin()) then

		if( args[1] == nil ) then
		
			CAKE.Notify(ply, "Format: admin_goto <name>" );
			return;
			
		end
	
		local target = CAKE.SearchForPlayer(1, args[1])
		
		if(target != nil and target != "err") then -- Target found, is player

			local newpos = playerSend( ply, target, ply:GetMoveType() == MOVETYPE_NOCLIP )
		
			if not newpos then
				CAKE.Notify( ply, "Can't find a place to put you! Noclip and use this command to force a goto." );
				return;
			end

			local newang = (target:GetPos() - newpos):Angle();

			ply:SetPos( newpos );
			ply:SetEyeAngles( newang );
			ply:SetLocalVelocity( Vector( 0, 0, 0 ) ); -- Stop!
			
			CAKE.AdminLog(ply:Name() .. " [" .. ply:SteamID() .. "] went to " .. target:Name() .. " [" .. target:SteamID() );
			
		elseif(target == nil) then -- Target was not found
		
			CAKE.Notify(ply, "Cannot find target!");
			
		elseif(target == "err") then -- More than one player of the same name
		
			CAKE.Notify(ply, "Multiple targets selected!");
			
		end
	
	end

end
concommand.Add( "admin_goto", ccGotoPlayer );

function ccBringPlayer( ply, cmd, args )

	if(ply:IsAdmin() or ply:IsSuperAdmin()) then

		if( args[1] == nil ) then
		
			CAKE.Notify(ply, "Format: admin_goto <name>" );
			return;
			
		end
	
		local target = CAKE.SearchForPlayer(1, args[1])
		
		if(target != nil and target != "err") then -- Target found, is player

			local newpos = playerSend( target, ply, target:GetMoveType() == MOVETYPE_NOCLIP )
		
			if not newpos then
				CAKE.Notify( ply, "Can't find a place to put them!" );
				return;
			end

			local newang = (ply:GetPos() - newpos):Angle();

			target:SetPos( newpos );
			target:SetEyeAngles( newang );
			target:SetLocalVelocity( Vector( 0, 0, 0 ) ); -- Stop!
			
			CAKE.AdminLog(ply:Name() .. " [" .. ply:SteamID() .. "] brought " .. target:Name() .. " [" .. target:SteamID() );
			
		elseif(target == nil) then -- Target was not found
		
			CAKE.Notify(ply, "Cannot find target!");
			
		elseif(target == "err") then -- More than one player of the same name
		
			CAKE.Notify(ply, "Multiple targets selected!");
			
		end
	
	end

end
concommand.Add( "admin_bring", ccBringPlayer );

-- disable noclipping
function DisableNoclip( ply, cmd, args ) 
 	
 	if( ply:IsAdmin() or ply:IsSuperAdmin() ) then
 	
 		if ( ply:GetMoveType() == MOVETYPE_WALK ) then
 		
			ply:SetMoveType( MOVETYPE_NOCLIP );
			ply:SetNotSolid(true);
			
		elseif ( ply:GetMoveType() == MOVETYPE_NOCLIP ) then
		
			ply:SetMoveType( MOVETYPE_WALK );
			ply:SetNotSolid(false);
			
		end
		
	end
 	
 	return false;
 	 
end 
concommand.Add("admin_noclip", DisableNoclip);
hook.Add("PlayerNoClip", "DisableNoclip", DisableNoclip);

function ccSlay( ply, cmd, args )

	if( IsConsole(ply) or ply:IsAdmin() or ply:IsSuperAdmin() ) then

		if( args[1] == nil ) then
		
			CAKE.Notify(ply, "Format: admin_slay <name>" );
			return;
			
		end

		local target = CAKE.SearchForPlayer(1, args[1])
		
		if(target != nil and target != "err") then -- Target found, is player
		
			target:Kill();
			CAKE.SendChat( false, ply:Name() .. " slayed " .. target:Name(), 1, Vector(0,0,0) );
			CAKE.AdminLog(ply:Name() .. " [" .. ply:SteamID() .. "] slayed " .. target:Name() .. " [" .. target:SteamID() );
			
		elseif(target == nil) then -- Target was not found
		
			CAKE.Notify(ply, "Cannot find target!");
			
		elseif(target == "err") then -- More than one player of the same name
		
			CAKE.Notify(ply, "Multiple targets selected!");
			
		end
	end

end
concommand.Add("admin_slay", ccSlay);

function ccSlap( ply, cmd, args )

	if( IsConsole(ply) or ply:IsAdmin() or ply:IsSuperAdmin() ) then

		if( args[1] == nil ) then
		
			CAKE.Notify(ply, "Format: admin_slap <name>" );
			return;
			
		end

		local target = CAKE.SearchForPlayer(1, args[1])
		
		if(target != nil and target != "err") then -- Target found, is player

			local norm = target:GetAngles():Up();
			target:SetVelocity( norm * 500 + target:GetAngles():Forward() * math.random( -1000, 1000 ) );
			target:SetHealth( math.Clamp( target:Health() - 5, 1, 1000 ) );
			
			CAKE.SendChat( false, ply:Name() .. " slapped " .. target:Name(), 1, Vector(0,0,0) );
			CAKE.AdminLog(ply:Name() .. " [" .. ply:SteamID() .. "] slapped " .. target:Name() .. " [" .. target:SteamID() );
			
		elseif(target == nil) then -- Target was not found
		
			CAKE.Notify(ply, "Cannot find target!");
			
		elseif(target == "err") then -- More than one player of the same name
		
			CAKE.Notify(ply, "Multiple targets selected!");
			
		end
	end

end
concommand.Add("admin_slap", ccSlap);

function ccSetTitle(ply, cmd, args)

	if( IsConsole(ply) or ply:IsAdmin() or ply:IsSuperAdmin() ) then

		if( args[1] == nil ) then
		
			CAKE.Notify(ply, "Format: admin_settitle <name> <title>" );
			return;
			
		end

		local target = CAKE.SearchForPlayer(1, args[1])
		
		if(target != nil and target != "err") then -- Target found, is player

			if(string.len( args[2] ) > 33) then
	
				CAKE.Notify(ply, "Job title is too long! Max 32 characters");
				return;
		
			end
	
			target:SetField("info.job", args[2]);
			
			CAKE.Notify( ply, "Title set to: " .. args[2] );
			CAKE.Notify( target, ply:Name() .. " set your title to: " .. args[2] );
			CAKE.AdminLog(ply:Name() .. " [" .. ply:SteamID() .. "] set " .. target:Name() .. " [" .. target:SteamID() .. " title to: " .. args[2] );
			
		elseif(target == nil) then -- Target was not found
		
			CAKE.Notify(ply, "Cannot find target!");
			
		elseif(target == "err") then -- More than one player of the same name
		
			CAKE.Notify(ply, "Multiple targets selected!");
			
		end
	end

end
concommand.Add("admin_settitle", ccSetTitle);

function ccObserve(ply, cmd, args)

	if( ply:IsAdmin() or ply:IsSuperAdmin() ) then
	
		if( ply:GetNWBool("cloaked") == false ) then
		
			ply:GodEnable();
			ply:SetNoTarget(true);
			ply:SetNWBool("cloaked", true);
			ply:SetNoDraw( true );
			
			ply:SetNotSolid( true );
			ply:SetMoveType( 8 );
			
			if( ply:GetActiveWeapon() ) then
				ply:GetActiveWeapon():SetNoDraw( true );
			end
			
			local fx = EffectData();
			fx:SetOrigin( ply:GetShootPos()+ply:GetAimVector()*10 );
			fx:SetEntity( ply );
			util.Effect( "sodan_cloak",fx, true );
			
		else
		
			ply:GodDisable();
			ply:SetNoTarget(false);
			ply:SetNWBool("cloaked", false);
			ply:SetNoDraw( false );
			
			ply:SetNotSolid( false );
			ply:SetMoveType( 2 );
			
			if( ply:GetActiveWeapon() ) then
				ply:GetActiveWeapon():SetNoDraw( false );
			end
			
			local fx = EffectData();
			fx:SetOrigin( ply:GetShootPos()+ply:GetAimVector()*10 );
			fx:SetEntity( ply );
			util.Effect( "sodan_cloak",fx, true );
		
		end
	
	end
	
end
concommand.Add("admin_observe", ccObserve);

function ccResetMap( ply, cmd, args )

	if( IsConsole(ply) or ply:IsAdmin() or ply:IsSuperAdmin() ) then

		CAKE.SendChat( false, ply:Name() .. " is restarting the map in 1 minute.", 1, Vector(0,0,0) );
	
		timer.Simple( 60, game.ConsoleCommand, "changelevel " .. game.GetMap() .. "\n" );
	end

end
concommand.Add( "admin_restartmap", ccResetMap );


function ccCreateItem(ply, cmd, args)
	if(ply:IsAdmin() or ply:IsSuperAdmin()) then
		-- Drop the item 80 units infront of him.

		CAKE.CreateItem(args[1], ply:CalcDrop(), Angle(0,0,0));
		
	end
end
concommand.Add("admin_createitem", ccCreateItem);

function ccSendItems(ply, cmd, args)

	if( not(ply:IsAdmin() or ply:IsSuperAdmin())) then
		return;
	end

	for k, v in pairs( ItemData ) do
	
		umsg.Start("AddAdminItem",ply);
			umsg.String(k);
			umsg.String(v.Name);
			umsg.String(v.Model);
			umsg.String(v.Class);
			umsg.String(v.Description);
		umsg.End();
	
	end
	
	-- done sending items, recall their menu, aren't I nice?
	umsg.Start("openAdminMenu",ply);
	umsg.End();

end
concommand.Add("admin_getItems", ccSendItems);

-- edits their seeall NW bool which will effect people's info on screen range in cl_hud.lua
-- lucky for us, unset NW items return false for Bools :D
local function ccSeeAllPeople(ply, cmd, args)

	if( ply:IsAdmin() or ply:IsSuperAdmin() ) then
	
		if( ply:GetNWBool("seeall") ) then
			ply:SetNWBool("seeall", false );
		else
			ply:SetNWBool("seeall", true );
		end
	
	end

end
concommand.Add("admin_seeall", ccSeeAllPeople);

function ccSetOOC(ply, cmd, args)

	if( IsConsole(ply) or ply:IsAdmin() or ply:IsSuperAdmin() ) then
	
		if( args[1] != nil ) then
		
			CAKE.SetOOCDelay( args[1] );
			CAKE.Notify(ply,"OOC delay set to: " .. tonumber(args[1]));
		
		else
			CAKE.Notify(ply,"Format: admin_ooc <time>");
		end
	
	end

end
concommand.Add("admin_ooc", ccSetOOC);

function ccAllowOOC( ply, cmd, args )

	if( IsConsole(ply) or ply:IsAdmin() or ply:IsSuperAdmin() ) then
	
		if( args[1] != nil ) then
		
			if( args[1] == 1 ) then
			
				CAKE.AllowDynamicOOC( true );
				CAKE.Notify(ply, "Dynamic OOC adjustment enabled.");
			
			else
			
				CAKE.AllowDynamicOOC( false );
				CAKE.Notify(ply, "Dynamic OOC adjustment disabled.");
			
			end
		
		else
			CAKE.Notify(ply,"Format: admin_ooc_enable <0 or 1>");
		end
	
	end

end
concommand.Add("admin_ooc_enable", ccAllowOOC);


/* ANIMATION HAND FIXING CODE
function incrementAnim(ply, cmd, args)

	AnimationsAdjustment = AnimationsAdjustment + 1;

end
concommand.Add("animUp", incrementAnim);

function decrementAnim(ply, cmd, args)

	AnimationsAdjustment = AnimationsAdjustment - 1;

end
concommand.Add("animDown", decrementAnim);

function printAnim(ply, cmd, args)

Msg("Original value: " .. AnimationSequence .. "\n");
Msg("Animation adjustment: " .. AnimationsAdjustment .. "\n");

end
concommand.Add("getAnim", printAnim);

function setAnimValue(ply, cmd, args)

	if( args[1] == nil ) then
		return;
	end

	AnimationsAdjustment = tonumber(args[1]);

end
concommand.Add("setAnim", setAnimValue);
*/