Jump to content

Auto Unban


Recommended Posts

Hey guys, you can notice what i am doing down there. When Serial.Here1, ect... it then unban's then automatically. But this doesnt work, i started it, and i banned myself, and it didnt unban my lan ip. Does anyone see a problem with this script, and please let me know. I have hidden the serials and ip's just in case.

function autounban() 
local serial = getBanSerial(source) 
if serial == "Serial.Here1" then 
removeBan("Serial.Here1", getRootElement()) 
removeBan("123.211.166.320 ", getRootElement()) 
end 
if serial == "Serial.Here2" then 
removeBan("Serial.Here2", getRootElement()) 
removeBan("180.216.166.250", getRootElement()) 
end 
if serial == "Serial.Here3" then 
removeBan("Serial.Here3", getRootElement()) 
removeBan("125.215.166.490", getRootElement()) 
end 
if serial == "Serial.Here4" then 
removeBan("Serial.Here5", getRootElement()) 
removeBan("7.21.203.46", getRootElement()) 
end 
end 
addEventHandler("onPlayerBan",getRootElement(),autounban) 

Link to comment

Because, you are trying to get the ban serial of the player, not the ban pointer.

function autounban(banPointer) 
local serial = getBanSerial(banPointer) 
for index, ban in pairs(getBans()) do 
      if getBanSerial(ban) == serial then 
           removeBan ( ban, getRootElement() ) 
          end 
     end 
end 
addEventHandler("onPlayerBan",getRootElement(),autounban) 

You can't unban from a IP/serial If i'm right, you need to remove the ban himself.

Link to comment
Because, you are trying to get the ban serial of the player, not the ban pointer.
function autounban(banPointer) 
local serial = getBanSerial(banPointer) 
for index, ban in pairs(getBans()) do 
      if getBanSerial(ban) == serial then 
           removeBan ( ban, getRootElement() ) 
          end 
     end 
end 
addEventHandler("onPlayerBan",getRootElement(),autounban) 

You can't unban from a IP/serial If i'm right, you need to remove the ban himself.

I dont quite understand, it doesnt work :|, could you explain more?

Link to comment

Well, here works perfectly, are you sure you are banning by serial? I get no bad argument and in console says: "UNBAN: A ban was removed by Console"

P.S: I've added to check IP too,

function autounban(banPointer) 
local serial = getBanSerial(banPointer) 
local ip = getBanIP(banPointer) 
for index, ban in pairs(getBans()) do 
      if getBanSerial(ban) == serial or getBanIP(ban) == ip then 
           removeBan ( ban, getRootElement() ) 
          end 
     end 
end 
addEventHandler("onPlayerBan",getRootElement(),autounban) 

Link to comment
Well, here works perfectly, are you sure you are banning by serial? I get no bad argument and in console says: "UNBAN: A ban was removed by Console"

P.S: I've added to check IP too,

function autounban(banPointer) 
local serial = getBanSerial(banPointer) 
local ip = getBanIP(banPointer) 
for index, ban in pairs(getBans()) do 
      if getBanSerial(ban) == serial or getBanIP(ban) == ip then 
           removeBan ( ban, getRootElement() ) 
          end 
     end 
end 
addEventHandler("onPlayerBan",getRootElement(),autounban) 

Ok, well im doing it wrong? So i cant put in my serial? because will this unban everyone? we need it so it unbans our serials, if someone abuses admin.

Link to comment
Do this, make a list of serials in a table, then when someone get's banned, compare their serials.

Ok, i have never worked with tables: but here is my dumb attempt, and how do i compare? Im really sorry, but i have no idea, and if you help at least i learn that way :|:

serial1={CE99D8528E47A68C3BEAC89638D7A344} 
function autounban(banPointer) 
local serial = getBanSerial(banPointer) 
for index, ban in pairs(getBans()) do 
      if getBanSerial(ban) == serial then 
           removeBan ( ban, getRootElement() ) 
          end 
     end 
end 
addEventHandler("onPlayerBan",getRootElement(),autounban) 
  

Link to comment

That's wrong, use this:

local serials = { 
    ["CE99D8528E47A68C3BEAC89638D7A344"] = true, 
} 
  
function autounban(banPointer) 
local serial = getBanSerial(banPointer) 
local ip = getBanIP(banPointer) 
for index, ban in pairs(getBans()) do 
      if serials[serial] and getBanSerial(ban) == serial or getBanIP(ban) == ip then 
           removeBan ( ban, getRootElement() ) 
          end 
     end 
end 
addEventHandler("onPlayerBan",getRootElement(),autounban) 

Link to comment
That's wrong, use this:
local serials = { 
    ["CE99D8528E47A68C3BEAC89638D7A344"] = true, 
} 
  
function autounban(banPointer) 
local serial = getBanSerial(banPointer) 
local ip = getBanIP(banPointer) 
for index, ban in pairs(getBans()) do 
      if serials[serial] and getBanSerial(ban) == serial or getBanIP(ban) == ip then 
           removeBan ( ban, getRootElement() ) 
          end 
     end 
end 
addEventHandler("onPlayerBan",getRootElement(),autounban) 

Thank you SolidSnake, it took me awhile to figure out how to add more tables, i understand now, thank you alot :D

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