• 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!

TFS 0.X Anti-MC with coldown.

Otlandserv

Member
Joined
May 22, 2023
Messages
58
Reaction score
5
Hello!
I need anti-MC script with coldown? [ TFS 0.3.7 ]
I have this one: ANTI_MC but i need re-login security.

How to add this one to script?
(The script should check if the player exists then after that removes, because the player can logoff many times and after a few short time the server crash).
 
I haven't tested it yet, but I put a cooldown time of 1 hour. Let's see if it works

Lua:
local config = {
    max = 3, -- Maximum Clients Allowed Connected
    text = "Sorry, we only allow up to 3 Multi-Clients.", -- PopupFYI Text
    group_id = 1 -- This will only kick players with Group 1 (Player)
}

local accepted_ip_list = "127.0.0.1" -- IP's allowed to MC

local cooldown = 3600 -- Cooldown period in seconds (1 hour)
local cooldowns = {} -- Cooldown table to track players

local function AntiMC(p)
    local playerId = p.pid
    local playerIp = getPlayerIp(playerId)
  
    if #getPlayersByIp(playerIp) >= p.max then
        if not cooldowns[playerId] or (os.time() - cooldowns[playerId]) >= cooldown then
            doPlayerPopupFYI(playerId, config.text)
            addEvent(doRemoveCreature, 2500, playerId)
            cooldowns[playerId] = os.time()
        end
    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

or

Lua:
local config = {
     max = 3, -- Maximum Clients Allowed Connected
     text = "Sorry, we only allow up to 3 Multi-Clients.", -- PopupFYI Text
    group_id = 1 -- This will only kick players with Group 1 (Player)
}

local accepted_ip_list = "127.0.0.1" -- IP's allowed to MC

local cooldown = 3600 -- Cooldown period in seconds (1 hour)
local cooldowns = {} -- Cooldown table to track players

local function AntiMC(p)
    local playerId = p.pid
    local playerIp = getPlayerIp(playerId)
   
    if #getPlayersByIp(playerIp) >= p.max then
        if not cooldowns[playerId] or (os.time() - cooldowns[playerId]) >= cooldown then
            doPlayerPopupFYI(playerId, config.text)
            addEvent(doRemoveCreature, 2500, playerId)
            cooldowns[playerId] = os.time()
        end
    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

function onLogout(cid)
    cooldowns[cid] = os.time()
    return TRUE
end
 
Last edited:
Back
Top