Jump to content

Admin Say Resource


John_Scott

Recommended Posts

Hi,

I made a resource to i can write to the chat as admin. (/asay [message]). When i write the command, for example: /asay one two, the script write to the chat onty "one", so always just the first word.

My resource:

function sendMsg(playersource, cmd, msg) 
  
    local accName = getAccountName ( getPlayerAccount ( playersource ) ) 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
        
                local msg = tostring(msg) 
                if msg then 
                  outputChatBox(msg, getRootElement(), 255, 0, 0) 
                else 
                outputChatBox("Használat: /asay <üzenet>", player) --Usage 
                end 
        
    else 
    outputChatBox ( "#ffffff[#DF3A01Z-Land DayZ#ffffff]: #FF0000Nincs jogosultságod a parancs használatához!", 255, 255, 255, true ) --No permission 
    end 
end 
addCommandHandler ( "asay", sendMsg ) 

Thanks for help!

Link to comment

It's because of the fact that 'msg' only receives one value. Therefore you have to make it receive multiple arguments at once by making it an array like so.

Server-side

addCommandHandler("asay", 
    function(player, cmd, ...) 
        local account = getPlayerAccount(player) 
        local accountName = getAccountName(account) 
        if (not account) or (not accountName) or (account and accountName and not isObjectInACLGroup("user." .. accountName, aclGetGroup("Admin"))) then 
            outputChatBox("#ffffff[#DF3A01Z-Land DayZ#ffffff]: #FF0000Nincs jogosultságod a parancs használatához!", player, 245, 20, 20, true) 
            return 
        end 
         
        local message = table.concat({...}, " ") 
        if (message) and (#message > 0) then 
            outputChatBox(message, root, 255, 0, 0, false) 
        else 
            outputChatBox("Használat: /asay <üzenet>", player, 245, 20, 20, false) 
        end 
    end 
) 

Edited by Guest
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...