
local function RadioW( ply, cmd, text )

	local res, i, x, y = ply:HasItem( "radio" )

	if( not res ) then
		ply:PrintMessage( 3, "You don't have a radio!" );
		return;
	end
	
	if( math.floor( ply:GetField( "radiofreq" ) ) == 0 ) then
	
		ply:PrintMessage( 3, "0.0 is not a valid radio frequency." );
		return;
	
	end
	
	if( ply:GetField( "radiofreq" ) < 0 or ply:GetField( "radiofreq" ) > 999.9) then
	
		ply:PrintMessage( 3, "Invalid radio frequency." );
		return;
	
	end
	
	TS.TalkToFreq( ply:GetField( "radiofreq" ), ply:GetRPName() .. " [WHISPER]:" .. text, false );
	ply:WhisperLocalChat( text )
	
	return;

end
TS.ChatCmd( "/wr", RadioW );
TS.ChatCmd( "/rw", RadioW );
TS.ChatCmd( "/rwhisper", RadioW );

local function RadioY( ply, cmd, text )

	local res, i, x, y = ply:HasItem( "radio" )

	if( not res ) then
		ply:PrintMessage( 3, "You don't have a radio!" );
		return;
	end
	
	if( math.floor( ply:GetField( "radiofreq" ) ) == 0 ) then
	
		ply:PrintMessage( 3, "0.0 is not a valid radio frequency." );
		return;
	
	end
	
	if( ply:GetField( "radiofreq" ) < 0 or ply:GetField( "radiofreq" ) > 999.9) then
	
		ply:PrintMessage( 3, "Invalid radio frequency." );
		return;
	
	end
	
	TS.TalkToFreq( ply:GetField( "radiofreq" ), ply:GetRPName() .. " [YELL]:" .. text, false );
	ply:YellLocalChat( text )

	return;

end
TS.ChatCmd( "/yr", RadioY );
TS.ChatCmd( "/ry", RadioY );
TS.ChatCmd( "/ryell", RadioY );

local function crRadio( ply, cmd, text )

	local res, i, x, y = ply:HasItem( "crradio" )

	if( not res ) then
		ply:PrintMessage( 3, "You don't have a request device!" );
		return;
	end
	
	TS.TalkToFreq( TS.CombineRadioFreq, ply:GetRPName() .. " [REQUEST]:" .. text, true );
	ply:SayLocalChat( text )
	
	return;

end
TS.ChatCmd( "/cr", crRadio );
TS.ChatCmd( "/combinerequest", crRadio );
TS.ChatCmd( "/911", crRadio );
TS.ChatCmd( "/999", crRadio );

local function Radio( ply, cmd, text )

	local res, i, x, y = ply:HasItem( "radio" )

	if( not res ) then
		ply:PrintMessage( 3, "You don't have a radio!" );
		return
	end
	
	if( math.floor( ply:GetField( "radiofreq" ) ) == 0 ) then
	
		ply:PrintMessage( 3, "0.0 is not a valid radio frequency." );
		return
	
	end
	
	if( ply:GetField( "radiofreq" ) < 0 or ply:GetField( "radiofreq" ) > 999.9 ) then
	
		ply:PrintMessage( 3, "Invalid radio frequency." );
		return
	
	end
	
	if( res ) then
	
		TS.TalkToFreq( ply:GetField( "radiofreq" ), ply:GetRPName() .. ":" .. text, false );
		ply:SayLocalChat( text )
		
		
	end	
	


end
TS.ChatCmd( "/r", Radio );
TS.ChatCmd( "/radio", Radio );

local function RadioDispatch( ply, cmd, text )

	local res, i, x, y = ply:HasItem( "radio" )

	if( not res ) then
		ply:PrintMessage( 3, "You don't have a radio!" );
		return;
	end
	
	if( math.floor( ply:GetField( "radiofreq" ) ) == 0 ) then
	
		ply:PrintMessage( 3, "0.0 is not a valid radio frequency." );
		return;
	
	end
	
	if( ply:GetField( "radiofreq" ) < 0 or ply:GetField( "radiofreq" ) > 999.9) then
	
		ply:PrintMessage( 3, "Invalid radio frequency." );
		return;
	
	end
	
	TS.TalkToFreq( ply:GetField( "radiofreq" ),"(Dispatch) " .. text, false );

	
	for k, v in pairs( player.GetAll() ) do 	
		if( v:IsCombineDefense() ) then
			local num = math.random( 1, 3 );
			v:EmitSound( Sound( "npc/combine_soldier/vo/off" .. num .. ".wav", 55, 100 ) );
		end
	end	
	
	return;

