Jump to content

How to access to the Admin on the script? HELP ME


Recommended Posts

Hi Please help me, I'd like my script is restricted to admins when you make a command (/ op / pf)

Help me please.

local gate = createObject(10828, -1570.5, 1117.5, 16.10000038147, 0, 0, 91.988525390625) 
  
function open() 
moveObject(gate, 3000, -1570.5, 1117.5, 30.2, 0, 0, 0 ) 
end 
addCommandHandler("op", open) 
  
function close() 
moveObject(gate, 3000, -1570.5, 1117.5, 16.10000038147, 0, 0, 0 ) 
end 
addCommandHandler("fp", close) 

Link to comment

You must use the following functions:

getPlayerAccount -- Gets the account element of a player. 
getAccountName -- Gets the name of an account element. 
aclGetGroup -- Gets the ACL group from it's name. 
isObjectInACLGroup -- Checks if an object is in the ACL group. 

Link to comment
  
local gate = createObject(10828, -1570.5, 1117.5, 16.10000038147, 0, 0, 91.988525390625) 
addCommandHandler("gate",function(player) 
    if getPlayerAccount(player) and isObjectInACLGroup(string.format("user.%s",getAccountName(getPlayerAccount(player))),aclGetGroup("Admin")) then 
        setElementData(gate,"opened",not getElementData(gate,"opened")) 
        if getElementData(gate,"opened") then 
            moveObject(gate,3000,-1570.5,1117.5,30.2,0,0,0) 
        else 
            moveObject(gate,3000,-1570.5,1117.5,16.10000038147,0,0,0) 
        end 
    end 
end) 
  

Edited by Guest
Link to comment
  
local gate = createObject(10828, -1570.5, 1117.5, 16.10000038147, 0, 0, 91.988525390625) 
addCommandHandler("gate",function(player) 
    if getPlayerAccount(player) and isObjectInACLGroup(string.format("user.%s",getAccountName(getPlayerAccount(player))),aclGetGroup("Admin")) then 
        setElementData(gate,"opened",not getElementData(gate,"opened")) 
        if getElementData(gate,"opened") then 
            moveObject(gate,3000,-1570.5,1117.5,30.2,0,0,0) 
        else 
            moveObject(gate,3000,-1570.5,1117.5,16.10000038147,0,0,0) 
        end 
    end 
end) 
  

What's the point on using string.format? you can simply do:

"user.".. getAccountName ( getPlayerAccount ( player ) ) 

@RoRo76: Try this:

local gate = createObject ( 10828, -1570.5, 1117.5, 16.10000038147, 0, 0, 91.988525390625 ) 
local state = false 
  
addCommandHandler ( "gate", 
    function ( thePlayer ) 
        if isObjectInACLGroup ( "user.".. getAccountName ( getPlayerAccount ( thePlayer ) ), aclGetGroup ( "Admin" ) ) then 
            if ( not state ) then 
                moveObject ( gate, 3000, -1570.5, 1117.5, 30.2, 0, 0, 0 ) 
            else 
                moveObject ( gate, 3000, -1570.5, 1117.5, 16.10000038147, 0, 0, 0 ) 
            end 
            state = ( not state ) 
        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...