Jump to content

Staff chat and Anti-Caps


marty000123

Recommended Posts

Hey everyone.

Due the fact there aren't alot scripter available for us, we're kindly asking you for help.

The things, we are searching:

1: Anti-Caps. Nobody can use shift/caps. If they do, the script will translate the letters into small letters. Only people in the ACL group ''Staff'' can use shift/caps. It will not be translated into small letters by the script.

2: Staff chat. Only people in the ACL group ''Staff'' must be able to use /s(taffchat) [ So the command must be /s to use staffchat ] and they must be the only one who can read it so only people in the ACL group Staff. Nobody else must be able to use /s or to even read it.

Thank you very much in advance!

Regards, Marty

The Zombie Invasion Server Owner.

Link to comment

Well the anti caps part is easy unless you're being lazy,

str = string.lower(str) 

For the second one you need to make a command handler and a loop thought all the players online and check their team.

function staffChat(staffPlayer, cmd, ...) 
    local message = string.concat(..., " ") 
    for i, thePlayer in ipairs(getElementsByType("player")) 
        -- Check your acl group here and show the message 
    end 
end 
addCommandHandler("s", staffChat) 

Link to comment
Well the anti caps part is easy unless you're being lazy,
str = string.lower(str) 

Thanks for responding.

I know anti-caps isn't that hard, but I requested ''only players in the ACL group ''Staff'' can be able to use caps/shift''. That's too hard for me and that's why I ask you.

For the second one you need to make a command handler and a loop thought all the players online and check their team.
function staffChat(staffPlayer, cmd, ...) 
    local message = string.concat(..., " ") 
    for i, thePlayer in ipairs(getElementsByType("player")) 
        -- Check your acl group here and show the message 
    end 
end 
addCommandHandler("s", staffChat) 

I don't get it exactly, sorry I'm not the best scripter you've ever met :D

What do I need to put in that script to make it work?

Marty

Link to comment
  
  
function getOnlineAdmins() 
    local t = {} 
    for k,v in ipairs ( getElementsByType("player") ) do 
        while true do 
            local acc = getPlayerAccount(v) 
            if not acc or isGuestAccount(acc) then break end 
            local accName = getAccountName(acc) 
            local isAdmin = isObjectInACLGroup("user."..accName,aclGetGroup("Admin")) 
            if isAdmin == true then 
                table.insert(t,v) 
            end 
            break 
        end 
    end 
    return t 
end 
  
addCommandHandler("staffchat", function(source, cmd, ...) 
      local concat = string.lower(table.concat(..., " ")) 
      if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then 
          for k,v in ipairs(getOnlineAdmins()) do 
                   outputChatBox("(STAFF-CHAT)"..getPlayerName(source).. ": #ffffff"..tostring(concat), v, 255, 255, 255, true) 
end 
      end 
end 
) 
  
  

Link to comment
  
  
function getOnlineAdmins() 
    local t = {} 
    for k,v in ipairs ( getElementsByType("player") ) do 
        while true do 
            local acc = getPlayerAccount(v) 
            if not acc or isGuestAccount(acc) then break end 
            local accName = getAccountName(acc) 
            local isAdmin = isObjectInACLGroup("user."..accName,aclGetGroup("Admin")) 
            if isAdmin == true then 
                table.insert(t,v) 
            end 
            break 
        end 
    end 
    return t 
end 
  
addCommandHandler("staffchat", function(source, cmd, ...) 
      local concat = string.lower(table.concat(..., " ")) 
      if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then 
          for k,v in ipairs(getOnlineAdmins()) do 
                   outputChatBox("(STAFF-CHAT)"..getPlayerName(source).. ": #ffffff"..tostring(concat), v, 255, 255, 255, true) 
end 
      end 
end 
) 
  
  

Thanks, I'll try it out asap!

Link to comment
  
  
function getOnlineAdmins() 
    local t = {} 
    for k,v in ipairs ( getElementsByType("player") ) do 
       while true do 
            local acc = getPlayerAccount(v) 
            if not acc or isGuestAccount(acc) then break end 
            local accName = getAccountName(acc) 
            local isAdmin = isObjectInACLGroup("user."..accName,aclGetGroup("Admin")) 
            if isAdmin == true then 
                table.insert(t,v) 
            end 
            break 
        end 
    end 
    return t 
end 
  
addCommandHandler("staffchat", function(source, cmd, ...) 
      local concat = string.lower(table.concat(..., " ")) 
      if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then 
          for k,v in ipairs(getOnlineAdmins()) do 
                   outputChatBox("(STAFF-CHAT)"..getPlayerName(source).. ": #ffffff"..tostring(concat), v, 255, 255, 255, true) 
end 
      end 
end 
) 
  
  

I don't understand why you would put a while loop in the getOnlineAdmins ( ) function. It's completely useless...

Try using this code:

  
function isPlayerInACL ( player, acl ) 
    local account = getPlayerAccount ( player ) 
    if ( isGuestAccount ( account ) ) then 
        return false 
    end 
    return isObjectInACLGroup ( "user."..getAccountName ( account ), aclGetGroup ( acl ) ) 
end 
  
addCommandHandler ( "staffchat", function ( p, _, ... )  
    if ( not isPlayerInACL ( p, "Admin" ) ) then 
        return 
    end 
    local msg = string.lower ( tostring ( table.concat ( { ... }, " " ) ) ):gsub ( "#%x%x%x%x%x%x", "" ) 
    if ( msg:gsub ( " ", "" ) == "" ) then return end 
    for i, v in pairs ( getElemetnsByType ( "player" ) ) do 
        if ( isPlayerInACL ( v, "Admin" ) ) then 
            outputChatBox ( "(Staff) "..getPlayerName ( p )..": #ffffff"..msg, v, 0, 255, 0 ) 
        end  
    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...