end
TS.ChatCmd( "/rd", RadioDispatch );


local function ooc( ply, cmd, text )

	
	if( CurTime() < ply:GetTable().NextTimeCanChatOOC and not ply:CanUseCommand() ) then 
		return;
	end

	if( TS.OOCDelay > 0 and not ply:CanUseCommand() ) then
	
		umsg.Start( "SNCTOOC", ply );
			umsg.Float( TS.OOCDelay );
		umsg.End();
	
		ply:GetTable().NextTimeCanChatOOC = CurTime() + TS.OOCDelay;
	
	end

	return text;

end
TS.ChatCmd( "/ooc", ooc );
TS.ChatCmd( "//", ooc );
TS.ChatCmd( "/a", ooc );

local function title( ply, cmd, text )
	
	if( not string.find( text, " " ) ) then return; end
	
	text = string.gsub( text, "\n", "" );
	text = string.gsub( text, "\r", "" );
	
	if( string.len( text ) > 35 ) then
	
		text = string.sub( text, 1, 35 );
	
	end
	
	ply:SetNWString( "title", string.sub( text, 2 ) );
	ply:SetPlayerTitle( string.sub( text, 2 ) );
	ply:PrintMessage( 3, "Title changed to " .. string.sub( text, 2 ) );
	
	cmd = "UPDATE `TS2Characters` SET `Title` = '" .. string.sub( text, 2 ) .. "' WHERE `RPName` = '" .. ply:GetRPName() .. "'" 
	sql.Query( cmd );
	
end
TS.ChatCmd( "/title", title );

TS.CIDs = { }

local function ccSetCID( ply, cmd, text )
	
	if( ply:IsCombineDefense() ) then
		Console( ply, "You need to be citizen!", true )
		return
	end

	if( not string.find( text, " " ) ) then return end
	
	if( string.find( text, tonumber( 1337 ) ) ) then 
		Console( ply, "Can't have this number as a CID", true )
		return;
	end
	
	text = string.gsub( text, "\n", "" )
	text = string.gsub( text, "\r", "" )
	
	if( string.len( text ) > 6 ) then
		text = string.sub( text, 1, 6 )
	end
	
	if( TS.CIDIsTaken( string.sub( text, 2 ) ) ) then
		Console( ply, "CID already taken", true )		
		return 	
	end
	
	ply:SetNWFloat( "CID", string.sub( text, 2 ) )
	table.insert( TS.CIDs, string.sub( text, 2 ) )
	
	ply:SaveData( "CID", string.sub( text, 2 ) );
	
	Console( ply, "Set CID to " .. ply:GetNWFloat( "CID" ), true )
	
end
TS.ChatCmd( "/cid", ccSetCID )	
	
local function ccSecondTitle( ply, cmd, text )
	
	if( not string.find( text, " " ) ) then return; end
	
	text = string.gsub( text, "\n", "" );
	text = string.gsub( text, "\r", "" );
	
	if( string.len( text ) > 35 ) then
	
		text = string.sub( text, 1, 35 );
	
	end
	
	ply:SetNWString( "secondtitle", string.sub( text, 2 ) );
	ply:SetPlayerSecondTitle( string.sub( text, 2 ) );
	ply:PrintMessage( 3, "Second Title changed to " .. string.sub( text, 2 ) );
	
	cmd = "UPDATE `TS2Characters` SET `SecondTitle` = '" .. string.sub( text, 2 ) .. "' WHERE `RPName` = '" .. ply:GetRPName() .. "'" 
	sql.Query( cmd );
	
end
TS.ChatCmd( "/title2", ccSecondTitle );

local function getup( ply, cmd, text )

	if( not ply:GetPlayerConscious() and ply:GetPlayerConsciousness() >= 45 ) then
	
		ply:Conscious();
	
	end

end
TS.ChatCmd( "/getup", getup );

local function passout( ply, cmd, text )

	ply:SetPlayerConsciousness( 0 )
	
