PtokaX forum

PtokaX => Support => Topic started by: Themaster on 23 September, 2004, 16:36:10

Title: help
Post by: Themaster on 23 September, 2004, 16:36:10
i have a little problem.. when i do !myip like regestered user...then nothing gone happen...

what have i forgot in the script

Thx with all the help i get ;)
Title:
Post by: Herodes on 23 September, 2004, 16:39:12
what script ?
Title:
Post by: Themaster on 23 September, 2004, 16:45:02
That i make

assert(dofile("blade/Setup.lua"),"blade/Setup.lua not found")
assert(dofile("blade/Logincheck.lua"),"blade/Logincheck.lua not found")

Version ="Blade? 1.0"
Build ="~~1.3~~"
Creators ="Themaster?"

sUserCount = frmHub:GetUsersCount()
sHubName = frmHub:GetHubName()
sHubDesc = frmHub:GetHubDescr()
sRedirect = frmHub:GetRedirectAddress()
sMaxUsers = frmHub:GetMaxUsers()
sMinShare = frmHub:GetMinShare(3)
sCurrentShare = frmHub:GetCurrentShareAmount()

Guard_File = "blade/PeerGuardian/Guarding.P2P"

function Main()
   frmHub:UnregBot(BotName)
   frmHub:RegBot(BotName)
   frmHub:RegBot(OpChat)
   TimeSpanInMinutes = 60
   SendToAll("    (? ?.??.->  "..Version.." Build"..Build..date(" the %d/%m-%Y at %X ").."  <-.??.???)" )
   BotNameInfo = "$MyINFO $ALL "..BotName.." <++V:1.0 Blade? 1.0,C:Themaster? $ $LAN(T3)"..strchar( 1 ).."$$"
   SendToAll(ScriptRestart)
   SendToAll(BotNameInfo)
   SendToAll(OpChatInfo)
   SetTimer(TimeSpanInMinutes*60000)
   StartTimer()
end

function OnTimer()
   SendAdMessage()
end

function SendAdMessage()
   upline = "~~~~~~~~~~~~H~U~=B~~S~T~A~T~S~~~~~~~~~~"
   underline = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
   hubstats = "\r\n\r\n"..upline.."\r\n"..
       "      ?Script Version:           "..Version.."\r\n"..
       "      ?Build:              "..Build.."\r\n"..
       "      ?Script Creator:              "..Creators.."\r\n"..
       "      ?Hub Name:               "..sHubName.."\r\n"..
       "      ?Hub Description:          "..sHubDesc.."\r\n"..
       "      ?Hub Adress:             "..HubAdress.."\r\n"..
       "      ?Web Adress:             "..WebAdress.."\r\n"..
       "      ?Owner:           "..HubOwner.."\r\n"..
       "      ?Online Users:          "..sUserCount.."\r\n"..
       "      ?Redirect Adress:          "..sRedirect.."\r\n"..
       "      ?Maximum Users:          "..sMaxUsers.."\r\n"..
       "      ?Hub Network:           !network".."\r\n"..
       "      ?Hub Rules:              !rules".."\r\n"..underline.."\r\n".." "

      SendToAll(BotName, hubstats)
end

function DataArrival(user,data)
      if (strsub(data,1,7) == "$MyINFO") then
         Tag,Speed,Share = Parse(data)
         TagCheck(Tag,Speed,Share,user)
      end

   if (strsub(data, 1, 1) == "<" ) and user.bOperator then
      data=strsub(data,1,strlen(data)-1)
      _,_,cmd=strfind(data, "%b<>%s+(%S+)")
      if not cmd then cmd = "0" end
      cmd = strlower(cmd)
      cmdprefix = strsub(cmd, 1,1)
      if cmdprefix == "!" or cmdprefix == "+" or cmdprefix == "#" or cmdprefix == "?" then
         cmd = strsub(cmd, 2,strlen(cmd))
         if cmd == "say" then
            _,_,as,message = strfind(data, "%b<>%s+%S+%s+(%S+)%s+(.+)")
            SendToAll(as, message)
            return 1
         end
      end

         if cmd == "myip" then
            user:SendData(BotName, "Your IP is *** "..user.sIP)
            return 0
         elseif cmd == "version" then
            user:SendData("The Script", "  "..Version ..Build .. Creators)
            return 0
         else
            user:SendData("wrong use read help menu you fool!")
            return 1
         end
      end
      if strsub(data, 1, 5) == "$To: " then
      local s,e,to,from,text = strfind(data, "%$To:%s(%S+)%sFrom:%s(%S+)%s$(.*)$")
         if to == OpChat then
            if user.bOperator then
               local s,e,msg = strfind(text,"^%b<>%s+(.+)")
               OpChatRoom(user,msg)
            end
         end
      end
end

function NewUserConnected(user,data)
   Connected(user)    
end
OpConnected = NewUserConnected

