Jump to content

Admin


Dice

Recommended Posts

local accountname = getAccountName(getPlayerAccount(thePlayer)) 
if isObjectInACLGroup("user." ..accountname, aclGetGroup("Admin")) or isObjectInACLGroup("user." ..accountname, aclGetGroup("SuperModerator"))  then 
Do something..... 
  

This is just a snippet from a thing i am working on. I am wondering why the DO SOMETHING doesn't get triggered for the supermoderator when an admin get's to that function first. This code happenes whenever a person presses 7, so let's say I am admin and mike is a supermod, if i press 7 first then he does, it will not work for any supermod only admins. I also tried elseif but it does the same thing. The only way i did it was makeing to if statements for the 2 things. But i feel that is unprofessional how can i do it more efficiently.

Link to comment
  • Moderators

Not very clear:

triggered for the supermoderator when an admin get's to that function first.
  
  
if isObjectInACLGroup("user." ..accountname, aclGetGroup("Admin")) then 
outputDebugString ("Admin") 
elseif isObjectInACLGroup("user." ..accountname, aclGetGroup("SuperModerator"))  then 
outputDebugString ("SuperModerator") 
end 
  

elseif is for spilt the admin from the supermoderator and will only be checked when the if isn't true.

It is faster than if end/if end/if end.*

if admin then -- check

elseif mod then -- check only when if is false.

else -- only when if and elseif are false. (false when not true or not exist>elseif)

end

You can also write it down in a table when they are with more then 4/5 for efficiently. I don't know what is faster, ipairs or elseif. It probably depends on the amount of data.

I prever ipairs, because it reduce the lines.

local accountname = getAccountName(getPlayerAccount(thePlayer)) 
for i, type in ipairs({"Admins","SuperModerator"}) do 
    if isObjectInACLGroup("user." ..accountname, aclGetGroup(type)) then 
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...