end
TS.ChatCmd( "/passout",	passout )

local function ccSetClassMark( ply, cmd, text )

	if( not ply:Alive() or not ply:GetPlayerConscious() ) then
		return;
	end
	
	if( !ply:IsCombine() ) then
		Console( ply, "Need to be CP", true )
		return
	end	

	local trace = { }
	trace.start = ply:EyePos();
	trace.endpos = trace.start + ply:GetAimVector() * 90;
	trace.filter = ply;
	
	local tr = util.TraceLine( trace );
	
	local ValidMarks = { "A", "B", "C", "D", "E", "F" }
	
	if( !tr.Entity and !tr.Entity:IsValid() and !tr.Entity:IsPlayer() ) then
		Console( ply, "You're not looking at anyone!", true )
		return
	end	
	
	if( tr.Entity and tr.Entity:IsValid() and tr.Entity:IsPlayer() ) then
	
		tr.Entity:SetPlayerClassMark( text )
		tr.Entity:SaveData( "ClassMark", text )
		
		umsg.Start( "ICAction", tr.Entity );
			umsg.String( ply:GetRPName() );
			umsg.String( " set your classmark to " .. text );
		umsg.End();	

		umsg.Start( "ICAction", ply );
			umsg.String( "You" );
			umsg.String( " set " .. tr.Entity:GetRPName() .. " class mark to " .. text )
		umsg.End();	
	
	end
	
end
TS.ChatCmd( "/setcm", ccSetClassMark );

local function ccSetClassStatus( ply, cmd, text )

	if( not ply:Alive() or not ply:GetPlayerConscious() ) then
		return;
	end
	
	if( !ply:IsCombine() ) then
		Console( ply, "Need to be CP", true )
		return
	end	

	local trace = { }
	trace.start = ply:EyePos();
	trace.endpos = trace.start + ply:GetAimVector() * 90;
	trace.filter = ply;
	
	local tr = util.TraceLine( trace );
	
	if( !tr.Entity and !tr.Entity:IsValid() and !tr.Entity:IsPlayer() ) then
		Console( ply, "You're not looking at anyone!", true )
		return
	end	
	
	if( tr.Entity and tr.Entity:IsValid() and tr.Entity:IsPlayer() ) then
	
		tr.Entity:SetPlayerClassStatus( text )
		tr.Entity:SaveData( "ClassStatus", text )
		
		umsg.Start( "ICAction", tr.Entity );
			umsg.String( ply:GetRPName() );
			umsg.String( " set your Class Status to " .. text );
		umsg.End();	

		umsg.Start( "ICAction", ply );
			umsg.String( "You" );
			umsg.String( " set " .. tr.Entity:GetRPName() .. " class status to " .. text )
		umsg.End();	
	
	end
	
end
TS.ChatCmd( "/setcs", ccSetClassStatus );
		
local function givemoney( ply, cmd, text )

	if( not ply:Alive() or not ply:GetPlayerConscious() ) then
		return;
	end
	
	local val = tonumber( text )
	
	if( not val ) then return; end
	
	if( not ply:CanAfford( val ) ) then
		return;
	end
	
	local trace = { }
	trace.start = ply:EyePos();
	trace.endpos = trace.start + ply:GetAimVector() * 90;
	trace.filter = ply;
	
	local tr = util.TraceLine( trace );
	
	if( tr.Entity and tr.Entity:IsValid() and tr.Entity:IsPlayer() ) then
	
		tr.Entity:GiveMoney( val );
		ply:TakeMoney( val );
		
		local plur = "s";
		
		if( val == 1 ) then
			plur = "";
		end
	
		umsg.Start( "ICAction", tr.Entity );
			umsg.String( ply:GetRPName() );
			umsg.String( " gave you " .. val .. " credit" .. plur );
		umsg.End();	

		umsg.Start( "ICAction", ply );
			umsg.String( "You" );
			umsg.String( " gave " .. tr.Entity:GetRPName() .. " " .. val .. " credit" .. plur );
		umsg.End();	
	
	end
	
end
TS.ChatCmd( "/give", givemoney );
TS.ChatCmd( "/givemoney", givemoney );
TS.ChatCmd( "/givecredits", givemoney );

