PtokaX forum

Development Section => Your Developing Problems => Topic started by: Themaster on 28 December, 2004, 20:44:32

Title: script help
Post by: Themaster on 28 December, 2004, 20:44:32
Hello ppl

Need some help with my script
i can't do my command in pm why....plz help me on it


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) == "<" ) then
   local data = strsub(data,1,strlen(data)-1)
   local _,_,prefix,cmd=strfind(data, "%b<>%s+(%S)(%S+)")
      if Tprefix[prefix] and cmd then
         prefixcmd = Tprefix[prefix]..cmd
         local Command = Command(user, data, cmd)
         return Command
      elseif Kennylizednicks[user.sName] == 1 then
            text=kennytext[random(1, getn(kennytext))]
SendToAll(user.sName, text)
return 1
         elseif Mutes[user.sName] == 1 then
user:SendData(BotName,"You are muted. your message has been blocked ! ! !")
return 1
         end
      end
      if strsub(data, 1, 5) == "$To: " then
      local s,e,whoTo,from,text = strfind(data, "%$To:%s(%S+)%sFrom:%s(%S+)%s$(.*)$")
      if whoTo == BotName then
local data=strsub(data,1,strlen(data)-1)
local _,_,cmd = strfind(data,"$%b<>%s+(%S+)")
if user.iProfile == 1 or user.iProfile == 0 then
         local Commands = Commands(user, data, cmd)
return Commands
end
      end      
      if whoTo == OpChat then
         if user.bOperator or Invited[user.sName] then
            local s,e,msg = strfind(text,"^%b<>%s+(.+)")
            OpChatRoom(user,msg)
         end
      end
      if whoTo == MasterChat then
         if user.bOperator then
            local s,e,msg = strfind(text,"^%b<>%s+(.+)")
            MasterChatRoom(user,msg)
         end
      end
      if whoTo == PmToOps then
local data=strsub(data,1,strlen(data)-1)
local _,_,message = strfind(data,"$%b<>%s+(.+)")
SendPmToOps(OpChat, "The user "..user.sName.." wants to inform us about : "..message)
user:SendPM(PmToOps,"Your Message has been delivered to  "..OpChat.." and Ops will handle it  !! ")
         end
      end
   local tmp = strsub(data,1,1)
if tmp == "<" then
local s, e, str = strfind(data,"%b<> (.*)|")
if not iscommand(str) then
if (user.bOperator) then
DoUpdOpStats(user,str)
else
DoUpdUserStats(user,str)
end
end
end
if (strsub(data,1,1) == "<" ) then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind( data,"%b<>%s+(%S+)" )
if (cmd=="+stats")then
pm = 0
ShowTop15(user)
end
end
   if HomeMadeTimer ~= strfind(date("%M"), "^%d") then
      HomeMadeTimer = strfind(date("%M"), "^%d")
      lucifer = nil
      lucifer = {}
   end
   if AUTO == 1 then
      if CleanDay ~= date("%x") then -- user cleaning trigger, works as a timer without a timer
         CleanDay = date("%x")
         CleanUsers()
      end
   end
end
Title:
Post by: DJ Bert on 28 December, 2004, 22:14:08
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 (strsub(data, 1, 1) == "<" ) then
   local data = strsub(data,1,strlen(data)-1)
   local _,_,prefix,cmd=strfind(data, "%b<>%s+(%S)(%S+)")
      if Tprefix[prefix] and cmd then
         prefixcmd = Tprefix[prefix]..cmd
         local Command = Command(user, data, cmd)
         return Command
      elseif Kennylizednicks[user.sName] == 1 then
            text=kennytext[random(1, getn(kennytext))]
SendPm(user.sName, text)
return 1
         elseif Mutes[user.sName] == 1 then
user:SendData(BotName,"You are muted. your message has been blocked ! ! !")
return 1
         end
      end
      if strsub(data, 1, 5) == "$To: " then
      local s,e,whoTo,from,text = strfind(data, "%$To:%s(%S+)%sFrom:%s(%S+)%s$(.*)$")
      if whoTo == BotName then
local data=strsub(data,1,strlen(data)-1)
local _,_,cmd = strfind(data,"$%b<>%s+(%S+)")
if user.iProfile == 1 or user.iProfile == 0 then
         local Commands = Commands(user, data, cmd)
