PtokaX forum

Development Section => Your Developing Problems => Topic started by: mandix on 28 June, 2004, 03:04:57

Title: [PING] i got a ping script but i need...
Post by: mandix on 28 June, 2004, 03:04:57
hela all.
i found a ping script (lua) somewhere on the net.. dunno where anymore but... my operating system is dutch  :D, but i need it in english can anyone help me ?
i got the ping.exe and ping6.exe in english from a frend...

PingComm = "!ping"


function DataArrival(curUser, sData)
      sData=strsub(sData,1,-2)
      s,e,cmd,who = strfind( sData, "%b<>%s+(%S+)%s*(%S*)" )
if (cmd==PingComm) and curUser.bOperator then
  local nick = GetItemByName(who)
if nick == nil then
SendToNick(curUser.sName,"<-=Hubgods=-> The user "..who.." is not online. Try again.") return 1 end
local compIp = FetchIP(nick.sIP)
SendToNick(curUser.sName,"\r\n\t---<>-----------------------------------------------------------------------------<>---\r\n\t\tPinging ->> [ "..who.." ]   Please wait...\r\n\t---<>-----------------------------------------------------------------------------<>---")
execute("ping "..addy.." > pinger.lst")
local pingtime = ""
if readfrom("pinger.lst") then
readfrom("pinger.lst")
pingtime = read("*a")
pingtime = gsub(pingtime,"|",strchar(166))
pingtime = gsub(pingtime,"\n","\r\n\t")
writeto()
remove("pinger.lst")
end
SendToNick(curUser.sName,"\t\t\t.:: Results ::.\r\n\t---<>-----------------------------------------------------------------------------<>---\r\n\t"..pingtime.."\r\n\t---<>-----------------------------------------------------------------------------<>---")
return 1
end
end

function FetchIP(IP)
local _,_,a,b,c,d = strfind(IP, "(%d+)%.(%d+)%.(%d+)%.(%d+)")
if a and b and c and d then
addy=a.."."..b.."."..c.."."..d
return addy
end
end