Jump to content

antiban


Makaveli15

Recommended Posts

Hello guys, how can i make my script able to ban someone who tried to ban me on server?for example somebody tries to ban me, but gets ban instead of me and for me nothing happens

here's the undone one, which blocks to ban all admins

function onBan ( _, Player )
    for _, ban in ipairs( getBans() )do
        if isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(source)),aclGetGroup("Admin")) then
            if getPlayerName ( source ) == getBanNick( ban ) then
                if ( removeBan ( ban ) ) then
                    outputChatBox("This is a bad idea. :)",Player , 255, 255, 255, true)    
                end
            end
        end
    end
end
addEventHandler ( "onPlayerBan", root, onBan )

Edited by OsO.cp
Link to comment
  • Administrators

This isn't a problem you should initially be trying to solve with code. You shouldn't be giving people permissions on your server if you can't trust them.

However, something like this might help. If anyone tries to ban an admin the action will be blocked and they'll get banned them-self (Serial and IP ban).

function verifyBan(banPointer, responsiblePlayer)
    if getElementType(responsiblePlayer) ~= "player" then return false end
    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then
    	cancelEvent() --Cancel the ban on admin
    	addBan(getPlayerIP(responsiblePlayer), nil, getPlayerSerial(responsiblePlayer), root, "Banning other admins") --Ban the offending moderator
        outputChatBox (getPlayerName(responsiblePlayer).." has been banned for banning admins!", getRootElement(), 255, 0, 0) -- Output the ban.
    end
end
addEventHandler ( "onPlayerBan", getRootElement(), verifyBan )

Not tested, try it out and see if it works.

Edited by LopSided_
Link to comment
10 minutes ago, LopSided_ said:

This isn't a problem you should initially be trying to solve with code. You shouldn't be giving people permissions on your server if you can't trust them.

However, something like this might help. If anyone tries to ban an admin the action will be blocked and they'll get banned them-self (Serial and IP ban).


function verifyBan(banPointer, responsiblePlayer)
	if getElementType(responsiblePlayer) ~= "player" then return false end
	if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then
    	cancelEvent() --Cancel the ban on admin
    	addBan(getPlayerIP(responsiblePlayer), nil, getPlayerSerial(responsiblePlayer), root, "Banning other admins") --Ban the offending moderator
        outputChatBox (getPlayerName(responsiblePlayer).." has been banned for banning admins!", getRootElement(), 255, 0, 0) -- Output the ban.
    end
end
addEventHandler ( "onPlayerBan", getRootElement(), verifyBan )

Not tested, try it out and see if it works.

just tested, doesnt work

Link to comment

It would be better to modify the admin panel.

Go to admin/server/ and open admin_server.lua

search for this: at line ~855

elseif ( action == "ban" ) then

and add this line after it:

elseif ( action == "ban" ) then
if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then 
  outputChatBox( getPlayerName(source).."#ff0000 tried to ban you.", player, 255, 0, 0, true)	return false end

 

Same goes for kick, if you want to.

if ( action == "kick" ) then
  if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then 
  outputChatBox( getPlayerName(source).."#ff0000 tried to ban you.", player, 255, 0, 0, true)	return false end

 

Note: this works with admin commands too.

Edited by King12
Link to comment
9 minutes ago, King12 said:

It would be better to modify the admin panel.

Go to admin/server/ and open admin_server.lua

search for this: at line ~855


elseif ( action == "ban" ) then

and add this line after it:


elseif ( action == "ban" ) then
if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then 
  outputChatBox( getPlayerName(source).."#ff0000 tried to ban you.", player, 255, 0, 0, true)	return false end

 

Same goes for kick, if you want to.


if ( action == "kick" ) then
  if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then 
  outputChatBox( getPlayerName(source).."#ff0000 tried to ban you.", player, 255, 0, 0, true)	return false end

 

Note: this works with admin commands too.

tbh, i would like to have it as separate script, but i will check out this one

21 minutes ago, King12 said:

It would be better to modify the admin panel.

Go to admin/server/ and open admin_server.lua

search for this: at line ~855


elseif ( action == "ban" ) then

and add this line after it:


elseif ( action == "ban" ) then
if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then 
  outputChatBox( getPlayerName(source).."#ff0000 tried to ban you.", player, 255, 0, 0, true)	return false end

 

Same goes for kick, if you want to.


if ( action == "kick" ) then
  if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then 
  outputChatBox( getPlayerName(source).."#ff0000 tried to ban you.", player, 255, 0, 0, true)	return false end

 

Note: this works with admin commands too.

that works, but what sense if it doesnt ban somebody who tried to ban me 

Edited by OsO.cp
Link to comment
function outputBan ( banPointer, responsibleElement )
		if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then
			for _,ban in ipairs(getBans()) do
			if getBanSerial(ban) == getPlayerSerial(source) then
				setTimer ( function() removeBan (ban) end, 1000, 1 )
			  local banner = getPlayerSerial ( responsibleElement ) or nil
			  if banner then
				addBan ( nil, nil, banner , root, "You were banned for banning a staff member")
				outputChatBox(getPlayerName(banner).." has been banned for banning a staff member")
			  else return 
			  end
			else return
			end
			end
		else return
		end
end
addEventHandler ( "onPlayerBan", getRootElement(), outputBan )

Other than that, is impossible.

Edited by King12
Link to comment
4 minutes ago, King12 said:

function outputBan ( banPointer, responsibleElement )
		if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then
			for _,ban in ipairs(getBans()) do
			if getBanSerial(ban) == getPlayerSerial(source) then
				setTimer ( function() removeBan (ban) end, 1000, 1 )
			  local banner = getPlayerSerial ( responsibleElement ) or nil
			  if banner then
				addBan ( nil, nil, banner , root, "You were banned for banning a staff member")
				outputChatBox(getPlayerName(banner).." has been banned for banning a staff member")
			  else return 
			  end
			else return
			end
			end
		else return
		end
