PtokaX forum

Archive => Archived 5.0 boards => Finished Scripts => Topic started by: Dessamator on 20 April, 2005, 23:10:12

Title: SIMPLE Online ip checker
Post by: Dessamator on 20 April, 2005, 23:10:12
   
--By Dessamator
--SIMPLE Online ip finder, and server nick finder
bot=frmHub:GetHubBotName()

function ChatArrival(user, data)

data = string.sub(data,1,string.len(data)-1)
s,e,cmd = string.find(data, "%b<>%s+(%S+)")

local s,e,ip = string.find(data, "%b<>%s+%S+%s+(.+)")
if cmd=="!findip" and user.bOperator then
findip(user,ip,1)
return 1
elseif cmd=="!getserver" and user.bOperator then
local hubip=frmHub:GetHubIp()
findip(user,hubip,0)
return 1
end
end
ToArrival=ChatArrival

function findip(user,ip,i)
local check =""
if i==1 and ip then
temp= "\r\n".."\t".."The ip: "..ip.." Belongs to :".."\r\n"
else
temp= "\r\n".."\t".."The Current server is: ".."\r\n"
end
if ip==nil or ip=="" then
user:SendPM(bot,"Syntax error. Correct Syntax is : !findip ")
else
temp=temp.."\t".."??????????????????????".."\r\n"
for _,nick in frmHub:GetOnlineUsers() do
serverip=string.sub(nick.sIP,1,4)
if nick.sIP==ip then
temp=temp.."\t\t".."•"..nick.sName.."\r\n"
check=check..nick.sName
elseif i==0 and serverip=="127." then
temp=temp.."\t\t".."•"..nick.sName.."\r\n"
check=check..nick.sName
elseif (i==0) and not(nick.sIP==ip )  then
temp="The person with the server isnt online!!"
end
end
if check=="" then
user:SendPM(bot,"The User with that ip isnt online")
else
user:SendPM(bot,temp)
temp=nil
serverip=""
check=""
end
end
end


for those who love to ask what the script does, it simply searches for an ip, to c if its online and finds the nick, and reports it to the person, and it also finds the nick which the hubs server is using !!
Title:
Post by: Dessamator on 21 April, 2005, 15:46:17
--By Dessamator
--SIMPLE Online/offline ip checker v2
bot=frmHub:GetHubBotName()

function ChatArrival(user, data)

data = string.sub(data,1,string.len(data)-1)
s,e,cmd = string.find(data, "%b<>%s+(%S+)")

local s,e,ip = string.find(data, "%b<>%s+%S+%s+(.+)")
if  user.bOperator then
if cmd=="!findip"  then
findip(user,ip,1)
return 1
elseif cmd=="!getserver" then
findip(user,"127.0.0.1",0)
return 1
elseif cmd=="!findserver" then
findip(user,findlocalip(),0)
return 1
end
end
end
ToArrival=ChatArrival

function findip(user,ip,i)
local check =""
if i==1 and ip then
temp= "\r\n".."\t".."The ip: "..ip.." Belongs to :".."\r\n"
else
temp= "\r\n".."\t".."The Current server is: ".."\r\n"
end
temp=temp.."\t".."??????????????????????".."\r\n"
for _,nick in frmHub:GetOnlineUsers() do
if nick.sIP==ip and i==1 then
temp=temp.."\t\t".."?"..nick.sName.."\r\n"
check=check..nick.sIP
elseif i==0 and nick.sIP==frmHub:GetHubIp() or nick.sIP==ip then
temp=temp.."\t\t".."?"..nick.sName.."\r\n"
check=check..nick.sIP
elseif i==0 and not(nick.sIP==ip )and check==nil then
temp="The person with the server isnt online!! "
end
end
if check=="" then
user:SendPM(bot,"The User with that ip isnt online")
elseif not(check=="") then
user:SendPM(bot,temp)
end
temp=""
check=""
end

-- ping localhost to find ip --
function findlocalip()
os.execute("ping -n 1 localhost >localip.txt")
local stuff =""
for line in io.lines("localip.txt") do
    stuff = stuff..line.."\r\n"
end
s,l =string.find(stuff,"%[")
e,f=string.find(stuff,"%]")
local hubip=(string.sub(stuff,s+1,e-1))
os.execute("del localip.txt")
return hubip

end
Title:
Post by: Herodes on 22 April, 2005, 01:41:01
couldnt resist.. ;)
--By Dessamator
--SIMPLE Online/offline ip checker v2

bot=frmHub:GetHubBotName()

function ChatArrival(user, data)
local data = string.sub(data,1, -2)
local s,e,cmd,ip = string.find(data, "%b<>%s+(%S+)%s*(%S*)")
if user.bOperator then
if cmd=="!findip"  then
findip(user,ip,1);
return 1
elseif cmd=="!getserver" then
findip(user,"127.0.0.1",0);
return 1
elseif cmd=="!findserver" then
findip(user,findlocalip(),0)
return 1
end
end
end
ToArrival=ChatArrival

