PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: michael on 22 December, 2004, 11:11:00

Title: !table / LANPARTY!!! :)
Post by: michael on 22 December, 2004, 11:11:00
Hi all  :]

Another person and me have a LAN party, sometimes I want to know witch table number that person has.

Ok my question,

If I do !table
I want that the script checks for me on witch table that person has.

The script can filter the table number out an file (table.txt)

123.123.123.123 = table 3
123.123.123.124 = table 4

so if I do !table the script is looking for his ip and then look in the txt file witch table number it is, and then he is saying has table number ?.

This function must only be available for an OP and above

Can someone make this script for me pls ?

Gr Michael  :))

(bad English :S  :( :( )
Title:
Post by: michael on 23 December, 2004, 09:22:31
Nobody ?  :(
Title:
Post by: blackwings on 23 December, 2004, 10:12:58
Tomorrow its christmas and many a probably busy with planing stuff or helping friends and family. For the moment I will give a idea of solving the reqeust. It's pretty newbie idea, but it would solve your request and if a skilled lua programmer finds the time, he/she can quickly use my idea to solve it.

My idea is this. Instead of this script checks everyone that connect, it does it thing though a command instead. The bad thing about the idea is that you need 1 copy for the script for each table on the party. But to make it easier for the person that use the commands. the commands could be like =
!table1
!table2
!table3
!table4

and you get a answer if user IS or IS NOT from that table.

I will later try to solve it myself, but I can't promise anything, because I have just newbie lua skills :P
--//Idea for the table checker
--//The IP handling is taken from RangeBlaster v2.05 by Phatty


Bot = "TABLE-CHECKER"

Ranges = {}

function Main()
LoadIps()
end

--------------------------------------------------------------------------------------------------
-- Load Ips
function LoadIps()
local tmp = 0
local handle = openfile("LANtable/table1.dat","r")
line = read(handle)
while line do
tmp = tmp + 1
local s,e,ipr1,ipr2 = strfind(line,"(%S+)|(%S+)")
if ipr2 == nil then
end
Ranges[ipr1] = ipr2
line = read(handle)
end
end
--------------------------------------------------------------------------------------------------
-- IP handle
function Blocked(userip)
local s,e,range1,range2,range3,range4 = strfind(userip,"(%d+).(%d+).(%d+).(%d+)")
for i,p in Ranges do
local s,e,ipa1,ipb1,ipc1,ipd1 = strfind(i, "(%d*).(%d*).(%d*).(%d*)")
local s,e,ipa2,ipb2,ipc2,ipd2 = strfind(p, "(%d*).(%d*).(%d*).(%d*)")
if range1 == ipa1 then
if range1 < ipa1 or range1 > ipa2 then
else
if range2 < ipb1 or range2 > ipb2 then
else
if range3 < ipc1 or range3 > ipc2 then
else
if range4 < ipd1 or range4 > ipd2 then
else
collectgarbage()
flush()
return 1
end
end
end
end
end
end
end

--------------------------------------------------------------------------------------------------
-- Action
function DataArrival(user,data)
if (strsub(data, 1, 8) == "$Version") then
if Blocked(user.sIP) == 1 then
-- Message that says that the user is from this table
else
-- Message that says that the user is NOT from this table
end
end
end
--------------------------------------------------------------------------------------------------
Title:
Post by: michael on 23 December, 2004, 10:20:26
Hi

i am a noob about lua scripts  :D
i hope that someone els can make it for me

thanks blackwings for your reply  :))

Grz Michael
Title:
Post by: NightLitch on 23 December, 2004, 15:32:27
If I understand you each "Table" the place where you sit has it's own IP ????

or you just want to know what IP that user have ???

Or you have placed out special IP number for just that "Table" where the user is sitting in the room...

I need to understand your idea...

Have done a half script... but need to now how you wanted it...

/NightLitch
Title:
Post by: NightLitch on 23 December, 2004, 15:46:53
This should take care of your request I hope...

--###############################################--
-- IP - Table -- By NightLitch 2004-12-23 --
--###############################################--
BotName = "T-Bot"
Version = "0.1"
TableCommand = "!table"
--###############################################--
IpTable = {

["123.123.123.121"] = "Table 1",
["123.123.123.122"] = "Table 2" ,
["123.123.123.123"] = "Table 3",
["123.123.123.124"] = "Table 4",
["123.123.123.125"] = "Table 5",
["123.123.123.126"] = "Table 6",
["123.123.123.127"] = "Table 7",
["123.123.123.128"] = "Table 8",
["123.123.123.129"] = "Table 9",
["123.123.123.130"] = "Table 10",

-- continue type in amount of ip's with table numbers...
}
--###############################################--
function DataArrival(sUser,sData)
if strsub(sData, 1,1) == "<" then
local _,_,Cmd,Arg = strfind(sData, "%b<>%s+(%S+)%s*(.*)%|")
if Command[Cmd] and sUser.bOperator then
return Command[Cmd](sUser,Arg)
end
end
end
--###############################################--
Command = {}
Command[TableCommand] = function(sUser,sArg)
local _,_,Nickname = strfind(sArg, "(%S+)")
if Nickname == nil then sUser:SendData(BotName, "Syntax: !table ") return 1 end
local tUser = GetItemByName(Nickname)
if tUser == nil then sUser:SendData(BotName, "User "..Nickname.." is not online or wrong username.") return 1 end
sUser:SendData(BotName, "User "..tUser.sName.." have IP "..tUser.sIP.." and sits at "..IpTable[tUser.sIP])
return 1
end
--###############################################--
--// NightLitch 2004-12-23

Merry Christmas // NightLitch
Title:
Post by: michael on 23 December, 2004, 16:03:54
( the place where you sit has it's own IP ??)

Yes every table has his own ip
Title:
Post by: 6Marilyn6Manson6 on 23 December, 2004, 16:11:59
Good work NightLight... ;) bye King Of Lua :P
Title:
Post by: blackwings on 23 December, 2004, 19:47:15
ya, NL script is great, so I don't have to make a crappy script with my newbie lua skills :P
Title:
Post by: michael on 23 December, 2004, 21:51:46
I made a mistake :(

Your script is working perfect :)

I had written the wrong ip in the script

Thank you very much

Gr Michael :D:D:D:D
Title:
Post by: Madman on 23 December, 2004, 23:20:30
Just to avoid the Error you got before... ;)