return Commands
end
      end      
      if whoTo == OpChat then
         if user.bOperator or Invited[user.sName] then
            local s,e,msg = strfind(text,"^%b<>%s+(.+)")
            OpChatRoom(user,msg)
         end
      end
      if whoTo == MasterChat then
         if user.bOperator then
            local s,e,msg = strfind(text,"^%b<>%s+(.+)")
            MasterChatRoom(user,msg)
         end
      end
      if whoTo == PmToOps then
local data=strsub(data,1,strlen(data)-1)
local _,_,message = strfind(data,"$%b<>%s+(.+)")
SendPmToOps(OpChat, "The user "..user.sName.." wants to inform us about : "..message)
user:SendPM(PmToOps,"Your Message has been delivered to  "..OpChat.." and Ops will handle it  !! ")
         end
      end
   local tmp = strsub(data,1,1)
if tmp == "<" then
local s, e, str = strfind(data,"%b<> (.*)|")
if not iscommand(str) then
if (user.bOperator) then
DoUpdOpStats(user,str)
else
DoUpdUserStats(user,str)
end
end
end
if (strsub(data,1,1) == "<" ) then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind( data,"%b<>%s+(%S+)" )
if (cmd=="+stats")then
pm = 0
ShowTop15(user)
end
end
   if HomeMadeTimer ~= strfind(date("%M"), "^%d") then
      HomeMadeTimer = strfind(date("%M"), "^%d")
      lucifer = nil
      lucifer = {}
   end
   if AUTO == 1 then
      if CleanDay ~= date("%x") then -- user cleaning trigger, works as a timer without a timer
         CleanDay = date("%x")
         CleanUsers()
      end
   end
end


Grtzzz
DJ Bert
Title:
Post by: Themaster on 28 December, 2004, 22:59:28
Nope...it not work on the pm but in main it works

but i got this error
Syntax error: attempt to call global `Commands' (a nil value)
stack traceback:
   1:  function `DataArrival' at line 183 [file `...ettingsHub\scripts\Blade1.1.lua']

     if strsub(data, 1, 5) == "$To: " then
      local s,e,whoTo,from,text = strfind(data, "%$To:%s(%S+)%sFrom:%s(%S+)%s$(.*)$")
      if whoTo == BotName then
local data=strsub(data,1,strlen(data)-1)
local _,_,cmd = strfind(data,"$%b<>%s+(%S+)")
if user.iProfile == 1 or user.iProfile == 0 then
         local Commands = Commands(user, data, cmd)
[COLOR=red]return Commands[/COLOR]
end
      end  
the red are the error
Title:
Post by: [_XStaTiC_] on 28 December, 2004, 23:32:08
I'm not sure, but i think the word Commands must be Command


        local Command = Command(user, data, cmd)
         return Command

I'm also missing the prefix command, or do you want the commands whitout the prefix in PM
Title:
Post by: Themaster on 29 December, 2004, 00:02:34
no i do have try it...
Title:
Post by: bastya_elvtars on 29 December, 2004, 00:04:31
Simplified:

     if strsub(data, 1, 5) == "$To: " then
     local _,_,whoTo= strfind(data, "%$To:%s(%S+)%s+")
     if whoTo == BotName then
local data=strsub(data,1,strlen(data)-1)
local _,_,cmd = strfind(data,"$%b<>%s+(%S+)")
if user.bOperator then
return Commands(user, data, cmd)
end
     end  
 end
Title:
Post by: Themaster on 29 December, 2004, 00:08:24
Ok...that do something...but now i got that here in main
[00:07:07]   You are not allowed to use this command
Title:
Post by: bastya_elvtars on 29 December, 2004, 00:11:45
the chunk you posted is for ops only
Title:
Post by: Themaster on 29 December, 2004, 00:15:32
K...but the ops do have 2 use the command on pm 2 instead of main i mean both
Title:
Post by: bastya_elvtars on 29 December, 2004, 00:17:10
QuoteOriginally posted by Themaster
K...but the ops do have 2 use the command on pm 2 instead of main i mean both

huh?

i cannot understand - i m a bit sleepy
Title:
Post by: Themaster on 29 December, 2004, 00:20:17
k...i'm just have try with master and ops it still the same i got in main
Title:
Post by: bastya_elvtars on 29 December, 2004, 02:03:21
what you are doing wrong is the following:

you wanna add features to your script. first make the core work, then it will be a pleasure to add features. so use 1 or 2 commands, make the checker... the others are easy

ask for lawmaker source @ typhoon
Title:
Post by: Themaster on 29 December, 2004, 13:33:31
k...but i still not understan that problem i got on that