Jump to content

disallow /ss (setskin)


5150

Recommended Posts

Posted

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

Posted
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) 

Posted (edited)

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
Posted
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?

Posted (edited)
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
Posted

when i put that in a zip file with the meta, it doesnt load into my server. i named everything correctly, i saved it correctly, etc etc etc but doesnt work

Posted
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) 

Posted

guys im still confused where do i put this script? i know a lot about scripting, but i still dont know where to put the scripts i find on the forum xD

Posted

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 .

Posted

man, i know about making scripts and editing, but i think during me learning sh*t, i skipped over learning how to save scripts from the forum, etc. idk it seems like an easy explanation, but its just going right past me

Posted

So you know how to write scripts yourself but you don't know how to copy ones from the forums?

Just place them in an Lua file and add the file to the meta.xml.

Posted

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

Posted

This probably means either the resource files aren't in a folder nor in a .zip file OR something is wrong with the meta. Post your meta.xml file here please.

Posted (edited)
<meta> 
<info author="name" name="name" version="version" type="script"/> 
<script src="server.lua" type="server" /> 
</meta> 

Edited by Guest
Posted

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) 

Posted

Well since the files are in a folder/.zip file, and nothing is wrong with your meta file, and the "server.lua" script is there, are you sure your resource is placed in the right directory?

Posted

put in server/mods/deathmatch/resources. when i tested the ss script you guys sent to here, i used the server.lua meta from another self-made resource, also serverside. so i figured it would be fine

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