Jump to content

Ho i can make elseif in script ?


//_Dragon

Recommended Posts

i want make aclgetgroup : Admin & Console & S.mod

this is the script but doesnt work :arrowdown:

function shout ( player, cmd, ... ) 
    local accountname = getAccountName ( getPlayerAccount ( player ) ) 
elseif 
    if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" ) )  
elseif 
if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Console" ) ) 
elseif 
if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "SuperModerator" ) ) then 

Link to comment
    function shout ( player, cmd, ... ) 
local accountname = getAccountName ( getPlayerAccount ( player ) ) 
if isObjectInACLGroup ( "user.".. accountname, aclGetGroup ( "Admin" ) ) 
or isObjectInACLGroup ( "user." ..accountname, aclGetGroup ( "Console" ) ) 
or isObjectInACLGroup ( "user." ..accountname, aclGetGroup ( "SuperModerator" ) )  
then 

Link to comment

If you for some reason don't wanna use the or operator, this is how you properly make use of if statements in Lua;

function shout(player, cmd, ...) 
    local accountname = getAccountName(getPlayerAccount(player)) 
    if isObjectInACLGroup("user." .. accountname, aclGetGroup("Admin")) then 
        -- If true, code here 
    -- If false, check next if statement 
    elseif isObjectInACLGroup("user." .. accountname, aclGetGroup("Console")) then 
        -- If true, code here 
    -- If false, check next if statement 
    elseif isObjectInACLGroup("user." .. accountname, aclGetGroup("SuperModerator")) then 
        -- If true, code here 
    else 
        -- If all above if statements fail, you can use else 
        outputChatBox("You do not have permission to use this command!", player, 187, 0, 0)      
    end 
end 

Things to note;

if and elseif both need to end with then otherwise it will return an error.

else does not require then as it is used if the previous if statements failed.

Link to comment
Well he wanted it so only a certain group could use it, so or works just fine in this situation.

I'm well aware of this. But the title of the thread is "Ho i can make elseif in script ?", and since he didn't seem to know how to properly structure the if statements - I thought I'd help him out.

I never said your method does not work.

  • Like 1
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...