local function givehonor( ply, cmd, text )

	if( not ply:Alive() or not ply:GetPlayerConscious() ) then
		return;
	end
	
	local val = tonumber( text )
	
	if( not val ) then return; end
	
	if( not ply:EnoughHonor( val ) ) then
		return;
	end
	
	local trace = { }
	trace.start = ply:EyePos();
	trace.endpos = trace.start + ply:GetAimVector() * 90;
	trace.filter = ply;
	
	local tr = util.TraceLine( trace );
	
	if( tr.Entity and tr.Entity:IsValid() and tr.Entity:IsPlayer() ) then
	
		tr.Entity:GiveHonor( val );
		ply:TakeHonor( val );
		
		local plur = "s";
		
		if( val == 1 ) then
			plur = "";
		end
	
		umsg.Start( "ICAction", tr.Entity );
			umsg.String( ply:GetRPName() );
			umsg.String( " awarded you " .. val .. " Honor Credit" .. plur );
		umsg.End();	

		umsg.Start( "ICAction", ply );
			umsg.String( "Awarded " .. tr.Entity:GetRPName() .. " " .. val .. " Honor Credit" .. plur );
		umsg.End();	
	
	end
	
end
TS.ChatCmd( "/givehonor", givehonor );

local function yell( ply, cmd, text )

	ply:YellLocalChat( text );	

end
TS.ChatCmd( "/y", yell );
TS.ChatCmd( "/yell", yell );

local function whisper( ply, cmd, text )

	ply:WhisperLocalChat( text );

end
TS.ChatCmd( "/w", whisper );
TS.ChatCmd( "/whisper", whisper );

local function broadcast( ply, cmd, text )

	if( not ply:IsCombine() ) then return; end
	
	PrintMessage( 2, ply:GetRPName() .. " (" .. ply:Nick() .. ") broadcasted" )
	
	for k, v in pairs( player.GetAll() ) do
		umsg.Start( "msgBroadcast", v );
			umsg.String( ply:GetRPName() )
			umsg.String( " (Broadcast):" .. text )
		umsg.End();	
	end
	
end
TS.ChatCmd( "/bc", broadcast );
TS.ChatCmd( "/broadcast", broadcast );

local function event( ply, cmd, text )

	if( not ply:CanUseCommand() ) then return; end
	
	for k, v in pairs( player.GetAll() ) do
		umsg.Start( "msgEv", v );
			umsg.String( "(Event)" .. text );
		umsg.End();	
	end
	
end
TS.ChatCmd( "/event", event );
TS.ChatCmd( "/ev", event );

local function advert( ply, cmd, text )

	PrintMessage( 2, ply:GetRPName() .. " (" .. ply:Nick() .. ") advertised" )
	
	for k, v in pairs( player.GetAll() ) do
		umsg.Start( "msgAdv", v );
			umsg.String( "*** [ADVERT]:" .. text .. " ***"  );
		umsg.End();	
	end
	
end
TS.ChatCmd( "/adv", advert );
TS.ChatCmd( "/advert", advert );

local function dispatch( ply, cmd, text )

	if( not ply:IsCombine() ) then return; end

	
	PrintMessage( 2, ply:GetRPName() .. " (" .. ply:Nick() .. ") sent out a dispatch" )
	for k, v in pairs( player.GetAll() ) do
		umsg.Start( "msgDispatch", v );
					umsg.String( "(DISPATCH):" .. text );
		umsg.End();	
	end

	
end
TS.ChatCmd( "/dp", dispatch );
TS.ChatCmd( "/dispatch", dispatch );

local function looc( ply, cmd, text )

	ply:SayLocalOOCChat( "[LOCAL-OOC] " .. text );

end
TS.ChatCmd( "/looc", looc );
TS.ChatCmd( "[[", looc );
TS.ChatCmd( ".//", looc );	

local function me( ply, cmd, text )

	ply:DoICAction( text );

end
TS.ChatCmd( "/me", me );

local function tapdance( ply, cmd, text )

	ply:DoICAction( " tap dances" );

end
TS.ChatCmd( "/tapdance", tapdance );

local function write( ply, cmd, text )

	local res, i, x, y = ply:HasItem( "paper" );
	
	if( res ) then

		ply:GetTable().SelectedPaper = { Inv = i, x = x, y = y };

		umsg.Start( "LWP", ply );
			umsg.String( text );
		umsg.End();
		
	end

