Neproify Posted June 4, 2015 Posted June 4, 2015 Hello, I'm trying to rewrite my resources to OOP. This code: addCommandHandler("aduty", function(player) local globalInfo = player:getData("globalInfo") globalInfo.name = string.gsub(globalInfo.name, " ", "_") globalInfo.name = string.gsub(globalInfo.name, "ś", "s") globalInfo.name = string.gsub(globalInfo.name, "ć", "c") local charInfo = player:getData("charInfo") local accountName = player.account:getName() --if isObjectInACLGroup("user."..accountName, aclGetGroup("Admin")) then if ACLGroup.get("Admin"):doesContainObject("user."..player.account:getName()) then if not player:getData("adminduty") then player:setName(globalInfo.name) player:setData("adminduty", true) else player:setName(charInfo.name) player:setData("adminduty", false) end --elseif isObjectInACLGroup("user."..accountName, aclGetGroup("Support")) then elseif ACLGroup.get("Support"):doesContainObject("user."..player.account:getName()) then if not player:getData("supportduty") then player:setName(globalInfo.name) player:setData("supportduty", true) else player:setName(charInfo.name) player:setData("supportduty", false) end end end) outputing this error: admin.lua:9: attempt to call method 'doesContainObject' (a nil value) I don't know why. Can anyone help me? Sorry for my english. I am from Poland.
Walid Posted June 4, 2015 Posted June 4, 2015 Try this untested addCommandHandler("aduty", function(player) local globalInfo = player:getData("globalInfo") local charInfo = player:getData("charInfo") globalInfo.name = string.gsub(globalInfo.name, " ", "_") globalInfo.name = string.gsub(globalInfo.name, "ś", "s") globalInfo.name = string.gsub(globalInfo.name, "ć", "c") local account = player:getAccount() if account and not isGuestAccount(account) then local accountName = account:getName() local admin = ACLGroup.get("Admin") local support = ACLGroup.get("Support") if admin:doesContainObject("user."..accountName) then if not player:getData("adminduty") then player:setName(globalInfo.name) player:setData("adminduty", true) else player:setName(charInfo.name) player:setData("adminduty", false) end elseif support:doesContainObject("user."..accountName) then if not player:getData("supportduty") then player:setName(globalInfo.name) player:setData("supportduty", true) else player:setName(charInfo.name) player:setData("supportduty", false) end end end end) Do not yield your back to your enemy, might feel something strange in your ass. Two things are infinite the universe and human stupidity and i'm not sure about the universe. UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators
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