Jump to content

How to send a message to admins from player


Recommended Posts

Hi.

The script I'm trying to make is a player who needs help does /adminreq and he gets a message saying admin is coming and admins, supermoderators and moderators get a message saying they are needed by the person who requested. 

Current code: 

function requestAdmin(playerName)
exports.SANGcommands:sendMessage("Your request for a staff member has been accepted. One of our staff members will be with you soon", 225,255,255)

local account = getPlayerAccount (thePlayer)
if isObjectInACLGroup ("user." .. getAccountName(string(account)), aclGetGroup ("Admin", "SuperModerator", "Moderator")) and type == 0 then
outputChatBox("You are required by ".. getPlayerFromName(playerName .. playerName)
end
end
  
addCommandHandler("adminreq", requestAdmin)

But when /adminreq is typed the first message shows but admins dont get the message. Why? (i'm new to lua) 

Link to comment
6 minutes ago, Ryan2233 said:

Hi.

The script I'm trying to make is a player who needs help does /adminreq and he gets a message saying admin is coming and admins, supermoderators and moderators get a message saying they are needed by the person who requested. 

Current code: 


function requestAdmin(playerName)
exports.SANGcommands:sendMessage("Your request for a staff member has been accepted. One of our staff members will be with you soon", 225,255,255)

local account = getPlayerAccount (playerName) -- thePlayer ? you need to use playerName as in function (playerName)
if isObjectInACLGroup ("user." .. getAccountName(string(account)), aclGetGroup ("Admin", "SuperModerator", "Moderator")) and type == 0 then
outputChatBox("You are required by ".. getPlayerFromName(playerName .. playerName)
end
end
  
addCommandHandler("adminreq", requestAdmin)

But when /adminreq is typed the first message shows but admins dont get the message. Why? (i'm new to lua) 

Try it now, of using playerName at line 4 you used thePlayer

Edited by SSKE
Link to comment
  1. function requestAdmin(playerName)
    exports.SANGcommands:sendMessage("Your request for a staff member has been accepted. One of our staff members will be with you soon", 225,255,255)
    
    local account = getPlayerAccount (thePlayer)
    if isObjectInACLGroup ("user." .. getAccountName(string(account)), aclGetGroup ("Admin", "SuperModerator", "Moderator")) and type == 0 then
    outputChatBox("You are required by ".. getPlayerFromName(playerName .. playerName)
    end
    end
    
    addCommandHandler("adminreq", requestAdmin)
    Mate the function requestAdmin(playerName)
  2. at local account = getPlayerAccount (thePlayer)  you used thePlayer you should use playerName

You can see it now ?

Try it now, I think that was the only problem..

Edited by SSKE
Link to comment
3 minutes ago, SSKE said:
  1. 
    function requestAdmin(playerName)
    exports.SANGcommands:sendMessage("Your request for a staff member has been accepted. One of our staff members will be with you soon", 225,255,255)
    
    local account = getPlayerAccount (thePlayer)
    if isObjectInACLGroup ("user." .. getAccountName(string(account)), aclGetGroup ("Admin", "SuperModerator", "Moderator")) and type == 0 then
    outputChatBox("You are required by ".. getPlayerFromName(playerName .. playerName)
    end
    end
    
    addCommandHandler("adminreq", requestAdmin)
    
    Mate the function requestAdmin(playerName)
  2. at local account = getPlayerAccount (thePlayer)  you used thePlayer you should use playerName

You can see it now ?

No. Bad argument @ 'getPlayerAccount' [Expected Element at argument 1, got nil]

Link to comment

You change thePlayer to playerName ?

local account = getPlayerAccount (thePlayer)            -- see this? make it   

 

                --make it like that: 

local account = getPlayerAccount (playerName)

 

and if change thePlayer to playerName    didn't work then try this: 

  1. function requestAdmin(playerName)
        exports.SANGcommands:sendMessage("Your request for a staff member has been accepted. One of our staff members will be with you soon", 225,255,255)
        local account = getPlayerAccount (playerName)
        if isObjectInACLGroup ("user." .. getAccountName(string(account)), aclGetGroup ("Admin", "SuperModerator", "Moderator")) and type == 0 then
            outputChatBox("You are required by ".. getPlayerFromName(playerName .. playerName)
        end
    end
    addCommandHandler("adminreq", requestAdmin)
      
    -- use the first which is above(up) this message if it didn't work then try which is below(down) this message
      
    function requestAdmin()
        for _,playerName in ipairs ( getElementsByType("player") ) do
            exports.SANGcommands:sendMessage("Your request for a staff member has been accepted. One of our staff members will be with you soon", 225,255,255)
            local account = getPlayerAccount (playerName)
            if isObjectInACLGroup ("user." .. getAccountName(string(account)), aclGetGroup ("Admin", "SuperModerator", "Moderator")) and type == 0 then
                outputChatBox("You are required by ".. getPlayerFromName(playerName .. playerName)
            end
        end
    end
    addCommandHandler("adminreq", requestAdmin)
    Try the first one if it didn't work. then try the second one, but the first one should work if it didn't then try the second one~ 
Edited by SSKE
Link to comment
13 minutes ago, SSKE said:

You change thePlayer to playerName ?


local account = getPlayerAccount (thePlayer)            -- see this? make it   

 

                --make it like that: 

local account = getPlayerAccount (playerName)

 

Yes

Link to comment
  1. function requestAdmin()
  2. for _,playerName in ipairs ( getElementsByType("player") ) do
  3. exports.SANGcommands:sendMessage("Your request for a staff member has been accepted. One of our staff members will be with you soon", 225,255,255)
  4. local account = getPlayerAccount (playerName)
  5. if isObjectInACLGroup ("user." .. getAccountName(string(account)), aclGetGroup ("Admin", "SuperModerator", "Moderator")) and type == 0 then
  6. outputChatBox("You are required by ".. getPlayerFromName(playerName .. playerName)
  7. end
  8. end
  9. end
  10. addCommandHandler("adminreq", requestAdmin)

- try this 

Link to comment
2 minutes ago, SSKE said:
  1. function requestAdmin()
  2. for _,playerName in ipairs ( getElementsByType("player") ) do
  3. exports.SANGcommands:sendMessage("Your request for a staff member has been accepted. One of our staff members will be with you soon", 225,255,255)
  4. local account = getPlayerAccount (playerName)
  5. if isObjectInACLGroup ("user." .. getAccountName(string(account)), aclGetGroup ("Admin", "SuperModerator", "Moderator")) and type == 0 then
  6. outputChatBox("You are required by ".. getPlayerFromName(playerName .. playerName)
  7. end
  8. end
  9. end
  10. addCommandHandler("adminreq", requestAdmin)

- try this 

There's no errors or anything but it doesn't show still 

Link to comment

 

  1. function requestAdmin(playerName)
  2.     exports.SANGcommands:sendMessage("Your request for a staff member has been accepted. One of our staff members will be with you soon", 225,255,255)
  3.     local account = getAccountName ( getPlayerAccount ( playerName ) )
  4.     if isObjectInACLGroup ("user.".. account, aclGetGroup ("Admin", "SuperModerator", "Moderator")) and type == 0 then
  5.         outputChatBox("You are required by ".. getPlayerFromName(playerName .. playerName)
  6.         end
  7.     end
  8. addCommandHandler("adminreq", requestAdmin)

 

try this now xD 

or wait before use this one write in console":   debugscript 3

it will show all errors

Edited by SSKE
Link to comment
function requestAdmin(playerName)
    exports.SANGcommands:sendMessage("Your request for a staff member has been accepted. One of our staff members will be with you soon", 225,255,255)
    local x, y, z = getElementPosition (playerName)
    local account = getAccountName ( getPlayerAccount ( playerName ) )
    if isObjectInACLGroup ("user.".. account, aclGetGroup ("Admin", "SuperModerator", "Moderator")) and type == 0 then
        setElementPosition( playerName, x, y, z )
    end
end
addCommandHandler("adminreq", requestAdmin)

Try this it should warp the Staff to the player which used the command, idk if it will work didn't test it

 

Edited by SSKE
Link to comment
2 minutes ago, SSKE said:

function requestAdmin(playerName)
    exports.SANGcommands:sendMessage("Your request for a staff member has been accepted. One of our staff members will be with you soon", 225,255,255)
    local x, y, z = getElementPosition (playerName)
    local account = getAccountName ( getPlayerAccount ( playerName ) )
    if isObjectInACLGroup ("user.".. account, aclGetGroup ("Admin", "SuperModerator", "Moderator")) and type == 0 then
        setElementPosition( playerName, x, y, z )
    end
end
addCommandHandler("adminreq", requestAdmin)

Still no

Link to comment
    function requestAdmin(playerName)
        outputChatBox("Your request for a staff member has been accepted. One of our staff members will be with you soon.",playerName, 225,255,255)
        local account = getAccountName ( getPlayerAccount ( playerName ) )
        local Staff = isObjectInACLGroup ("user.".. account, aclGetGroup ("Admin"))
        if (Staff) then
            outputChatBox("You been requested by "..getPlayerName(playerName),playerName, 255, 255, 255)
        end
    end
    addCommandHandler("adminreq", requestAdmin)

Here you go ~ i test it 

Edited by SSKE
Link to comment
addCommandHandler("help", function(source, commad)
    messageToAdmins("Player "..getPlayerName(source).." need a administrator now.")
    outputChatBox("Your request sent to the admins.", source)
end)

function messageToAdmins(message)
       for k, v in ipairs(getElementsByType("player")) do
           if isPlayerInACL(v, "Admin") or isPlayerInACL(v, "Moderator") or isPlayerInACL(v, "SuperModerator") then
              outputChatBox(message, v, 255, 255, 255, true)          
           end
       end
end

function isPlayerInACL(player, acl)
   local accountName = getAccountName( getPlayerAccount(player) )
   if accountName ~= "guest" and type( aclGetGroup(acl) ) == "userdata" then
      return isObjectInACLGroup( "user."..accountName, aclGetGroup(acl) )
   end
   return false
end

 

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