Jump to content

Help please fast


Nahar

Recommended Posts

function chatDis(command) 
        cancelEvent() 
        outputChatBox("THE CHAT IS DISABLED",source,255,0,0) 
    if hasObjectPermissionTo ( command, "function.banPlayer" ) then 
        addEventHandler("onPlayerChat",getRootElement(),chatDis) 
end end 
  
function chatEN(command) 
    if hasObjectPermissionTo ( command, "function.banPlayer" ) then 
    outputChatBox("THE CHAT IS NOW ENABLED ",getRootElement(),255,0,0) 
        removeEventHandler("onPlayerChat",getRootElement(),chatDis) 
end end 
  
addCommandHandler("cd",chatDis) 
addCommandHandler("ce",chatEN) 
  

How i can add there that it work only for the team spectators? i mean when i write ./ce no one can write in the chat even admins. how i can add like admins can talk and others cant.

Link to comment
function disableChat() 
    if getTeamName(getPlayerTeam(source)) == "Spectators" then 
        cancelEvent() 
        outputChatBox("THE CHAT IS DISABLED",source,255,0,0) 
    end 
end 
  
function toggleChat(player,cmd) 
    if hasObjectPermissionTo ( player, "function.banPlayer" ) then 
        if cmd == "cd" then 
            addEventHandler("onPlayerChat",getRootElement(),disableChat) 
            outputChatBox("THE CHAT IS NOW ENABLED ",getRootElement(),255,0,0) 
        elseif cmd == "ce" then 
            removeEventHandler("onPlayerChat",getRootElement(),disableChat) 
        end 
    end 
end 
addCommandHandler("cd",toggleChat) 
addCommandHandler("ce",toggleChat) 

Link to comment

simple way to enable/disable the chat;

local isDisabled = false; 
  
addEventHandler ( "onPlayerChat", root, 
    function ( message, messageType ) 
        if ( messageType == 0 ) then 
            if ( isDisabled ) then 
                if ( not hasObjectPermissionTo ( source, "function.banPlayer" ) ) then 
                    cancelEvent(); 
                    outputChatBox ( "The chat is currently disabled", source ); 
                end 
            elseif ( getPlayerTeam ( source ) and getTeamName ( getPlayerTeam ( source ) ) == "Spectators" ) then 
                cancelEvent(); 
                outputChatBox ( "You're not allowed to talk", source ); 
            end 
        end 
    end 
); 
  
addCommandHandler ( "cd", 
    function ( thePlayer, cmd ) 
        if ( hasObjectPermissionTo ( thePlayer, "function.banPlayer" ) ) then 
            isDisabled = not isDisabled; 
            outputChatBox ( "The chat has been ".. ( isDisabled and "disabled" or "enabled" ) .." by ".. getPlayerName ( thePlayer ) ); 
        end 
    end 
); 

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...