Jump to content

[HELP] indexing a nil field


LabiVila

Recommended Posts

local clans = {} 
  
function createClan (player, cmd, password, ...) 
    local acc = getPlayerAccount (player) 
    local cName = table.concat ({...}, " ") 
     
    if not password or not (...) then 
        return outputChatBox ("t Syntax error, /addc password clanName", player, 255, 255, 255) 
    end 
  
    if acc and isGuestAccount (acc) then 
        return outputChatBox ("This command is disabled for guests.", player, 255, 255, 255) 
    end 
  
    if clans[cName] then 
        return outputChatBox ("There is a clan with such name.", player, 255, 255, 255) 
    end 
     
    for a,b in ipairs (clans[cName].members) do  
        if (b == player) then 
            outputChatBox ("You are in a clan already.", player, 255, 255, 255) 
        end 
    end 
     
    outputChatBox ("You have created a clan called '"..cName.."', password is '"..password.."'.", player, 255, 255, 255) 
    clans [cName] = {members = {player}, cPass = {password}} 
    setAccountData (acc, "currentClan", cName) 
    setAccountData (acc, "LeaderState", cName) 
end 
addCommandHandler ("addc", createClan) 

The error is: Attempt to index field '?' (a nil value), line 15 and 19

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