• 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

leandroluck

New Member
Joined
Dec 24, 2010
Messages
104
Reaction score
1
Code:
local AccForIp = 2

function onLogin(player)

    local mc = 0
    for _, check in ipairs(Game.getPlayers()) do
        if player:getIp() == check:getIp() then
            mc = mc + 1
            if mc > AccForIp then
                return false
            end
        end
    end

    return true
end
I'm trying to put for him to leave at most 2 mc more if the character is vip he will allow the vip to open up to 3 mc
 
Solution
Code:
local AccForIp = 2
function onLogin(player)

    local mc = 0
    for _, check in ipairs(Game.getPlayers()) do
        if player:getIp() == check:getIp() and not player:isVip() then
            mc = mc + 1
            if mc > AccForIp then
                return false
            end
        end
    end

    return true
end

Try again
Code:
local AccForIp = 2

function onLogin(player)

    local mc = 0
    for _, check in ipairs(Game.getPlayers()) do
        if player:getIp() == check:getIp() then
            mc = mc + 1
            if mc > AccForIp then
                return false
            end
        end
    end

    return true
end
I'm trying to put for him to leave at most 2 mc more if the character is vip he will allow the vip to open up to 3 mc
What is your VIP system?
if, for example, you have the command to check the VIP player for:
player: isVip ()
then your code will look like this:

Code:
local AccForIp = 2

function onLogin(player)

    local mc = 0
    for _, check in ipairs(Game.getPlayers()) do
        if player:getIp() == check:getIp() then
            mc = mc + 1
            if mc > AccForIp and player:isVip() then --Check player VIP
                return true
            else mc > AccForIp then
                return false
            end
        end
    end

    return true
end

Try use this code and return result
 
What is your VIP system?
if, for example, you have the command to check the VIP player for:
player: isVip ()
then your code will look like this:

Code:
local AccForIp = 2

function onLogin(player)

    local mc = 0
    for _, check in ipairs(Game.getPlayers()) do
        if player:getIp() == check:getIp() then
            mc = mc + 1
            if mc > AccForIp and player:isVip() then --Check player VIP
                return true
            else mc > AccForIp then
                return false
            end
        end
    end

    return true
end

Try use this code and return result


I tested the player who is not vip can log in when chars can




What is your VIP system?
player:isVip() - ok
 
Last edited:
Code:
local AccForIp = 2
function onLogin(player)

    local mc = 0
    for _, check in ipairs(Game.getPlayers()) do
        if player:getIp() == check:getIp() and not player:isVip() then
            mc = mc + 1
            if mc > AccForIp then
                return false
            end
        end
    end

    return true
end

Try again
 
Solution
Lua:
local max_free_connections = 2
local max_vip_connections = 3
local connections = {}

function onLogin(player)
    local ip = player:getIp()
    local local_connections = connections[ip]
    if local_connections then
        if (player:isVip() and local_connections >= max_vip_connections) or (local_connections >= max_free_connections) then
            return false
        end
        connections[ip] = local_connections + 1
    else
        connections[ip] = 1
    end
    return true
end

function onLogout(player)
    local ip = player:getIp()
    connections[ip] = connections[ip] - 1
    return true
end

register a logout script for this too, make sure that code is in 1 file not two
 
Lua:
local max_free_connections = 2
local max_vip_connections = 3
local connections = {}

function onLogin(player)
    local ip = player:getIp()
    local local_connections = connections[ip]
    if local_connections then
        if (player:isVip() and local_connections >= max_vip_connections) or (local_connections >= max_free_connections) then
            return false
        end
        connections[ip] = local_connections + 1
    else
        connections[ip] = 1
    end
    return true
end

function onLogout(player)
    local ip = player:getIp()
    connections[ip] = connections[ip] - 1
    return true
end

register a logout script for this too, make sure that code is in 1 file not two


Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/others/antimc.lua:eek:nLogout
data/creaturescripts/scripts/others/antimc.lua:21: attempt to perform arithmetic on field '?' (a nil value)
stack traceback:
[C]: in function '__sub'
data/creaturescripts/scripts/others/antimc.lua:21: in function <data/creaturescripts/scripts/others/antimc.lua:19>


<event type="login" name="AntiMc" script="others/antimc.lua" />
<event type="logout" name="AntiMc" script="others/antimc.lua" />











Code:
local AccForIp = 2
function onLogin(player)

    local mc = 0
    for _, check in ipairs(Game.getPlayers()) do
        if player:getIp() == check:getIp() and not player:isVip() then
            mc = mc + 1
            if mc > AccForIp then
                return false
            end
        end
    end

    return true
end

Try again

Work
 
Last edited:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/others/antimc.lua:eek:nLogout
data/creaturescripts/scripts/others/antimc.lua:21: attempt to perform arithmetic on field '?' (a nil value)
stack traceback:
[C]: in function '__sub'
data/creaturescripts/scripts/others/antimc.lua:21: in function <data/creaturescripts/scripts/others/antimc.lua:19>


<event type="login" name="AntiMc" script="others/antimc.lua" />
<event type="logout" name="AntiMc" script="others/antimc.lua" />













Work
It is a pleasure to help !
despite my little knowledge.
May we spread this feeling and help the next one!
Good luck with your project.
 
Back
Top