end
TS.ChatCmd( "/write", write );

local function adminmsg( ply, cmd, text )

	for k, v in pairs( player.GetAll() ) do
		if( v:CanUseCommand() ) then

			umsg.Start( "AdminMessage", v );
				umsg.String( ply:GetRPName() .. " (" .. ply:Nick() .. ") to admins:" .. text );
			umsg.End();

			v:PrintMessage( 2, ply:GetRPName() .. " (" .. ply:Nick() .. ") to admins:" .. text );

		end

	end
	
	if( not ply:CanUseCommand() ) then
		
		umsg.Start( "AdminMessage", ply );
			umsg.String( ply:GetRPName() .. " (" .. ply:Nick() .. ") to admins:" .. text );
		umsg.End();

		ply:PrintMessage( 2, ply:GetRPName() .. " (" .. ply:Nick() .. ") to admins:" .. text );
		
	end
	
end
TS.ChatCmd( "!a", adminmsg );
TS.ChatCmd( "/admin", adminmsg );
TS.ChatCmd( "!admin", adminmsg );

local function adminmsg( ply, cmd, text )

	umsg.Start( "OIFYMessage", v );
		umsg.String( ply:Nick() .. ":" .. text .. " also cocks" );
	umsg.End();
	
end
TS.ChatCmd( "/oify", adminmsg );
TS.ChatCmd( "/o", adminmsg );

local function pm( ply, cmd, text )

	if( not string.find( text, " " ) or not string.find( string.sub( text, string.find( text, " " ) + 1 ), " " ) ) then return; end

	local namepos = string.find( text, " " ) + 1;
	local msgpos = string.find( string.sub( text, string.find( text, " " ) + 1 ), " " );

	local name = string.sub( text, namepos, msgpos );
	text = string.sub( text, msgpos + 1 );
	
	local succ, result = TS.FindPlayerByName( name );
	TS.ErrorMessage( ply, true, succ, result );
	
	if( succ ) then
	
		umsg.Start( "PrivateMessage", ply );
			umsg.String( "[PM TO " .. result:GetRPName() .. "]" .. text );
		umsg.End();
		
		umsg.Start( "PrivateMessage", result );
			umsg.String( "[PM FROM " .. ply:GetRPName() .. "]" .. text );
		umsg.End();
		
		ply:PrintMessage( 2, "[PM TO " .. result:GetRPName() .. "]" .. text );
		result:PrintMessage( 2, "[PM FROM " .. ply:GetRPName() .. "]" .. text );
	
	end

end
TS.ChatCmd( "/pm", pm );

local function it( ply, cmd, text )

	ply:SayICAction( text );

end
TS.ChatCmd( "/it", it );

local function lean( ply, cmd, text )

	if( ply:IsCombineDefense() ) then return; end
	ply:ConCommand( "rp_ic_lean\n" );
	
end
TS.ChatCmd( "/lean", lean );

local function sitground( ply, cmd, text )

	if( ply:IsCombineDefense() ) then return; end
	ply:ConCommand( "rp_ic_sitground\n" );
	
end
TS.ChatCmd( "/sitground", sitground );

local function stand( ply, cmd, text )

	if( ply:IsCombineDefense() ) then return; end
	if( ply:GetTable().InStanceAction ) then
		if( ply:GetTable().StanceGroundSit ) then
			ply:ConCommand( "rp_ic_sitground\n" );
		elseif( ply:GetTable().StanceSit  ) then
			ply:ConCommand( "rp_ic_sit\n" );
		end
	end
	
end
TS.ChatCmd( "/stand", stand );

local function sit( ply, cmd, text )

	if( ply:IsCombineDefense() ) then return; end
	ply:ConCommand( "rp_ic_sit " .. text .. "\n" );
	
end
TS.ChatCmd( "/sit", sit );

local function atw( ply, cmd, text )

	if( ply:IsCombine() ) then return; end
	ply:ConCommand( "rp_ic_atw " .. text .. "\n" );
	
end
TS.ChatCmd( "/atw", atw );

local function goto( ply, cmd, text )

	ply:ConCommand( "rpa_goto " .. text .. "\n" );

end
TS.ChatCmd( "!goto", goto );