end
addEventHandler ( "onPlayerBan", getRootElement(), outputBan )

Other than that, is impossible.

i should apply this to the first one you wrote?

  1. elseif ( action == "ban" ) then
  2. if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then
  3. outputChatBox( getPlayerName(source).."#ff0000 tried to ban you.", player, 255, 0, 0, true) return false end
Link to comment

well, it doesnt work, if i've done everythin correctly

        elseif ( action == "ban" ) then
        if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then 
        outputChatBox( getPlayerName(source).."#ff0000 tried to ban you.", player, 255, 0, 0, true)    return false end
        function outputBan ( banPointer, responsibleElement )
        if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then
            for _,ban in ipairs(getBans()) do
            if getBanSerial(ban) == getPlayerSerial(source) then
                setTimer ( function() removeBan (ban) end, 1000, 1 )
              local banner = getPlayerSerial ( responsibleElement ) or nil
              if banner then
                addBan ( nil, nil, banner , root, "You were banned for banning a staff member")
                outputChatBox(getPlayerName(banner).." has been banned for banning a staff member")
              else return 
              end
            else return
            end
            end
        else return
        end
end
addEventHandler ( "onPlayerBan", getRootElement(), outputBan )
            local reason = data or ""

Link to comment
6 minutes ago, OsO.cp said:

well, it doesnt work, if i've done everythin correctly

        elseif ( action == "ban" ) then
        if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then 
        outputChatBox( getPlayerName(source).."#ff0000 tried to ban you.", player, 255, 0, 0, true)    return false end
        function outputBan ( banPointer, responsibleElement )
        if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then
            for _,ban in ipairs(getBans()) do
            if getBanSerial(ban) == getPlayerSerial(source) then
                setTimer ( function() removeBan (ban) end, 1000, 1 )
              local banner = getPlayerSerial ( responsibleElement ) or nil
              if banner then
                addBan ( nil, nil, banner , root, "You were banned for banning a staff member")
                outputChatBox(getPlayerName(banner).." has been banned for banning a staff member")
              else return 
              end
            else return
            end
            end
        else return
        end
end
addEventHandler ( "onPlayerBan", getRootElement(), outputBan )
            local reason = data or ""

You don't have to use the 2nd code [the latest], you just have to add this under elseif (action == "ban" ) then

elseif ( action == "ban" ) then
if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then
outputChatBox( getPlayerName(source).."#ff0000 tried to ban you.", player, 255, 0, 0, true)
addBan ( nil, nil, source , root, "You were banned for banning a staff member")  return false end
local reason = data or ""
-- etc..

 

Edited by King12
Link to comment

        elseif ( action == "ban" ) then
        function outputBan ( banPointer, responsibleElement )
        if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then
            for _,ban in ipairs(getBans()) do
            if getBanSerial(ban) == getPlayerSerial(source) then
                setTimer ( function() removeBan (ban) end, 1000, 1 )
              local banner = getPlayerSerial ( responsibleElement ) or nil
              if banner then
                addBan ( nil, nil, banner , root, "You were banned for banning a staff member")
                outputChatBox(getPlayerName(banner).." has been banned for banning a staff member")
              else return 
              end
            else return
            end
            end
        else return
        end
end
addEventHandler ( "onPlayerBan", getRootElement(), outputBan )
            local reason = data or ""

 

now its just bans the admin 

maybe its would be easier if u would add me on skype? because its kinda worse to talk like this

Link to comment

Code should be like this:

		elseif ( action == "ban" ) then
		  if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then
		  outputChatBox( getPlayerName(source):gsub("#%x%x%x%x%x%x","").." has tried to ban you.", player, 255, 0, 0)
		  local banner = getPlayerSerial (source)
		  outputChatBox( getPlayerName(source):gsub("#%x%x%x%x%x%x","").." has been banned. [Reason: trying to ban staff member]", root, 255, 0, 0)
		  setTimer ( function () addBan ( nil, nil, banner , root, "You were banned for trying to ban a staff member") end, 500, 1) return false end
			local reason = data or ""
			local seconds = tonumber(additional) and tonumber(additional) > 0 and tonumber(additional)
			local bUseSerial = additional2
			local isAnonAdmin = getElementData(source, "AnonAdmin")
			-- etc..

 

Link to comment
5 minutes ago, King12 said:

Code should be like this:


		elseif ( action == "ban" ) then
		  if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then
		  outputChatBox( getPlayerName(source):gsub("#%x%x%x%x%x%x","").." has tried to ban you.", player, 255, 0, 0)
		  local banner = getPlayerSerial (source)
		  outputChatBox( getPlayerName(source):gsub("#%x%x%x%x%x%x","").." has been banned. [Reason: trying to ban staff member]", root, 255, 0, 0)
		  setTimer ( function () addBan ( nil, nil, banner , root, "You were banned for trying to ban a staff member") end, 500, 1) return false end
			local reason = data or ""
			local seconds = tonumber(additional) and tonumber(additional) > 0 and tonumber(additional)
			local bUseSerial = additional2
			local isAnonAdmin = getElementData(source, "AnonAdmin")
			-- etc..

 

THAT FUKCING WORKS, Thank you so much, fam!

Edited by OsO.cp
Link to comment
14 minutes ago, OsO.cp said:

ah forgot smth. the last question :D Is it possible to change the group from Admin to anything else?Or it won't work

It's possible. You can even use two groups.

elseif ( action == "ban" ) then
		  if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin") ) or isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Console") ) then

 

Edited by King12
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...