Jump to content

Attempt to index field '?' (a nil value)


DjMixCuma

Recommended Posts

I have big trouble, with my LUA Code.

function SendMessageToAdmins(color1, color2, color3, msg) 
    for i = 0, maxSlots - 1 do 
        if Account[i] and Account[i].Admin >= 1 or Account[i] and Account[i].GameMaster >= 1 then 
            SendPlayerMessage(i, color1, color2, color3, string.format("%s", msg)) 
        end 
    end 
end 

Here is the error:

if Account[i] and Account[i].Admin >= 1 or Account[i] and Account[i].GameMaster >= 1 then 

Content of error:

attempt to index field '?' (a nil value)

How to fix that?

Code not forom MTA:SA !!!!!!!!

Link to comment
I have big trouble, with my LUA Code.
function SendMessageToAdmins(color1, color2, color3, msg) 
    for i = 0, maxSlots - 1 do 
        if Account[i] and Account[i].Admin >= 1 or Account[i] and Account[i].GameMaster >= 1 then 
            SendPlayerMessage(i, color1, color2, color3, string.format("%s", msg)) 
        end 
    end 
end 

Here is the error:

if Account[i] and Account[i].Admin >= 1 or Account[i] and Account[i].GameMaster >= 1 then 

Content of error:

attempt to index field '?' (a nil value)

How to fix that?

Code not forom MTA:SA !!!!!!!!

What exactly do you want to do?

Link to comment

Is that what you wanted?

  
addCommandHandler("sendmessage", 
    function(player, command, ...) 
        msgt = { ... } 
        message = table.concat(msgt, " ") 
        for i, v in ipairs(getElementsByType("player")) do 
            while true do 
                if not getPlayerAccount(v) or isGuestAccount(getPlayerAccount(v)) then break end 
                    if isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(v)), aclGetGroup("Admin")) then 
                        outputChatBox("Message sent.", player, 255, 255, 255, true) 
                        outputChatBox(getPlayerName(player) .. " said: "..message, v, 255, 255, 255, true) 
                    end 
            break 
            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...