PtokaX forum

Development Section => Your Developing Problems => Topic started by: Themaster on 02 January, 2005, 20:49:51

Title: just a qustien
Post by: Themaster on 02 January, 2005, 20:49:51
i wonder if there are away to do prefix in command
like that here

if cmd == prefix.."myip" then
Title:
Post by: ??????Hawk?????? on 02 January, 2005, 21:02:07
hi m8  


what  exactly  do you mean  ???
Title:
Post by: Themaster on 02 January, 2005, 21:07:29
i mean that

function UserCommands(user,data,cmd)
   if cmd == prefix "+myip" then
      user:SendData(Bot, " Your Ip is -=-=> "..user.sIP)
      return 1

and then have 2 prefix
Prefix = {
["+"] = 1,
["!"] =,
}
Title:
Post by: ??????Hawk?????? on 02 January, 2005, 22:04:35
maby something like this will help

local _,_,PrefixToCheck = strfind(data, "%b<>%s+(%S)")
if Prefix[PrefixToCheck] then
--- Do your command checks here
end
using table
Prefix = {
["+"] = 1,
["!"] =1,
}
Title:
Post by: Themaster on 02 January, 2005, 22:08:28
ok..i will try it out and see if i it work's
Title:
Post by: Themaster on 02 January, 2005, 22:16:20
Nope that did not work
Title:
Post by: ??????Hawk?????? on 02 January, 2005, 22:24:43
hmmm    works  here  m8  ....  

can  you post the  script    ...
Title:
Post by: Themaster on 02 January, 2005, 22:25:52
function DataArrival(user, data)
   if (strsub(data,1,7) == "$MyINFO") then
      Tag,Speed,Share = Parse(data)
      TagCheck(Tag,Speed,Share,user)
   end
   if Kennylizednicks[user.sName] == 1 then
text=kennytext[random(1, getn(kennytext))]
SendToAll(user.sName, text)
return 1
elseif MUTE[user.sName] == 1 then
user:SendData(Bot,"You are muted. your message has been blocked ! ! !")
return 1
   elseif drunknicks[user.sName] == 1 then
text=DrunkText[random(1, getn(DrunkText))]
SendToAll(user.sName, text)
         return 1
end
   if (strsub(data, 1, 1) == "<" ) then
      local data=strsub(data,1,strlen(data)-1)
      local _,_,cmd=strfind(data, "%b<>%s+(%S+)")
      local Commands = (UserCommands(user, data, cmd))
      return Commands
   elseif (strsub(data,1,4) == "$To:") then
      data = strsub(data,1,-2);
      local s,e,whoTo,from,arg = strfind(data,"%$To:%s+(%S+)%s+From:%s+(%S+)%s+%$%b<>%s+(.*)")
      local s,e,cmd = strfind(arg,"(%S+)")
      if (whoTo == Bot) then
      UserCommands(user,data,cmd)
      elseif(whoTo == fBot) then
      UserCommands(user,data,cmd)
      else
         for i=1,getn(ChatBots) do
            if (( whoTo == ChatBots[i].Name )) then
               if (( ChatBots[i].Allowed[user.iProfile] == 1 )) then
                  sChat = ChatBots[i].Name;
                  for b,v in ChatBots[i].Allowed do
                     if (( v == 1 )) then
                        ChatRoom(sChat,user,arg,b)
                     end
                  end
               end
            end
         end
      end
   end
end

function UserCommands(user,data,cmd)
   if cmd == "+myip" then
      user:SendData(Bot, " Your IP is -=-=> "..user.sIP)
      return 1
   end
end
Title:
Post by: ??????Hawk?????? on 02 January, 2005, 22:39:00
try  this  :-  


function DataArrival(user, data)
   if (strsub(data,1,7) == "$MyINFO") then
      Tag,Speed,Share = Parse(data)
      TagCheck(Tag,Speed,Share,user)
   end
   if Kennylizednicks[user.sName] == 1 then
text=kennytext[random(1, getn(kennytext))]
SendToAll(user.sName, text)
return 1
elseif MUTE[user.sName] == 1 then
user:SendData(Bot,"You are muted. your message has been blocked ! ! !")
return 1
   elseif drunknicks[user.sName] == 1 then
text=DrunkText[random(1, getn(DrunkText))]
SendToAll(user.sName, text)
         return 1
end
   if (strsub(data, 1, 1) == "<" ) then
      local data=strsub(data,1,strlen(data)-1)
      local _,_,PrefixToCheck=strfind(data, "%b<>%s+(%S)")
if Prefix[PrefixToCheck] then
      local _,_,cmd=strfind(data, "%b<>%s+%S(%S+)")
      local Commands = (UserCommands(user, data, cmd))
      return Commands
end
   elseif (strsub(data,1,4) == "$To:") then
      data = strsub(data,1,-2);
      local s,e,whoTo,from,arg = strfind(data,"%$To:%s+(%S+)%s+From:%s+(%S+)%s+%$%b<>%s+(.*)")
      local s,e,cmd = strfind(arg,"(%S+)")
      if (whoTo == Bot) then
      UserCommands(user,data,cmd)
      elseif(whoTo == fBot) then
      UserCommands(user,data,cmd)
      else
         for i=1,getn(ChatBots) do
            if (( whoTo == ChatBots[i].Name )) then
               if (( ChatBots[i].Allowed[user.iProfile] == 1 )) then
                  sChat = ChatBots[i].Name;
                  for b,v in ChatBots[i].Allowed do
                     if (( v == 1 )) then
                        ChatRoom(sChat,user,arg,b)
                     end
                  end
               end
            end
         end
      end
   end
end




function UserCommands(user,data,cmd)
   if cmd == "myip" then
      user:SendData(Bot, " Your IP is -=-=> "..user.sIP)
      return 1
   end
end

Prefix = {
["!"] = 1,
["+"] = 1,
["?"] = 1
}
Title:
Post by: [_XStaTiC_] on 02 January, 2005, 22:43:12
You must also remove the + cmd == "+myip"  <-> cmd == "myip"

function UserCommands(user,data,cmd)
   if cmd == "myip" then
      user:SendData(Bot, " Your Ip is -=-=> "..user.sIP)
      return 1
   elseif cmd == "rules" then
Title:
Post by: Themaster on 02 January, 2005, 22:45:07
Nope it not work with ? and ! but work with +
Title:
Post by: ??????Hawk?????? on 02 January, 2005, 22:50:43
sorry   above  post  edited    ;)
Title:
Post by: Themaster on 02 January, 2005, 22:55:00
that ok..m8
i was just a test i 2 see if it will do
Title:
Post by: ??????Hawk?????? on 02 January, 2005, 22:57:31
yups  all  workin  ok now  ??

you  probably  spotted  that  not only  the  prefix  from the  command   had to be removed  but it also had to be removed from the  cmd

local _,_,cmd=strfind(data, "%b<>%s+%S(%S+)")

or Ignored as in the above