Need Help!
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Need Help!

Started by hax0rs, 15 January, 2005, 15:58:01

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

hax0rs

Hi!
I want that IP is in one line, but IP`s isn`t in one line:( Can somebody help me :) Here is that scritp:
--## Nick and IP logger
--## Added Number to Loggers                                            
--## Requested by D-J Valhala                                        
--## Made by nErBoS                                                    
--## Command:                          
--##      +ip      - Will show the nicks and ips of all connected users
--##      +getip    - Will give you the ip of the nick

sBot = "IP-Logger"
arrIP = {}

--## Configuration ##--
uLaterPtokax = 0   --## If you are using ptokax 0.3.30 or higher choose 0
         --## If you are using lower versions then ptokax 0.3.3.0 choose 1
fileIP = "ip.log"   --## This file will be created to save the users and ips
--## End of Configuration ##--

function Main()
   --frmHub:RegBot(sBot)
   LoadFromFile(fileIP)
   CheckForUser()
end

function OnExit()
   SaveToFile(fileIP , arrIP , "arrIP")
end

function NewUserConnected(user)
   arrIP[user.sName] = user.sIP
end



function UserDisconnected(user)
   arrIP[user.sName] = nil
   if (uLaterPtokax == 1) then
      SaveToFile(fileIP , arrIP , "arrIP")
   end
end

OpConnected = NewUserConnected
OpDisconnected = UserDisconnected

function DataArrival(user, data)
   if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot) then
      data = strsub(data,1,strlen(data)-1)
      s,e,cmd = strfind(data, "%b<>%s+(%S+)")
      if (cmd == "+ip" and user.bOperator) then
         local sTmp,count,usr,ip = "Shobriid hubaa ir "..frmHub:GetUsersCount().." uuseri. Un vinjiem ir sekojoshas IP :\r\n\r\n",0
         for usr, ip in arrIP do
            count = count + 1
            sTmp = sTmp.."["..count.."] Uusers: "..usr.."\t\t\t\t\t\t IP:"..ip.." ("..count..")\r\n"

         end
         user:SendPM(sBot, sTmp)
         return 1
      elseif (cmd == "+getip" and user.bOperator) then
         local s,e,usr = strfind(data, "%b<>%s+%S+%s+(%S+)")
         if (usr == nil) then
            user:SendPM(sBot, "Nepareiza komanda, !getip , jaauzraxta niks.")
         elseif (GetItemByName(usr) == nil) then
            user:SendPM(sBot, "Uusers "..usr.." nau Hubaa.")
         else
            user:SendPM(sBot, "Uusera "..GetItemByName(usr).sName.." ip ir: "..GetItemByName(usr).sIP)

         end
         return 1
      end
   end
end

function CheckForUser()
   local usr,ip
   for usr, ip in arrIP do   
      if (GetItemByName(usr) == nil) then
         arrIP[usr] = nil
      end
   end
end


function Serialize(tTable, sTableName, sTab)
   assert(tTable, "tTable equals nil");
   assert(sTableName, "sTableName equals nil");

   assert(type(tTable) == "table", "tTable must be a table!");
   assert(type(sTableName) == "string", "sTableName must be a string!");

   sTab = sTab or "";
   sTmp = ""
   sTmp = sTmp..sTab..sTableName.." = {\n"
   for key, value in tTable do
      local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);
      if(type(value) == "table") then
         Serialize(value, sKey, sTab.."\t");
      else
         local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
         sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
      end



      sTmp = sTmp..",\n"

   end



   sTmp = sTmp..sTab.."}"

   return sTmp

end



function SaveToFile(file , table , tablename)

   writeto(file)

   write(Serialize(table, tablename))

   writeto()

end



function LoadFromFile(file)

   if (readfrom(file) ~= nil) then

      readfrom(file)

      dostring(read("*all"))

      readfrom()

   end

end


I want ThisPREVIEW:
 [1]Uusers: huseinsxxxxxxxxxxx.lv                  IP:81.198.16.186(1)
- [2]Uusers: FW26                  IP:81.198.9.226(2)
- [3]Uusers: igrok                  IP:62.85.12.100(3)
- [4]Uusers: martina                  IP:81.198.11.235(4)
- [5]Uusers: slonik1                  IP:80.81.57.33(5)
- [6]Uusers: hax0rs                  IP:81.198.9.105(6)
- [7]Uusers: [LV]Dylan                  IP:62.214.147.103(7)
- [8]Uusers: Markinc                  IP:83.136.139.16(8)

