Anti-mc - freeze server

metiu11

Well-Known Member
Joined
Mar 26, 2011
Messages
82
Reaction score
4
Heyo again :D TFS 0.3.6
I found script like this - anti MC
It works but this script kicked player when he log MC and freeze server like 1-2 sec.
Do you have an idea how to block login and send information to the player in the client when choosing a character?
I am pretty sure to just change "doRemoveCreature(p.pid)" in another but i dont know what function can do that...
Code:
local config = {
        max = 1,
        text = "Multi-Client or Magebomb is not allowed.",
        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 = ""  -- here put the Ips you want to be 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})
                        doPlayerPopupFYI(cid, config.text)
                end
        end
        return TRUE
end
 

chupaescadatri

Intermediate OT User
Joined
Jul 5, 2014
Messages
333
Reaction score
41
Heyo again :D TFS 0.3.6
I found script like this - anti MC
It works but this script kicked player when he log MC and freeze server like 1-2 sec.
Do you have an idea how to block login and send information to the player in the client when choosing a character?
I am pretty sure to just change "doRemoveCreature(p.pid)" in another but i dont know what function can do that...
Code:
local config = {
        max = 1,
        text = "Multi-Client or Magebomb is not allowed.",
        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 = ""  -- here put the Ips you want to be 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})
                        doPlayerPopupFYI(cid, config.text)
                end
        end
        return TRUE
end

yes

Change:
Code:
players.append_attribute("online") = std::to_string(g_game.getPlayersOnline()).c_str();
To this:
Code:
uint32_t real = 0;

std::map<uint32_t, uint32_t> listIP;

for (const auto& it : g_game.getPlayers()) {
   if (it.second->getIP() != 0) {
      auto ip = listIP.find(it.second->getIP());
      if (ip != listIP.end()) {
         listIP[it.second->getIP()]++;
         if (listIP[it.second->getIP()] < 5) {
            real++;
         }
      } else {
         listIP[it.second->getIP()] = 1;
         real++;
      }
   }
}
players.append_attribute("online") = std::to_string(real).c_str();
protocolstatus.cpp (TFS 1.0/1.1/1.2)

gunz script: Very important - Rules change on otservlist.org (https://otland.net/threads/very-important-rules-change-on-otservlist-org.247531/post-2407794)
 
OP
metiu11

metiu11

Well-Known Member
Joined
Mar 26, 2011
Messages
82
Reaction score
4
@chupaescadatri cool but its for TFS 1.0/1.1/1.2 i read posts about this and they dont create the same code for TFS 0.3.6, maybe someone have it?
 
OP
metiu11

metiu11

Well-Known Member
Joined
Mar 26, 2011
Messages
82
Reaction score
4
@chupaescadatri tried now and dont worked... :( Script kick MC not giving info to him "u cannot login with MC". Kick freezing server
 

chupaescadatri

Intermediate OT User
Joined
Jul 5, 2014
Messages
333
Reaction score
41
@chupaescadatri tried now and dont worked... :( Script kick MC not giving info to him "u cannot login with MC". Kick freezing server
yes but only a tip, player to log off and log in and give a freeze, it's mysql and hd error
my one gave the same error, formatted the pc put in a clean HD and optimized the max_allowed_packet to 25mb
in hd ssd and stopped
 
OP
metiu11

metiu11

Well-Known Member
Joined
Mar 26, 2011
Messages
82
Reaction score
4
@chupaescadatri Well, now i used my own computer to test this server, dont have hosting now. I have SSD, 16 GB ram, i5 3.2 ghz, GTX 970. So i think its enough to host 2 players. Its weird... Where can i optimize the max_allowed_packet? I thinking if i block people before they login this freeze will disappeared
 
OP
metiu11

metiu11

Well-Known Member
Joined
Mar 26, 2011
Messages
82
Reaction score
4
@chupaescadatri i have hosting, tried to change it with mysql anyway i have similar 25mb now and this freeze still being... Now i see that problem is when someone log in or log off, just freeze server 2-3 sec... can u help me with this?
 

Sarah Wesker

ค∂vαηcε รүηтαx ❤
Joined
Mar 16, 2017
Messages
412
Reaction score
237
Location
London
a good idea would be to start with "protocollogin.cpp" and make a small temporary ban system with a slightly more discreet message.
 
OP
metiu11

metiu11

Well-Known Member
Joined
Mar 26, 2011
Messages
82
Reaction score
4
Okay i got new informations. :D
First... Its not the problem with this script, its problem with my database.
Second... I open local database with xampp, then test it and its works good, dont have freeze.
I currently use hosting only for the database. The server is enabled on my private computer and we use hamachi. It seems that connecting to the database every time someone tries to log on to the server takes a long time. Can it be the fault of hosting on a private computer? If I move to a dedicated server, will the problem disappear?
 
Top