Jump to content

Class chat


jonas13362

Recommended Posts

  
TeamPlayer = {}; 
TeamPlayer.__index = TeamPlayer; 
  
ChatPlayer = {}; 
  
function TeamPlayer:Enter( player ) 
    if ( ChatPlayer[player] ) then 
        return; 
    end 
    local objector = {}; 
    objector.player = player; 
    objector.class = false; 
    _chatenter = function() objector:EnterChat() end; 
    _chatfunction = function( msg, type ) objector:Chat( msg, type ) end; 
     
    addCommandHandler("class", _chatenter); 
    addEventHandler("onPlayerChat", root, _chatfunction); 
     
     
    table.insert( ChatPlayer, objector.player ); 
    setmetatable( objector, self ); 
    return objector; 
end 
  
function TeamPlayer:EnterChat( ) 
    if ChatPlayer[self.player] then 
        self.class = true; 
    end 
end 
  
  
function TeamPlayer:Chat(msg) 
    if ( self.class ) then 
        cancelEvent() 
        for k, v in pairs( ChatPlayer ) do  
            outputChatBox(msg, v, 255, 255, 255 ) 
        end 
    end 
end 
  
function LeaveOutClassChat( player ) 
    for k, v in pairs( ChatPlayer ) do  
        if v == player then 
            table.remove( ChatPlayer, k ); 
        end 
    end 
    return true 
end 
addCommandHandler("leaveclass", LeaveOutClassChat) 
  
function enterInClassChat( player ) 
    TeamPlayer:Enter( player ); 
end 
addCommandHandler("enterclass", enterInClassChat) 
  

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...