function OpChatRoom(user,msg)
      local allprofiles = GetProfiles()
      local index, profile, index2, nick
      for index, profile in allprofiles do
         local users = GetUsersByProfile(profile)
         for index2, nick in users do
            local usr = GetItemByName(nick)
            if usr ~= nil then
               if user.sName == usr.sName then
               else
                  if usr.iProfile == 0 or usr.iProfile == 1 or usr.iProfile == 4 then
                     usr:SendData("$To: "..usr.sName.." From: "..OpChat.." $<"..user.sName.."> "..msg)
                  end
               end
            end
         end
      end
end

function BlockGuard(ip)
   local _,_,a,b,c,d = strfind(ip "(%d*).(%d*).(%d*).(%d*)")
   if ( tonumber(a) and tonumber(b) and tonumber (c) and tonumber (d) ) then
      local uip = Computer(ip)
      if uip then
         for ranger,comp in Guard do
            local _,_,r1,r2 = strfind(ranger, "(.*)-(.*)")
            r1 = ComputeIP(r1)
            r2 = ComputeIP(r2)
            if uip>=r1 and uip <=r2 then
               return 1,comp
            end
         end
      end
   end
end

function Computer(curIP)
   local _,_,a,b,c,d = strfind (curIP, "(%d+).(%d+).(%d+).(%d+)")
   return a*16777216 + b*65536 + c+256 + d
end

function DeComputeIP(cIP)
   local temp1 = mod(cIP,16777216)
   local temp2 = mod(temp1,65536)
   return (floor(cIP/16777216).."."..floor(temp1/65536).."."..floor(temp2/256).."."..floor(mod(temp2,256)))
end

function LoadGuard(table,file)
   local handle = openfile(file, "r")
   if (handle) then
    local line = read(handle)
    while line do
         s,e,ind,val = strfind( line, "(.*):(.*)")
         if ind and val then
            table[val]=ind
         end
         line = read(handle)
    end
     closefile(handle)
   end
end

i think i miss something on it
Title:
Post by: Herodes on 23 September, 2004, 16:50:15
a Gotcha was found .. :)
function DataArrival(user,data)
if (strsub(data,1,7) == "$MyINFO") then
Tag,Speed,Share = Parse(data)
TagCheck(Tag,Speed,Share,user)
end

if (strsub(data, 1, 1) == "<" ) [b]and user.bOperator[/b] then
data=strsub(data,1,strlen(data)-1)
_,_,cmd=strfind(data, "%b<>%s+(%S+)")
if not cmd then .. . . .

no wonder it would show up :)

ooh and please use the [ c o d e ](no spaces :) code in here [ / c o d e ](no spaces, again :) tag to post ur code so the tabbing is preserved ..
Title:
Post by: Themaster on 23 September, 2004, 17:13:15
it still don't work :S
Title:
Post by: Herodes on 23 September, 2004, 17:38:42
I just noticed another Gotcha...
if cmd == "myip" then
user:SendData(BotName, "Your IP is *** "..user.sIP)
[b]return 0[/b] --- this needs to be      return 1
elseif cmd == "version" then
user:SendData("The Script", " "..Version ..Build .. Creators)
[b]return 0[/b] --- this needs to be      return 1
else
user:SendData("wrong use read help menu you fool!")
return 1
end
Title:
Post by: Themaster on 23 September, 2004, 17:46:39
i still miss something one it....

i Can't still not do it on a VIP User or Reg User
Title:
Post by: [UK]Madman on 23 September, 2004, 18:06:32
if (strsub(data, 1, 1) == "<" ) and user.bOperator then

=

If command is in main chat, and the user is an Operator then.....   So this will not recognise commands sent by anybody lower than an Operator, so VIPs or REGs would get no response.
Title:
Post by: Themaster on 23 September, 2004, 18:12:17
thx it help...now i just go on with my command ...

thx to you there are helping ;)
Title:
Post by: Themaster on 23 September, 2004, 18:23:36
assert(dofile("blade/Commands.lua"), "blade/Commands.lua not found")

are there some load code there load my command ore that line is good ????
Title:
Post by: tezlo on 23 September, 2004, 19:31:54
one major gotcha..
sUserCount = frmHub:GetUsersCount()
..
sCurrentShare = frmHub:GetCurrentShareAmount()

these change, but you only assign them once at script start, so you always get one value no matter how many people are _really online
Title:
Post by: Themaster on 23 September, 2004, 20:46:10
if (strsub(data, 1, 1) == "<" ) then
      data=strsub(data,1,strlen(data)-1)
      _,_,cmd=strfind(data, "%b<>%s+(%S+)")
      s,e,arg = strfind(data,"%b<>%s+%S+%s+(%S+)")
      local commands = Commands(user, data, cmd))
         local _,_,message=strfind(data, "%b<>%s+(.+)")
            return commands
         end
      end
   end
end

Why can't i load from my command file where i write all my command :s