-stolka- Posted April 5, 2014 Share Posted April 5, 2014 the debugscript reports bad agrumnet line 115, expected account at argument 1 ------------------------------------------------------------------------------------ -- PROJECT: N/A -- RIGHTS: All rights reserved by developers -- FILE: groupSystem/group.slua -- DEVELOPER: Sebbe (Smart) ------------------------------------------------------------------------------------ local groupTable = {} local log = true -- Set this to false if you don't want group stuff to be logged in your server.log local debugInfo = true -- Set this to false if you don't want to see see group logs in your debug mode. local GAC = {} -- index = account (string), [1] = group name, [2] = rank, [3] = warning level, [4] = date Joined, [5] = last time online (Not Available) local users = {} local myGang = {} local char = "[^0-9a-zA-Z_]" local rankCache = {} local db = dbConnect("sqlite", "/database.db") dbExec(db, "CREATE TABLE IF NOT EXISTS groupmember (account TEXT, groupName TEXT, rank TEXT, warningLvl TEXT, joined TEXT, lastTime TEXT)") dbExec(db, "CREATE TABLE IF NOT EXISTS groups (name TEXT, leader TEXT, message TEXT, chatcolor TEXT, notecolor TEXT, date TEXT, turfcolor TEXT)") dbExec(db, "CREATE TABLE IF NOT EXISTS groupRanks (groupName TEXT, name TEXT, permissions TEXT)") --Some misc functions _outputDebugString = outputDebugString function outputDebugString(string) if (debugInfo) then _outputDebugString(string) end end function getTime() local time = getRealTime() local date = string.format("%02d/%02d/%02d", time.monthday, (time.month+1), (time.year-100) ) local time = string.format("%02d:%02d", time.hour, time.minute) return date, time end MTAoutput = outputChatBox function outputChatBox(message, player, r, g, b, bool) if (isElement(message) and getElementType(message) == "player") then MTAoutput(player, message, r, g, b, bool) else outputChatBox(message, player, r, g, b, bool) end end function groupLog(group, message) if (log) then outputServerLog("GROUP: "..group.." - "..message) end if (debugInfo) then outputDebugString("GROUP: "..group.." - "..message) end end --Lets start local permToTable = { [1] = "invite", [2] = "promote", [3] = "demote", [4] = "kick", [5] = "warn", [6] = "delete", [7] = "deposit", [8] = "withdraw", [9] = "editInfo", [10] = "viewLog", [11] = "viewBlacklist", [12] = "addBlaclist", [13] = "changeTurfColor", [14] = "modifyAlliance", [15] = "modifyRanks", } function account(plr) if (plr and isElement(plr)) then accP = getPlayerAccount(plr) return getAccountName(accP) end end function loadGroupRanks(query) local the_table = dbPoll(query, 0) if (the_table) then for ind, data in pairs(the_table) do if (not rankCache[data.groupName]) then rankCache[data.groupName] = {} end if (not rankCache[data.groupName][data.name]) then rankCache[data.groupName][data.name] = {} end local JSONtable = fromJSON(data.permissions) for ind, value in pairs(JSONtable) do if (value and ind) then rankCache[data.groupName][data.name][ind] = true end end end end end dbQuery(loadGroupRanks, db, "SELECT * FROM groupRanks") function loadGroupStuff(query) local g_table = dbPoll(query, 0) if (not g_table) then return end for ind, data in ipairs(g_table) do groupTable[data.name] = {data.leader, data.message, data.chatcolor, data.notecolor, data.date, data.turfcolor} end end dbQuery(loadGroupStuff, db, "SELECT * FROM groups") function loadClientGroup(query) local g_table = dbPoll(query, 0) if (not g_table) then return end for ind, data in ipairs(g_table) do local player = getAccountPlayer(getAccount(data.account)) users[data.groupName] = {} table.insert(users[data.groupName], data.account) if (player) then setElementData(player, "Group", data.groupName) myGang[player] = data.groupName end GAC[data.account] = {data.groupName, data.rank, data.warningLvl, data.joined, data.lastTime or 0} end end dbQuery(loadClientGroup, db, "SELECT * FROM groupmember") function addRank(group, rank, permissionTable) if (not rankCache[group]) then rankCache[group] = {} end --rankCache[group][rank] = {fromJSON(permissionTable)} dbExec(db, "INSERT INTO groupRanks VALUES (?, ?, ?)", tostring(group), tostring(rank), permissionTable) dbQuery(loadGroupRanks, db, "SELECT * FROM groupRanks") end function removeRank(group, rank) if (not rankCache[group]) then return true end if (rankCache[group][rank]) then rankCache[group][rank] = nil dbExec(db, "DELETE FROM groupRanks WHERE name=? AND groupName=?", tostring(rank), tostring(group)) dbQuery(loadGroupRanks, db, "SELECT * FROM groupRanks") return true end end function isRank(group, rank) if (not rankCache[group]) then return false end return rankCache[group][rank] end function groupMemberLogin() if (GAC[account(source)]) then myGang[source] = GAC[account(source)][1] setElementData(source, "Group", GAC[account(source)][1]) end end addEventHandler("onPlayerLogin", root, groupMemberLogin) function getGroupMembers(group) local temp = {} for ind, data in pairs(users) do if (ind == group) then table.insert(temp, data[1]) end end return temp end function getPlayerGroup(player) if (not GAC[account(player)]) then return false end return GAC[account(player)][1] end function getPlayerGroupRank(player) if (not GAC[account(player)]) then return false end return GAC[account(player)][2] end function getPlayerWarningLevel(player) if (not GAC[account(player)]) then return false end return GAC[account(player)][3] end function getPlayerJoinDate(player) if (not GAC[account(player)]) then return false end return GAC[account(player)][4] end function getHexCode(r, g, b) if (r and g and b) then return string.format("#%.2X%.2X%.2X", r, g, b) end end function getGroupChatColor(group) if (not groupTable[group]) then return 255, 255, 255 end local color = fromJSON(groupTable[group][3]) return color[1], color[2], color[3] end function outputGroupMessage(message, group) for ind, data in pairs(GAC) do if (data[1] == group) then local acc = getAccount(ind) if (getAccountPlayer(acc)) then local color = fromJSON(groupTable[group][3]) local hex = getHexCode(color[1], color[2], color[3]) outputChatBox(hex.."("..group..") #FFFFFF"..message, getAccountPlayer(acc), 255, 255, 255, true) end end end end function checkGroupAccess(player, actionID) local rank = getPlayerGroupRank(player) local group = getPlayerGroup(player) if (not rankCache[group]) then return false end if (rankCache[group] and rankCache[group][rank]) then if (tostring(actionID)) then for ind, data in pairs(permToTable) do if (data == actionID) then actionID = ind break end end end local actionID = tonumber(actionID) if (rankCache[group][rank][actionID]) then return true end end end function getPermissionCount(group, rank) if (not rankCache[group]) then return false end local count = 0 if (rankCache[group] and rankCache[group][rank]) then for ind, data in pairs(rankCache[group][rank]) do count = count + 1 end end return count end function getGroupRankCount(group) if (not rankCache[group]) then return end local count = 0 for ind, v in pairs(rankCache[group]) do count = count + 1 end return Link to comment
.:HyPeX:. Posted April 5, 2014 Share Posted April 5, 2014 output what "data.account" is... it must be an account name in order to work. (Accounts itself wont work!) Link to comment
WhoAmI Posted April 5, 2014 Share Posted April 5, 2014 Try outputChatBox ( data.account ) and tell us what it outputs. Link to comment
-stolka- Posted April 5, 2014 Author Share Posted April 5, 2014 Try outputChatBox ( data.account ) and tell us what it outputs. I added this line outputChatBox( tostring( data.account ) ) it outputs 'smart' in the chatbox Link to comment
.:HyPeX:. Posted April 5, 2014 Share Posted April 5, 2014 Then smart is not an account, else getAccount("smart") would return that account. Link to comment
-stolka- Posted April 5, 2014 Author Share Posted April 5, 2014 Then smart is not an account, else getAccount("smart") would return that account. i just created an account called 'smart' but it still doesnt give the same error Link to comment
.:HyPeX:. Posted April 5, 2014 Share Posted April 5, 2014 ideas? It should be working, output what getAccount(data.account) does Link to comment
gghvcffcv Posted April 5, 2014 Share Posted April 5, 2014 try this local player = getAccountPlayer (smart) Link to comment
Weii. Posted April 5, 2014 Share Posted April 5, 2014 just add if (not getAccount(data.account)) then return end Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now