/*
	Hack vs Hack: Redux
*/
-- Most of the stuff is shamelessly ripped from DarkRP --

-- Get player meta --
local plyMeta = FindMetaTable( "Player" )

function plyMeta:SetHVHVar( var, value )
	if !ValidEntity( self ) then return end
	
	self.HVHVars = self.HVHVars or {}
	self.HVHVars[var] = value
	
	umsg.Start( "hvh_plyvar" )
		umsg.Entity( self )
		umsg.String(var)
		
		if value == nil then value = "nil" end
		
		umsg.String( tostring( value ) )
	umsg.End()
end

local function SendHVHVars( ply )
        if ply.DarkRPVarsSent and ply.DarkRPVarsSent > (CurTime() - 1) then return end --prevent spammers
        ply.DarkRPVarsSent = CurTime()

        local sendtable = {}
        for k,v in pairs(player.GetAll()) do
                sendtable[v] = v.DarkRPVars
        end
        datastream.StreamToClients(ply, "DarkRP_InitializeVars", sendtable)
end
concommand.Add( "_sendHVHvars", SendHVHVars )