function findip(user,ip,i)

local check, temp, hubip  = nil, "\r\n\tThe Current server is: \r\n", frmHub:GetHubIP()

if ( (i==1) and ip ) then temp = "\r\n\tThe ip: "..ip.." Belongs to :\r\n" end;

temp = temp.."\t??????????????????????\r\n"

for _,nick in frmHub:GetOnlineUsers() do
if i == 0 then
if ( (nick.sIP == hub.ip ) or (nick.sIP == ip) )  then
temp=temp.."\t\t".."?"..nick.sName.."\r\n"
elseif not ( ( nick.sIP == ip ) or check ) then
temp="The person with the server isnt online!! "
end
elseif i == 1 end
if user.sIP == ip then
temp=temp.."\t\t".."?"..nick.sName.."\r\n"
check = nick.sIP
end
end

if not check then
user:SendPM(bot,"The User with that ip isnt online")
else
user:SendPM(bot,temp)
end
end

-- ping localhost to find ip --
function findlocalip()
os.execute("ping -n 1 localhost >localip.txt")
local hubip = nil
for line in io.lines("localip.txt") do
if string.find ( line , "%[") then
s,e, hubip = string.find( line , "%[(%d+%.%d+%.%d+%.%d+)%]")
break
end
end
os.execute("del localip.txt")
return hubip
end
Title:
Post by: Dessamator on 22 April, 2005, 10:34:37
arrrgh, ur code is cleaner than mine, curses,  ;) , but anyways thnx, it gave me a new perspective on how to do such things , :]
Title:
Post by: Dessamator on 22 April, 2005, 11:09:35
herodes, ur script had some syntax errors solved here, hmm nice use of string.find, still have quite a lot to learn about that, ;)

--By Dessamator
--SIMPLE Online/offline ip checker v2

bot=frmHub:GetHubBotName()

function ChatArrival(user, data)
local data = string.sub(data,1, -2)
local s,e,cmd,ip = string.find(data, "%b<>%s+(%S+)%s*(%S*)")
if user.bOperator then
if cmd=="!findip"  then
findip(user,ip,1);
return 1
elseif cmd=="!getserver" then
findip(user,"127.0.0.1",0);
return 1
elseif cmd=="!findserver" then
findip(user,findlocalip(),0)
return 1
end
end
end
ToArrival=ChatArrival

function findip(user,ip,i)

local check, temp, hubip  = nil, "\r\n\tThe Current server is: \r\n", frmHub:GetHubIp()

if ( (i==1) and ip ) then temp = "\r\n\tThe ip: "..ip.." Belongs to :\r\n" end;

temp = temp.."\t??????????????????????\r\n"

for _,nick in frmHub:GetOnlineUsers() do
if i == 0 then
if ( (nick.sIP == hubip ) or (nick.sIP == ip) )  then
temp=temp.."\t\t".."?"..nick.sName.."\r\n"
check = nick.sIP
elseif not ( ( nick.sIP == ip ) or (check) ) then
temp="The person with the server isnt online!! "
end
elseif i == 1 then
if nick.sIP == ip then
temp=temp.."\t\t".."?"..nick.sName.."\r\n"
check = nick.sIP
end
end
end

if not check then
user:SendPM(bot,"The User with that ip isnt online")
else
user:SendPM(bot,temp)
end
end

-- ping localhost to find ip --
function findlocalip()
os.execute("ping -n 1 localhost >localip.txt")
local hubip = nil
for line in io.lines("localip.txt") do
if string.find ( line , "%[") then
s,e, hubip = string.find( line , "%[(%d+%.%d+%.%d+%.%d+)%]")
break
end
end
os.execute("del localip.txt")
return hubip
end
Title: ?
Post by: CaSaNoVa on 18 May, 2005, 01:26:09
I want to know if an IP was in my hub.or is now on my hub.not only now,but even if is offline andi i was here.
Title:
Post by: Dessamator on 18 May, 2005, 09:49:04
QuoteOriginally posted by CaSaNoVa
I want to know if an IP was in my hub.or is now on my hub.not only now,but even if is offline andi i was here.

use userinfo database by Night litch, search the forum !
Title:
Post by: jiten on 18 May, 2005, 09:54:13
QuoteOriginally posted by CaSaNoVa
I want to know if an IP was in my hub.or is now on my hub.not only now,but even if is offline andi i was here.
Then, you'll need an IP Logger too. What do you think about it, Dessamator? :D

Cheers
Title:
Post by: Dessamator on 18 May, 2005, 10:22:35
QuoteOriginally posted by jiten
QuoteOriginally posted by CaSaNoVa
I want to know if an IP was in my hub.or is now on my hub.not only now,but even if is offline andi i was here.
Then, you'll need an IP Logger too. What do you think about it, Dessamator? :D

Cheers

hmm, yah sure, it really isnt that hard, i had already done something like that for robocop,  although it used robos logs, but then the script will change its name, its not simple any more, unless u do it first jiten, :)