Jump to content

Staffchat


marty000123

Recommended Posts

Posted

Hey guys

I'm looking for a chat where only people from the ACL group ''Staff'' can talk in.

They can only use the chat, and they can only read the chat.

I'd like to get the command /s (staffchat).

The reason is that it's annoying to start up the staff panel and press Admin Chat to talk with staff only.

That's why I'm requesting this chat command.

Thanks in advance!

Marty

(Please tell me if it's client sided or server! ;) )

Posted

First of all; it's a server sided script. No need to do this client sided, there's actually no easy way to do this. You'll have to set data if someone is staff or not and all that crap.

To make it easy, just create a loop trough all the players and see if they are in the ACL group "staff", then output the message. To use the command, they should also be in the group. A small example;

addCommandHandler ( "staffchat", 
    fuction ( thePlayer, _, ... ) 
        if ( isObjectInACLGroup ( thePlayer, "staff" ) ) then 
            for i, p in ipairs ( getElementsByType ( "player" ) ) do 
                if ( isObjectInACLGroup ( p, "staff" ) ) then 
                    outputChatBox ( "[staff] ".. getPlayerName ( p ) ..": ".. table.concat({...}, " "), p, 0, 0, 120 ) 
                end 
            end 
        end 
    end 
) 

Posted
  
addCommandHandler ( "staffchat", 
    fuction ( thePlayer, _, ... ) 
        if ( isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(thePlayer)), "staff" ) ) then 
            for i, p in ipairs ( getElementsByType ( "player" ) ) do 
                if ( isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(p)) "staff" ) ) then 
                    outputChatBox ( "[staff] ".. getPlayerName ( p ) ..": ".. table.concat({...}, " "), p, 0, 0, 120 ) 
                end 
            end 
        end 
    end 
) 
  

If your nick wouldn't be acc could create problems.

Posted
  
addCommandHandler ( "staffchat", 
    fuction ( thePlayer, _, ... ) 
        if ( isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(thePlayer)), "staff" ) ) then 
            for i, p in ipairs ( getElementsByType ( "player" ) ) do 
                if ( isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(p)) "staff" ) ) then 
                    outputChatBox ( "[staff] ".. getPlayerName ( p ) ..": ".. table.concat({...}, " "), p, 0, 0, 120 ) 
                end 
            end 
        end 
    end 
) 
  

If your nick wouldn't be acc could create problems.

why "getPlayerName(p)" this will write the name of admin players its "getPlayerName (thePlayer)" ?

function not fuction

  
addCommandHandler ( "staffchat", 
    function ( thePlayer, _, ... ) 
        if ( isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(thePlayer)), "staff" ) ) then 
            for i, p in ipairs ( getElementsByType ( "player" ) ) do 
                if ( isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(p)) "staff" ) ) then 
                    outputChatBox ( "[staff] ".. getPlayerName ( thePlayer ) ..": ".. table.concat({...}, " "), p, 0, 0, 120 ) 
                end 
            end 
        end 
    end 
) 
  

??? ( dont know if its correct )

Posted
  
  
addCommandHandler ( "s", 
    function ( thePlayer, _, ... ) 
        if ( isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(thePlayer)), "Staff" ) ) then 
            for i, p in ipairs ( getElementsByType ( "player" ) ) do 
                if ( isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(p)) "Staff" ) ) then 
                    outputChatBox ( "[staff] ".. getPlayerName ( p ) ..": ".. table.concat({...}, " "), p, 0, 0, 120 ) 
                end 
            end 
        end 
    end 
) 
  
  

I tested it and put it in my server.lua, uploaded it, did /s blahblah and it didnt work, nothing happened.

Any idea's? :/

Posted

People are right, the getPlayerName ( p ) should be getPlayerName ( thePlayer ). Another thing, make sure the player is logged in. Else it'll just not work.

Sorry for the typo's with function and the p, lmao.

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