--###############################################--
-- IP - Table -- By NightLitch 2004-12-23 --
-- Updated By Madman
--###############################################--
BotName = "T-Bot"
Version = "0.1"
TableCommand = "!table"
--###############################################--
IpTable = {

["123.123.123.121"] = "Table 1",
["123.123.123.122"] = "Table 2" ,
["123.123.123.123"] = "Table 3",
["123.123.123.124"] = "Table 4",
["123.123.123.125"] = "Table 5",
["123.123.123.126"] = "Table 6",
["123.123.123.127"] = "Table 7",
["123.123.123.128"] = "Table 8",
["123.123.123.129"] = "Table 9",
["123.123.123.130"] = "Table 10",

-- continue type in amount of ip's with table numbers...
}
--###############################################--
function DataArrival(sUser,sData)
if strsub(sData, 1,1) == "<" then
local _,_,Cmd,Arg = strfind(sData, "%b<>%s+(%S+)%s*(.*)%|")
if Command[Cmd] and sUser.bOperator then
return Command[Cmd](sUser,Arg)
end
end
end
--###############################################--
Command = {}
Command[TableCommand] = function(sUser,sArg)
local _,_,Nickname = strfind(sArg, "(%S+)")
if Nickname == nil then sUser:SendData(BotName, "Syntax: "..TableCommand.." ") return 1 end
local tUser = GetItemByName(Nickname)
if tUser == nil then sUser:SendData(BotName, "User "..Nickname.." is not online or wrong username.") return 1 end
if IpTable[tUser.sIP] == nil then sUser:SendData(BotName, "User dont have a IP that is in the table") return 1 end
sUser:SendData(BotName, "User "..tUser.sName.." have IP "..tUser.sIP.." and sits at "..IpTable[tUser.sIP])
return 1
end
--###############################################--
--// NightLitch 2004-12-23


now the script tells if the user dont have a IP that is in the table =)
Title:
Post by: michael on 24 December, 2004, 00:06:13
Yes it works :D:D

Thanks   :D

Grz Michael