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

Lua [TFS 1.X] player:Disconnect() ?

Maldero

/root/
Joined
Oct 2, 2010
Messages
62
Reaction score
1
Location
Szczecin, Poland
Hello all,
my question is: possible is to do function which will be disconnecting player?
player:remove() kick player from the server, but I need function which disconnect player from the server but if he has pz then don's kick him but only close connection and player stay alive to pz time.
 
What you are aiming for is not allowing more than x character per ip, is that right?
Then you just need to make an onLogin and check if there's already x characters online with that ip, if there is, then return false.
 
I writed this code, but if first logged player has pz battle it can't log him..
Becouse he may think "oo I got red skull and got battle then i can log in my second character as mc and it will kick me so I will not have pz after relog.."
Then i search help in idea or code for disconnecting not kicking player.
 
Well, what I said would be to prevent the second char from logging in, and not kicking the two characters.
For example:

Code:
ipMapping = {}
local maxMc = 2

function onLogin(player)
   local playerIp = player:getIp()
   ipMapping[playerIp] = ipMapping[playerIp] and ipMapping[playerIp] + 1 or 1
   if ipMapping[playerIp] > maxMc then
     player:sendTextMessage(MESSAGE_INFO_DESCR, "You can only login two characters per IP.\nYou'll be disconnected in 3 seconds.")
     addEvent(function(playerId)
         local player = Player(playerId)
         if player then
           player:remove()
         end
       end, 3000, player:getId())
   end

   return true
end

function onLogout(player)
   local playerIp = player:getIp()
   ipMapping[playerIp] = ipMapping[playerIp] - 1 < 1 and nil or ipMapping[playerIp] - 1
   return true
end

This is what I use in my OT to prevent more than two characters per IP.
 
Back
Top