Jump to content

disallow /ss (setskin)


5150

Recommended Posts

how can i dissallow /ss for normal players, but keep it for admin, smod, and mod? i only want the chat command /ss disabled i dont want admin panel ss, or f1 GUI set skin disabled...

Try this:

addEventHandler("onPlayerCommand", getRootElement(), 
function (string) 
if string == "ss" then 
if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)),aclGetGroup("Admin")) then 
elseif isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)),aclGetGroup("SuperModerator")) then 
elseif isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)),aclGetGroup("Moderator")) then 
else 
    cancelEvent() 
end 
end 
end) 

Link to comment

What you gave him have no sense, also ss is not defined in your code

and if you want to check if the user of an cmd is in the ACL or not with more than group, simply do like that, be sure the group name is in the ACL or you'll get a Warning on the debugscript.

addCommandHandler("commandName",  
function (player) 
    if ( getElementType ( player ) == "player" ) then --Checking for the player who used the cmd is a player or not. 
    local accountName = getAccountName(account)  
 --Using the logical "or" exept of elseif IN this situation no need for elseif 
    if ( isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "Admin" ) ) or  
    isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "SuperModerator" ) ) or  
    isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "Moderator" ) ) ) then 
     --Your code 
       end 
    end 
end) 
     

Edited by Guest
Link to comment
What you gave him have no sense, also ss is not defined in your code

and if you want to check if the user of an cmd is in the ACL or not with more than group, simply do like that, be sure the group name is in the ACL or you'll get a Warning on the debugscript.

addCommandHandler("commandName",  
function (player) 
    if ( getElementType ( player ) == "player" ) then --Checking for the player who used the cmd is a player or not. 
    local accountName = getAccountName(account)  
 --Using the logical "or" exept of elseif 
    if ( isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "Admin" ) ) or  
    isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "SuperModerator" ) ) or  
    isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "Moderator" ) ) ) then 
     --Your code 
       end 
    end 
end) 
     

this + meta will make it so /ss is disabled for regular players?

Link to comment
tableAdministration = { 
  "Admin", 
  "SuperModerator", 
  "Moderator", 
  "Helper", 
}  
  
tableAdministration_two = { 
  "Admin", 
  "SuperModerator", 
}  
  
function isAdministration(player, tab) 
    local accountName 
    if player and getElementType(player) == "player" and not isGuestAccount(getPlayerAccount(player)) then 
        accountName = getAccountName(getPlayerAccount(player)) 
    else 
        return false 
    end 
  
    for _, v in ipairs(tab) do 
        if isObjectInACLGroup ("user." .. accountName, aclGetGroup(v)) then 
            return true 
        end 
    end 
  
    return false 
end 
  
  return false 
end 

function(...) 
  if not isAdministration(source, tableAdministration) then return false end 
  -- body 
end 
addCommandHandler(...) 
  

Edited by Guest
Link to comment
local AllowedGroups = { 
    "Admin", 
    "SuperModerator", 
    "Moderator" 
} 
  
addEventHandler("onPlayerCommand", root, 
function(cmd) 
    if cmd == "ss" then 
        local account = getPlayerAccount(source) 
        local hasPermission 
        if account and not isGuestAccount(account) then 
            local accName = getAccountName(account) 
            for _, groupName in ipairs(AllowedGroups) do 
                local group = aclGetGroup(groupName) 
                if group then 
                    if isObjectInACLGroup("user."..accName, group) then 
                        hasPermission = true 
                        break 
                    end 
                end 
            end 
        end 
        if not hasPermission then 
            cancelEvent() 
        end 
    end 
end) 

Link to comment

I'd recommend reading and learning more about Lua first and then reading MTA scripting tutorials. This is the best way to start scripting in MTA. Because MTA uses Lua as it's scripting engine.

This site is very useful for learning basics about Lua: http://www.tutorialspoint.com/lua/index.htm .

If you want to try out your codes, either use MTA or use this URL: http://www.lua.org/demo.html .

Link to comment

im doing that, but im saying i think im doing something wrong because i make sure everything is named correctly, everything is listed in meta, all the scripts are correct, and everything is in the right place, but it doesnt load into my server when i try to refresh my server

Link to comment

heres the script if it helps. just a basic move gate script. and yes tete i made sure of all that

local gate = createObject(10841, 82,2059.69999,24.6, 0,0,271.506) 
  
function open() 
     
    moveObject(gate, 8000, 92.4,2061.1,24.6, 0,0,199.506) 
     
end 
  
addCommandHandler("barriero", open) 
  
function close() 
     
    moveObject(gate, 8000, 82,2059.69999,24.6, 0,0,271.506) 
end 
  
addCommandHandler("barrierc", close) 

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