local function bring( ply, cmd, text )

	ply:ConCommand( "rpa_bring " .. text .. "\n" );

end
TS.ChatCmd( "!bring", bring );

local function kick( ply, cmd, text )

	ply:ConCommand( "rpa_kick " .. text .. "\n" );

end
TS.ChatCmd( "!kick", kick );

local function slay( ply, cmd, text )

	ply:ConCommand( "rpa_slay " .. text .. "\n" );

end
TS.ChatCmd( "!slay", slay );

local function slap( ply, cmd, text )

	ply:ConCommand( "rpa_slap " .. text .. "\n" );

end
TS.ChatCmd( "!slap", slap );

local function ignite( ply, cmd, text )

	ply:ConCommand( "rpa_ignite " .. text .. "\n" );

end
TS.ChatCmd( "!ignite", ignite );

local function explode( ply, cmd, text )

	ply:ConCommand( "rpa_ext " .. text .. "\n" );

end
TS.ChatCmd( "!ext", explode );
TS.ChatCmd( "!extinguish", explode );

local function explode( ply, cmd, text )

	ply:ConCommand( "rpa_explode " .. text .. "\n" );

end
TS.ChatCmd( "!explode", explode );

local function bring( ply, cmd, text )

	ply:ConCommand( "rpa_ban " .. text .. "\n" );

end
TS.ChatCmd( "!ban", bring );

local function bring( ply, cmd, text )

	ply:ConCommand( "rpa_ban " .. text .. "\n" );

end
TS.ChatCmd( "!pban", bring );

local function scannertoggle( ply, cmd, text )

	if( not ply:IsCombine() ) then return; end
	
	local already = false
	for k, v in pairs( scnr.plyr ) do
		if v[1] == ply then
			already = true
		end
	end
	
	if already then
		ply:ConCommand( "eng_stopscanner\n" );
	else
		ply:ConCommand( "eng_scanner\n" );
	end

end
TS.ChatCmd( "/scanner", scannertoggle );


local VGSfx = 
{ 
	"vo/npc/vortigaunt/vortigese02.wav",
	"vo/npc/vortigaunt/vortigese03.wav",
	"vo/npc/vortigaunt/vortigese04.wav",
	"vo/npc/vortigaunt/vortigese05.wav",
	"vo/npc/vortigaunt/vortigese07.wav",
	"vo/npc/vortigaunt/vortigese08.wav",
	"vo/npc/vortigaunt/vortigese09.wav",
	"vo/npc/vortigaunt/vortigese11.wav",
	"vo/npc/vortigaunt/vortigese12.wav",
	"vo/npc/vortigaunt/vortigese13.wav",
}

local VGSfxText =
{
	"Aarrr Gla'hhh!",
	"Darr'ahhh.",
	"Doooottt.",
	"Lawnnng'ahh.",
	"Dawnghh'ahh!",
	"Gawlah'ahh!",
	"Daleh'Long!",
	"Juuurrr. Alleng'Jer, Alle Gan.",
	"Jurrrr, lonnn gawn... Shalah grahhh.",
	"Turrrr, lonn gurrr. Challlah chur. Gownnnn, Gon... Luuuuuuuuuur.",
}
	
local function vortigese( ply, cmd, text )
	
	if( ply:GetField( "playerflags" ) == "V" or ply:GetField( "playerflags" ) == "VE" ) then
	
		local wtftoplay = math.random( 1, table.getn(VGSfx) );
	
		ply:EmitSound( Sound( VGSfx[wtftoplay] ) );
		ply:DoICAction( " says, \"" .. VGSfxText[wtftoplay] .. "\" to his kin, only they understand it." );
	
		ply:VortLocalChat( text );
		
	end	
	
end
TS.ChatCmd( "/v", vortigese );

--[[Barrier Shizzle]]--
function BarrierType(ply, cmd, text)
	if( !ply:IsCombineDefense() ) then return end
	
	local num = tonumber( text );
	
	if num then
		barriertype = num;
		Console(ply, "[Shield Barrier] The barrier type has been set to ".. num ..".", true);
	else
		Console(ply, "[Shield Barrier] Please enter a number that is either 1 or 2.", true);
	end
end
TS.ChatCmd( "!barriertype", BarrierType );

