Jump to content

Ho i can make elseif in script ?


//_Dragon

Recommended Posts

Posted

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 

Posted
    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 

Wolf Inc Discord

Youtube channel
Github

Posted

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.

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

Posted
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

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

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