• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved anti mc exception list

Sun

Knowledge is power - France is bacon
Joined
Jan 26, 2015
Messages
333
Solutions
22
Reaction score
244
Hello. The "accepted_ip_list" is not working in this ani mc script I'm using

I think this part needs to be edited so it check if an ip is in the accepted list first or not, but I'm not sure how to do it (I tried but failed)
Code:
local function antiMC(p)
        if #getPlayersByIp(getPlayerIp(p.pid)) >= p.max then
                doRemoveCreature(p.pid)
        end
        return TRUE
end

The whole script
Code:
local config = {
        max = 3,
        group_id = 1  -- it will only kick player whit that id (1=Players, 2=tutor, 3=seniortutors, 4=Gm's, 5=Cm's and 6=God's
}

local accepted_ip_list = {"127.0.0.1", "xx.xxx.xxx.xx"} -- the Ip's entered here are allowed to use Mc/Magebomb..

local function antiMC(p)
        if #getPlayersByIp(getPlayerIp(p.pid)) >= p.max then
                doRemoveCreature(p.pid)
        end
        return TRUE
end

function onLogin(cid)
        if getPlayerGroupId(cid) <= config.group_id then
                if isInArray(accepted_ip_list,getPlayerIp(cid)) == FALSE then
                        addEvent(antiMC, 1000, {pid = cid, max = config.max+1})
                end
        end
        return TRUE
end
 
IP address is not a string, it is a 32 bit integer where each 8 bits (1 byte) represent each field of the IP address.

For 127.0.0.1 you would use 0x7F000001 instead, or 2130706433 if you prefer base 10.
For other values, you can use this tool: http://www.miniwebtool.com/ip-address-to-hex-converter/

If you prefer to use Lua strings, you can convert numeric IPs with the following:
Code:
function ipToStr(ip)
    local a, b, c, d = math.floor(ip / 16777216), math.floor(ip / 65536) % 256, math.floor(ip / 256) % 256, ip % 256
    return a .. "." .. b .. "." .. c .. "." .. d
end
 
Last edited:
Solved it by changing

Code:
if isInArray(accepted_ip_list,getPlayerIp(cid)) == FALSE then

to

Code:
if isInArray(accepted_ip_list, doConvertIntegerToIp(getPlayerIp(cid))) == FALSE then
 
Woops, it only works if there's 1 IP in the accepted list.
I only needed to allow 1 IP so I don't need a solution to that.
However it might be good if someone else with the same or a similar problem comes by this thread.

also @Lordfire thanks for trying to help out. I appreciate it.
 
Back
Top