A script show`s
 [1]Uusers: huseinsxxxxxxxxxxx.lv                             
                                 IP:81.198.16.186(1)
- [2]Uusers: FW26
                  IP:81.198.9.226(2)
- [3]Uusers: igrok
                  IP:62.85.12.100(3)
- [4]Uusers: martina                  IP:81.198.11.235(4)
- [5]Uusers: slonik1                  IP:80.81.57.33(5)
- [6]Uusers: hax0rs                  IP:81.198.9.105(6)
- [7]Uusers: [LV]Dylan                  IP:62.214.147.103(7)
- [8]Uusers: Markinc                  IP:83.136.139.16(8)

TTB

#1
Hi,

here u are:

--## Nick and IP logger 
--## Added Number to Loggers 
--## Requested by D-J Valhala 
--## Made by nErBoS 
--## Command: 
--## +ip - Will show the nicks and ips of all connected users 
--## +getip  - Will give you the ip of the nick 

sBot = "IP-Logger" 
arrIP = {} 

--## Configuration ##-- 
uLaterPtokax = 0 --## If you are using ptokax 0.3.30 or higher choose 0 
--## If you are using lower versions then ptokax 0.3.3.0 choose 1 
fileIP = "ip.log" --## This file will be created to save the users and ips 
--## End of Configuration ##-- 

function Main() 
--frmHub:RegBot(sBot) 
 LoadFromFile(fileIP) 
 CheckForUser() 
end 

function OnExit() 
 SaveToFile(fileIP , arrIP , "arrIP") 
end 

function NewUserConnected(user) 
 arrIP[user.sName] = user.sIP 
end 



function UserDisconnected(user) 
 arrIP[user.sName] = nil 
 if (uLaterPtokax == 1) then 
  SaveToFile(fileIP , arrIP , "arrIP") 
 end 
end 

OpConnected = NewUserConnected 
OpDisconnected = UserDisconnected 

function DataArrival(user, data) 
 if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot) then 
  data = strsub(data,1,strlen(data)-1) 
  s,e,cmd = strfind(data, "%b<>%s+(%S+)") 
   if (cmd == "+ip" and user.bOperator) then 
    local sTmp,count,usr,ip = "Shobriid hubaa ir "..frmHub:GetUsersCount().." uuseri. Un vinjiem ir sekojoshas IP :\r\n\r\n",0 
    for usr, ip in arrIP do 
    count = count + 1 
    sTmp = sTmp.."["..count.."] Uusers: "..usr.." IP:"..ip.." ("..count..")\r\n" 
   end 
  user:SendPM(sBot, sTmp) 
  return 1 
  elseif (cmd == "+getip" and user.bOperator) then 
  local s,e,usr = strfind(data, "%b<>%s+%S+%s+(%S+)") 
   if (usr == nil) then 
    user:SendPM(sBot, "Nepareiza komanda, !getip , jaauzraxta niks.") 
    elseif (GetItemByName(usr) == nil) then 
    user:SendPM(sBot, "Uusers "..usr.." nau Hubaa.") 
   else 
    user:SendPM(sBot, "Uusera "..GetItemByName(usr).sName.." IP: "..GetItemByName(usr).sIP) 
  end 
  return 1 
 end 
end 
end 

function CheckForUser() 
 local usr,ip 
 for usr, ip in arrIP do 
 if (GetItemByName(usr) == nil) then 
  arrIP[usr] = nil 
 end 
end 
end 


function Serialize(tTable, sTableName, sTab) 
assert(tTable, "tTable equals nil"); 
assert(sTableName, "sTableName equals nil"); 

assert(type(tTable) == "table", "tTable must be a table!"); 
assert(type(sTableName) == "string", "sTableName must be a string!"); 

sTab = sTab or ""; 
sTmp = "" 
sTmp = sTmp..sTab..sTableName.." = {\n" 
for key, value in tTable do 
local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key); 
if(type(value) == "table") then 
Serialize(value, sKey, sTab.."\t"); 
else 
local sValue = (type(value) == "string") and format("%q",value) or tostring(value); 
sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue 
end 



sTmp = sTmp..",\n" 
end 

sTmp = sTmp..sTab.."}" 
return sTmp 
end 



function SaveToFile(file , table , tablename) 
 writeto(file) 
 write(Serialize(table, tablename)) 
 writeto() 
end 



function LoadFromFile(file) 
 if (readfrom(file) ~= nil) then 
  readfrom(file) 
  dostring(read("*all")) 
  readfrom() 
 end 
end

Please, next time put the code in {CODE} and {/CODE} where {} should be [].

Was easy to fix... note that text can be tabbed, in code with "\t", so 5 tabs would be "\t\t\t\t\t". You could do it yourself.

Bye
TTB

(? ?.??.-> Admin @ Surfnet hubs <-.??.???)

SMF spam blocked by CleanTalk