PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: Not on 20 December, 2003, 18:24:31

Title: show me my ip in a popup
Post by: Not on 20 December, 2003, 18:24:31
Hi, guys  :D .
I've looked around for a small, standalone script that will give users their ip.

I know that this function is included in many larger scriptpackages, but i don't want to replace those that i have today.

Could someone whip up such a script? If possible, it should open in a new popup window...
Title:
Post by: [ES]latinmusic on 20 December, 2003, 18:32:48
-- Not tested
-- Command-->> !myip -->> in mainchat
boName = "MyIP"
function DataArrival(curUser, data)
if strsub(data, 1, 1) ~= "<" then return end
local s, e, cmd, args = strfind(data, "^%b<> %!(%a+)%s*(.*)%|$")
if not s then return end
cmd = strlower(cmd)
if (cmd=="myip") then
curUser:SendPM(botName,"Your current IP is: '"..curUser.sIP.."'.")
return 1
end
end
Title:
Post by: Not on 20 December, 2003, 18:51:50
Hmm, didn't work.. so i modified it a bit (maybe screwed it up). Looks like this now, and still doesn't work :p


-- Command-->> +myip -->> in mainchat

BotName="-[PtokaX]-"

function Main()
   frmHub:RegBot(BotName)
end

function DataArrival(curUser, data)
   if strsub(data, 1, 1) ~= "<" then return end
   local s, e, cmd, args = strfind(data, "^%b<> %!(%a+)%s*(.*)%|$")
   if not s then return end
   cmd = strlower(cmd)
   if (cmd=="+myip") then
      curUser:SendPM(botName,"Your current IP is: '"..curUser.sIP.."'.")
      return 1
   end
end
Title:
Post by: NightLitch on 20 December, 2003, 19:22:22
the tiny problem is this:

curUser:SendPM(botName,"Your current IP is: '"..curUser.sIP.."'.")

should be a big B in BotName not like above

correct line

curUser:SendPM(BotName,"Your current IP is: '"..curUser.sIP.."'.")

this should do it...

/NL
Title:
Post by: SaintSinner on 20 December, 2003, 19:34:07
here did some changes
were just a few spelling errors
and in the DataArrival


Bot = "Ipbot"
function DataArrival(user,data)
if strsub(data, 1, 1) == "<" then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")

if cmd == "!myip" then
user:SendPM(Bot,"Your current IP is  "..user.sIP..".")
return 1
end
end
end



Title:
Post by: SaintSinner on 20 December, 2003, 19:35:03
QuoteOriginally posted by NightLitch
the tiny problem is this:

curUser:SendPM(botName,"Your current IP is: '"..curUser.sIP.."'.")

should be a big B in BotName not like above

correct line

curUser:SendPM(BotName,"Your current IP is: '"..curUser.sIP.."'.")

this should do it...

/NL


LOL...dammitt,...you were faster..
Title:
Post by: Not on 20 December, 2003, 19:58:19
Well, thanks a lot guys, it works like a charm  :D

Looks like this:


-- Command-->> +myip -->> in mainchat

BotName="-[PtokaX]-"

function Main()
   frmHub:RegBot(BotName)
end

function DataArrival(user,data)
if strsub(data, 1, 1) == "<" then
   data=strsub(data,1,strlen(data)-1)
   s,e,cmd = strfind(data,"%b<>%s+(%S+)")
      
      if cmd == "+myip" then
      user:SendPM(BotName,"Your current IP is  "..user.sIP..".")
      return 1
end
end
end





Really appreciate you all taking your time and helping me out!
Title:
Post by: turkiye on 20 December, 2003, 21:03:35
it's not a popup it's a PM
 8)
Title:
Post by: [ES]latinmusic on 22 December, 2003, 01:03:47
lol, what silly error, the original error was in this line:
boName= "MyIP" instead botName= "MyIP" seems i was tipying to fast, anyway is fixed now. Also i'm going to edit the first one for someone who need it another time.
Title:
Post by: [ES]latinmusic on 22 December, 2003, 01:06:43
-- Not tested
-- Command-->> !myip -->> in mainchat
botName = "MyIP"
function DataArrival(curUser, data)
if strsub(data, 1, 1) ~= "<" then return end
local s, e, cmd, args = strfind(data, "^%b<> %!(%a+)%s*(.*)%|$")
if not s then return end
cmd = strlower(cmd)
if (cmd=="myip") then
curUser:SendPM(botName,"Your current IP is: '"..curUser.sIP.."'.")
return 1
end
end
Seems that there is an error inside the board because i can edit my own post!!!!!!!!!!!!
Anyway edited in this ugly way.
Title:
Post by: pHaTTy on 22 December, 2003, 01:27:27
QuoteOriginally posted by [ES]latinmusic
-- Not tested
-- Command-->> !myip -->> in mainchat
botName = "MyIP"
function DataArrival(curUser, data)
if strsub(data, 1, 1) ~= "<" then return end
local s, e, cmd, args = strfind(data, "^%b<> %!(%a+)%s*(.*)%|$")
if not s then return end
cmd = strlower(cmd)
if (cmd=="myip") then
curUser:SendPM(botName,"Your current IP is: '"..curUser.sIP.."'.")
return 1
end
end
Seems that there is an error inside the board because i can edit my own post!!!!!!!!!!!!
Anyway edited in this ugly way.

for a small script there is no real point of
   
local s, e, cmd, args = strfind(data, "^%b<> %!(%a+)%s*(.*)%|$")


just a note. lol