PtokaX forum

Archive => Archived 5.1 boards => Help with scripts => Topic started by: Creative on 18 August, 2007, 17:49:23

Title: Help with ip script
Post by: Creative on 18 August, 2007, 17:49:23
Hello guys,
               I want some help in ip script. Actually when a user logins with a nick and if he changes his nick style,
for example if i login with nick "CREATIVE" then it saves the ip but if i login with nick "creative" and if i change my ip again, then it still shows the old ip. I want a to modify the script so that it stores the latest ip in the table even if the nick style is changed.


--User Settings----------------------------------------------------------------------------------------------------------------
--
--//-- Botname pulled from the hub
Bot = frmHub:GetHubBotName()
Prefix = "+" -- Command Prefix
IpCmd = "ip" -- Get IP User Command
IpMenu = Ip -- Menu name pulled form hub, uses hub name for menu
SubMenu0 ="IP Log" -- Custom submenu
IPFile="IPLog.dat"
--//--Set your profiles here.
--profile_idx, Commands/Menus enabled [0=no 1=yes], "Profile Name"
IpProfiles = {
[-1] = {1,"Unregistered User"},
[0] = {1,"Master"},
[1] = {1,"Operator"},
[2] = {1,"Vip"},
[3] = {1,"Registered User"},
[4] = {1,"Moderator"},
[5] = {1,"NetFounder"},
}
--
--End User Settings-------------------------------------------------------------------------------------------------------------

function Main()
if loadfile(IPFile) ~= nil then
dofile(IPFile)
else
IPLog ={}
Save_File(IPFile,IPLog,"IPLog")
end
end

function OnExit()
Save_File(IPFile,IPLog,"IPLog")
end

function NewUserConnected(user, data)
        local sClock = os.date("%I:%M:%S %p")
local timein=os.date("%A , %B %d %Y").." at "..sClock
IPLog[user.sName]={
                           ["sIP"] = user.sIP,
                           ["sLastSeen"] =timein}
Save_File(IPFile,IPLog,"IPLog")
if IpProfiles[user.iProfile][1] == 1 then
Commands(user)

end
end

OpConnected = NewUserConnected

UserDisconnected = function (user)
local sClock = os.date("%I:%M:%S %p")
local timein=os.date("%A , %B %d %Y").." at "..sClock
IPLog[user.sName]={
                           ["sIP"] = user.sIP,
                           ["sLastSeen"] =timein}
Save_File(IPFile,IPLog,"IPLog")
end

OpDisconnected = UserDisconnected

function ChatArrival(user, data)
local s,e,pre,cmd = string.find(data, "%b<>%s+(%p)(%S+)")
local s,e,addy = string.find(data, "%s(%d+%.%d+%.%d+%.%d+)|$")
local s,e,nick = string.find(data, "%s(%S+)|$")
if IpProfiles[user.iProfile][1] == 1 then
if pre and pre==Prefix then
if (string.lower(cmd)==IpCmd) then



if nick and nick ~= addy then



for i,v in pairs(IPLog) do
--if string.lower(i) == string.lower(nick) then
                                                                if string.find(string.lower(i),string.lower(nick),1,1)then
for i,v in pairs(frmHub:GetOnlineUsers()) do

v:SendData(user.sName, pre..cmd.." "..nick)
end

local reply2="Nick:- "..i.." \t "..
"IP Address:-"..v.sIP.."  "
user:SendData(Bot,reply2)
return 1

end

end

end




                                                              for i,v in pairs(IPLog) do
if v.sIP==addy then
for i,v in pairs(frmHub:GetOnlineUsers()) do

v:SendData(user.sName, pre..cmd.." "..addy)
end
local reply1="Nick:- "..i.." \t "..
"IP Address:-"..v.sIP.."  "
user:SendData(Bot,reply1)
return 1





end

end


elseif (pre==Prefix) and (cmd==IpCmd) and not addy then
user:SendData(Bot,"\r\n\r\n\tSyntax Error, Syntax = "..Prefix..IpCmd.." <IP or Nick>\r\n")

end
end
end


if IpProfiles[user.iProfile][1] == 1 then
if pre and pre==Prefix then
if (string.lower(cmd)=="lastseen") then
if nick and nick ~= addy then

for i,v in pairs(IPLog) do
if string.lower(i) == string.lower(nick) then
for i,v in pairs(frmHub:GetOnlineUsers()) do

v:SendData(user.sName, pre..cmd.." "..nick)
end
                                                                local status = v.sLastSeen
if GetItemByName(i) then


local reply2=""..i.." is currently online"
user:SendData(Bot,reply2)
return 1
else

local reply2=""..i.." was last seen on "..status..""
user:SendData(Bot,reply2)
return 1

end
end
end

end




                                                             


end
end
end





end



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

Save_File = function(file,table , tablename )
local hFile = io.open (file , "w")
Save_Serialize(table, tablename, hFile);
hFile:close()
end
Title: Re: Help with ip script
Post by: Creative on 19 August, 2007, 19:29:34
Sorry sir, but again this time my friend gave me this script, he wanted some changes to be done........... anyways, i hope that u help me in this  :-\
Title: Re: Help with ip script
Post by: Josecar on 19 August, 2007, 20:50:04
I don't know Mutor's script (maybe with the name), but the main idea in one of mine is charging ip's of users in an array (subarray), inserting the last used in first place. The size of the array configurable, 10 or more, and discarding the last one when it oversizes. Then you can make commands for searching, show it in getinfos, accurate rangebans, etc.  In actual times...

Title: Re: Help with ip script
Post by: CrazyGuy on 21 August, 2007, 12:39:31
I will second this motion to have it added to the rules and a punishment on violation.
Credit to who deserves it. As Mutor indicated already, ALL scripts are freeware which means you can use em without any costs/trouble and they can all be found here on the board. Over half of all the scripts here are created on request without the actual scripter even using it/having interrest in it. The least one can do in return is to give credit to the creator(s).
Title: Re: Help with ip script
Post by: Yahoo on 21 August, 2007, 13:24:33
i will also second it
all scripter put there efforts to satisfy our (users) request and some people remove the credits. its not at all fair common guys grow up let the scripter atleast get the credit for the script as they do not charge us for there hardword they are just asking for credits