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

TalkAction Multi(-client) checking

elf

Sing, sing blue silver
Senator
Joined
Dec 11, 2007
Messages
3,666
Solutions
1
Reaction score
125
Location
Warsaw, Poland
GitHub
tayandenga
Twitch
tayandenga
Note: This talkaction is included to TheForgottenServer 0.3 since Alpha 3.

Create multicheck.lua located in data/talkactions/scripts and paste there:
Code:
function onSay(cid, words, param)
	if(getPlayerAccess(cid) == 0) then
		return TRUE
	end

	local players = getOnlinePlayers()
	local IPs = {}
	local multiClients = {}
	local multiClientIPs = {}
	for i, player in ipairs(players) do
		local ip = getIPByName(player)
		local pos = table.find(IPs, ip)
		if(pos ~= nil) then
			if(not table.isStrIn(players[pos], multiClients)) then
				table.insert(multiClients, players[pos])
				table.insert(multiClientIPs, ip)
			end
			table.remove(players, pos)
			table.remove(IPs, pos)
			table.insert(multiClients, player)
			table.insert(multiClientIPs, ip)
		end
		table.insert(IPs, ip)
	end

	if(table.maxn(multiClients) > 0) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Currently online players with same IP address(es):")
		for i, multiClient in ipairs(multiClients) do
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, multiClient .. " (" .. convertIntToIP(multiClientIPs[i]) .. ")")
		end
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Currently there aren't any players with same IP address(es).")
	end
	return FALSE
end
Open talkactions.xml located in data/talkactions and add there:
Code:
<talkaction words="/mc" script="multicheck.lua"/>

Now you need to add the following functions to global.lua:
Code:
function convertIntToIP(int, mask)
	local mask = mask or 4294967295

	local b4 = bit.urshift(bit.uband(int, 4278190080), 24)
	local b3 = bit.urshift(bit.uband(int, 16711680), 16)
	local b2 = bit.urshift(bit.uband(int, 65280), 8)
	local b1 = bit.urshift(bit.uband(int, 255), 0)
	if(mask ~= nil) then
		local m4 = bit.urshift(bit.uband(mask, 4278190080), 24)
		local m3 = bit.urshift(bit.uband(mask, 16711680), 16)
		local m2 = bit.urshift(bit.uband(mask, 65280), 8)
		local m1 = bit.urshift(bit.uband(mask, 255), 0)
		if((m1 == 255 or m1 == 0) and (m2 == 255 or m2 == 0) and (m3 == 255 or m3 == 0) and (m4 == 255 or m4 == 0)) then
			if m1 == 0 then b1 = "x" end
			if m2 == 0 then b2 = "x" end
			if m3 == 0 then b3 = "x" end
			if m4 == 0 then b4 = "x" end
		else
			if(m1 ~= 255 or m2 ~= 255 or m3 ~= 255 or m4 ~= 255) then
				return b1 .. "." .. b2 .. "." .. b3 .. "." .. b4 .. " : " .. m1 .. "." .. m2 .. "." .. m3 .. "." .. m4
			end
		end
	end
	
	return b1 .. "." .. b2 .. "." .. b3 .. "." .. b4
end

table.isStrIn = function (txt, str)
	local result = false
	for i, v in pairs(str) do
		result = (string.find(txt, v) and not string.find(txt, '(%w+)' .. v) and not string.find(txt, v .. '(%w+)'))
		if(result) then
			break
		end
	end
	return result
end

getIPByName = getIPByPlayerName

Note: If you're using other distribution than TFS, please make sure that you have the following function: getIPByPlayerName or getIPByName.
 
Last edited:
Elf
Excelent script :D

PD:
How to recognize a LAN connection?
 
So if 2 people are playing on the same LAN and you banish them? :p

No, you investigate it. Go and ask one of them why they are Mcing, they will probably have a bad reason if they aint using the same lan. Otherwise they will probably say that they are using the same network. Its all about being a bit aggressive yet understanding.

//Massen
 
error maybe, huh?

Code:
[19/10/2008  22:02:09] Lua Script Error: [TalkAction Interface] 
[19/10/2008  22:02:09] data/talkactions/scripts/mc.lua:onSay

[19/10/2008  22:02:09] data/talkactions/scripts/mc.lua:38: attempt to call global 'getIPByName' (a nil value)
[19/10/2008  22:02:09] stack traceback:
[19/10/2008  22:02:09] 	data/talkactions/scripts/mc.lua:38: in function <data/talkactions/scripts/mc.lua:28>
Sorry forgot :p
Heres a error report:
Code:
[19/10/2008  22:02:09] Lua Script Error: [TalkAction Interface] 
[19/10/2008  22:02:09] data/talkactions/scripts/mc.lua:onSay

[19/10/2008  22:02:09] data/talkactions/scripts/mc.lua:38: attempt to call global 'getIPByName' (a nil value)
[19/10/2008  22:02:09] stack traceback:
[19/10/2008  22:02:09] 	data/talkactions/scripts/mc.lua:38: in function <data/talkactions/scripts/mc.lua:28>
 
Back
Top