function BarrierMake(ply, cmd, text)
	
	if( !ply:IsCombineDefense() ) then return end
	
	local trace = ply:GetEyeTrace();
	
	local first_vec = nil;
	local second_vec = nil;
	
	if !barrierStep or barrierStep == 2 then
		barrierStep = 1
		barrierpos = trace.HitPos
		Console(ply, "[Shield Barrier] Got first vector (".. tostring(trace.HitPos) ..")", true);
	else
		local firstpos  = barrierpos
		local secondpos = trace.HitPos
		
		local barrier = ents.Create("ts2_barrier");
		barrier:SetPos( barrierpos );
		
		if( barriertype )then
			Msg("(CMD) (".. type(barriertype) ..") Barrier Type: ".. barriertype .."\n");
			barrier:SetKeyValue( "type", barriertype );
		end
		
		barrier:SetNWVector( "MinVec", firstpos );
		barrier:SetNWVector( "MaxVec", secondpos );
		barrier:SetOwner( ply );
		barrier:Spawn();
		
		undo.Create("bam_barrier");
			undo.SetPlayer( ply );
			undo.AddEntity( barrier );
		undo.Finish();
		
		barrierStep = 2;
		
		Console(ply, "[Shield Barrier] Barrier has been made.", true);
	end
end
TS.ChatCmd( "!barrier", BarrierMake );

function GiveIDCard( ply, cmd, text )

	if( not ply:Alive() or not ply:GetPlayerConscious() ) then
		return;
	end
	
	local trace = { }
	trace.start = ply:EyePos();
	trace.endpos = trace.start + ply:GetAimVector() * 90;
	trace.filter = ply;
	
	local tr = util.TraceLine( trace );
	
	if( tr.Entity and tr.Entity:IsValid() and tr.Entity:IsPlayer() ) then
		
		local plur = "s";
		
		if( val == 1 ) then
			plur = "";
		end
	
		umsg.Start( "ICAction", tr.Entity );
			umsg.String( ply:GetRPName() );
			umsg.String( " gave you their ID Card." );
		umsg.End();	

		umsg.Start( "GIDC", tr.Entity );
			umsg.Short( ply:GetPlayerCID() );
			umsg.String( ply:GetRPName() );
			umsg.String( ply:GetModel() );
			umsg.Short( ply:GetPlayerAge() );
			umsg.Short( ply:GetPlayerCID() );
			umsg.String( ply:GetPlayerClassMark() );
		umsg.End();
		
		umsg.Start( "ICAction", ply );
			umsg.String( "You" );
			umsg.String( " gave " .. tr.Entity:GetRPName() .. " your ID Card." );
		umsg.End();	
	
	end
end
concommand.Add( "giveid", GiveIDCard );
TS.ChatCmd( "/giveid", GiveIDCard );

function GrabIDCard( ply, cmd, text )

	if( not ply:IsCombineDefense() ) then return; end

	if( not ply:Alive() or not ply:GetPlayerConscious() ) then
		return;
	end
	
	local trace = { }
	trace.start = ply:EyePos();
	trace.endpos = trace.start + ply:GetAimVector() * 90;
	trace.filter = ply;
	
	local tr = util.TraceLine( trace );
	
	if( tr.Entity and tr.Entity:IsValid() and tr.Entity:IsPlayer() ) then
		
		local plur = "s";
		
		if( val == 1 ) then
			plur = "";
		end
	
		umsg.Start( "ICAction", tr.Entity );
			umsg.String( ply:GetRPName() );
			umsg.String( " took your ID Card." );
		umsg.End();	

		umsg.Start( "GIDC", ply );
			umsg.Short( tr.Entity:GetPlayerCID() );
			umsg.String( tr.Entity:GetRPName() );
			umsg.String( tr.Entity:GetModel() );
			umsg.Short( tr.Entity:GetPlayerAge() );
			umsg.Short( tr.Entity:GetPlayerCID() );
			umsg.String( tr.Entity:GetPlayerClassMark() );
		umsg.End();
		
		umsg.Start( "ICAction", ply );
			umsg.String( "You" );
			umsg.String( " took " .. tr.Entity:GetRPName() .. "'s ID." );
		umsg.End();	
	
	end
end
concommand.Add( "grabid", GrabIDCard );
TS.ChatCmd( "/grabid", GrabIDCard );



	
	
