need help to my DataArrival
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

need help to my DataArrival

Started by Themaster, 24 September, 2004, 01:25:15

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Themaster

this function work

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
this function not work

function DataArrival(user, data)
	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) or OpCommands(user, data, cmd) or MasterCommands(user, data, cmd))
	return Commands
	elseif (strsub(data, 1, 12) == "$OpForceMove") or (strsub(data, 1, 10) == "$ForceMove") and (user.iProfile < 0 or user.iProfile > 0)then
	return 1
	elseif strsub(data, 1, 5) == "$To: " then
	local s, e, to = strfind(data, "$To: (%S+)")
		if to ~= BotName and to ~= OpChat then
			return 0
		else
			if to == 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 = (UserCommands(user, data, cmd) or OpCommands(user, data, cmd) or MasterCommands(user, data, cmd))
			return Commands
			end
      end
   end
   
         elseif to == OpChatName then
           if user.iProfile == 0 or user.iProfile == 1 then
            local s,e,msg = strfind(arg,"^%b<>%s+(.+)")
            OpChatRoom(user,msg)
			end
      end

	if (strsub(data, 1, 1) == "<" ) 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
   end
   
	if (strsub(data,1,7) == "$MyINFO") then
		Tag,Speed,Share = Parse(data)
		TagCheck(Tag,Speed,Share,user)
	end
end
i have create a command fil but it do not work :s

plz i need all the help i can get
peace out...and love to your all scripter..that do the hard work  :D And all thx to your all there are here 2 help!!! :]

blade.lir.dk

Herodes

hey USE the  [ c o d e ] code in here [ / c o d e ]
pls keep it tidy in here we like it as much as u do  ...

Themaster

k then...can you see what i have an error on it ....

i still don't what i do wrong :s
peace out...and love to your all scripter..that do the hard work  :D And all thx to your all there are here 2 help!!! :]

blade.lir.dk

Herodes

what is the file u are getting from like ?

is it layed out as variables ?

I mean is it like this :
acmd = "!you"
bcmd = "!can"
ccmd = "!edit"
dcmd = "!your"
ecmd = "!posts"
...?


btw it is l8 over here .. so I am off to bed ..

I am holding a friends gathering for bbq, lots of drinks and such in my house ..

any1 invited details about my location in my profile  ( lol )

Themaster

peace out...and love to your all scripter..that do the hard work  :D And all thx to your all there are here 2 help!!! :]

blade.lir.dk

Herodes

what are the contents of ur commands.lua ?

Themaster

#6
need a little help with my Commands.lua....this is not working :s...what is wrong i can't get it right
plz help me

and here are my  assert file
assert(dofile("blade/Commands.lua"))

this is my DataArrival
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
         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
      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

   	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 = (UserCommands(user, data, cmd) or OpCommands(user, data, cmd) or MasterCommands(user, data, cmd))
		return Command
		end
   end


and this is my Commands.lue

function UserCommands(user, arg, cmd)

      if cmd == "myip" then
        SendToUser(BotName, "Your IP is *** "..user.sIP)
         return 1
      elseif cmd == "version" then
         SendToAll("The Script ", "  "..Version ..Build .. Creators)
         return 1
      end 
   end

function OpCommands(user,arg, cmd)

-----------------------------------------------------------------------------------------------------------------------------------------------
-- only [OPERATORS] and [MASTERS] can do the following commands

		if user.iProfile == 0 or user.iProfile == 1 then
   end
end

function MasterCommands(user, arg, cmd)

-------------------------------------------------------------------------------------------------------------------------------------------------
-- only [MASTERS] can do the following commands
				
		if user.iProfile == 0 then
   end
end


plz help me....:)
peace out...and love to your all scripter..that do the hard work  :D And all thx to your all there are here 2 help!!! :]

blade.lir.dk

Themaster

i can't get my command function to work.
i need some help i'm stuck on it now:s


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

this are in my DataArrival

  if (strsub(data,1,1) == "<") then 
      data=strsub(data,1,strlen(data)-1) 
      local s,v, cmd = strfind(data, "%b<>%s+(%S+)") 
		local Commands = (UserCommands(user, data, cmd) or OpCommands(user, data, cmd) or MasterCommands(user, data, cmd))
		return Command
		end
   end

and here are my Command.lua function
function UserCommands(user, arg, cmd)

      if cmd == "myip" then
        user:SendData(BotName, "Your IP is *** "..user.sIP)
         return 1
      elseif cmd == "version" then
         user:SendData("The Script ", "  "..Version ..Build .. Creators)
         return 1
      end 
   end
peace out...and love to your all scripter..that do the hard work  :D And all thx to your all there are here 2 help!!! :]

blade.lir.dk

plop

you have 2x.
if (strsub(data, 1, 1) == "<" ) then
clean up dataarival 1st, then it becomes easyer 2 see whats going wrong.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Themaster

i don't that now.. and it still not working

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
      data=strsub(data,1,strlen(data)-1)
         local Commands = (UserCommands(user, data, cmd) or OpCommands(user, data, cmd) or MasterCommands(user, data, cmd))
         return Command
      else
      local s,v, cmd = strfind(data, "%b<>%s+(%S+)") 
      _,_,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
   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
   
peace out...and love to your all scripter..that do the hard work  :D And all thx to your all there are here 2 help!!! :]

blade.lir.dk

plop

check closely what you are doing here, added comments to help you.
  if (strsub(data, 1, 1) == "<" ) then -- if this is a mainchat msg then do the next
      data=strsub(data,1,strlen(data)-1)
      local Commands = (UserCommands(user, data, cmd) or OpCommands(user, data, cmd) or MasterCommands(user, data, cmd))
      return Command
   else -- if it's not a main chat msg then do the next
      local s,v, cmd = strfind(data, "%b<>%s+(%S+)") 
      _,_,cmd=strfind(data, "%b<>%s+(%S+)") -- this line does the same as the line above
      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
   end

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Themaster

Ok...but i still don't now what i miss on it now...It still not working..i tried anything now and i still miss something on it
peace out...and love to your all scripter..that do the hard work  :D And all thx to your all there are here 2 help!!! :]

blade.lir.dk

Herodes

  if (strsub(data, 1, 1) == "<" ) then
      data=strsub(data,1,strlen(data)-1)
         local Commands = (UserCommands(user, data, cmd) or OpCommands(user, data, cmd) or MasterCommands(user, data, cmd))
         return Command
      else
the ' return Command ' part ...

It doesnt exist as a variable anywhere ... so it is logical that it doesnt return anything ..

and the
local Commands = (UserCommands(user, data, cmd) or OpCommands(user, data, cmd) or MasterCommands(user, data, cmd))
this line in theory stands correct .. since those functions return 1 if any of the cmds is found ..

although the operation of the script halts there ..

Themaster

It do exist i can't get into main now only this coming op in the main now "wrong use read !help menu !!"
peace out...and love to your all scripter..that do the hard work  :D And all thx to your all there are here 2 help!!! :]

blade.lir.dk

Themaster

Need still help to my Commands.lua i can't get it wright..i only got this in main wrong use read !help menu !!
peace out...and love to your all scripter..that do the hard work  :D And all thx to your all there are here 2 help!!! :]

blade.lir.dk

plop

you had Commands and Command.
but 2 get you on your way try the next dataarival.
function DataArrival(user, data)
   if (strsub(data, 1, 1) == "<" ) then
      data=strsub(data,1,strlen(data)-1)
      local s,v, cmd = strfind(data, "%b<>%s+(%S+)")
      if cmd then
         cmd = strlower(cmd)
         local 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
      end
   end
end

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Themaster

it still a problem on it :s...My Commands do not come in main
peace out...and love to your all scripter..that do the hard work  :D And all thx to your all there are here 2 help!!! :]

blade.lir.dk

bastya_elvtars

#17
edited plops post a bit, this function must work

added some help
function DataArrival(user, data) -- fired when hub gets data from client(s)
   if (strsub(data, 1, 1) == "<" ) then -- any mainchat event
      data=strsub(data,1,strlen(data)-1) -- remove end pipe ("|")
      local _,_,cmd = strfind(data, "%b<>%s+([%!%+%#%?]%S+)") -- sees if there is a non-space string after > and it starts with ! or # or + or ?
      if cmd then -- if so then
         cmd = strlower(cmd) -- puts into lowercase ---> case-insensitive
            cmd = strsub(cmd, 2,strlen(cmd)) -- remove 1st char
            if cmd == "says" then
               local _,_,as,message = strfind(data, "%b<>%s+%S+%s+(%S+)%s+(.+)") -- finding params
               SendToAll(as, message) -- doing job
               return 1 -- blocking appearance of command in main
            end
         end
      end
   end
Everything could have been anything else and it would have just as much meaning.

Themaster

#18
thx now i got it work...thx for all of you help i'm happy now....THX :]
peace out...and love to your all scripter..that do the hard work  :D And all thx to your all there are here 2 help!!! :]

blade.lir.dk

Themaster

#19
i still got a small problem with the command's
i can get 2 things working on it but when i try to pass more command's on it..then it made a syntax error
Syntax error: attempt to index global `awayArray' (a nil value)
stack traceback:
   1:  function `UserCommands' at line 14 [file `blade/Commands.lua']
   2:  function `DataArrival' at line 85 [file `...ngs\ scripts\Blade?.lua']


     if (strsub(data, 1, 1) == "<" ) then -- any mainchat event
      data=strsub(data,1,strlen(data)-1)  -- remove end pipe ("|")
      local _,_,cmd = strfind(data, "%b<>%s+([%!%+%#%?%?]%S+)")  -- sees if there is a non-space string after > and it starts with ! or # or + or ?
      if cmd then -- if so then
         cmd = strlower(cmd) -- puts into lowercase ---> case-insensitive
            cmd = strsub(cmd, 2,strlen(cmd)) -- remove 1st char
            if cmd == "says" then
               local _,_,as,message = strfind(data, "%b<>%s+%S+%s+(%S+)%s+(.+)") -- finding params
               SendToAll(as, message) -- doing job
               return 1  -- blocking appearance of command in main
            end
         local Commands = (UserCommands(user, data, cmd) or OperatorCommands(user, data, cmd) or MasterCommands(user, data, cmd))
         return Commands
         end
      end
function UserCommands(user, data, cmd)
   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
   elseif cmd=="away" then
      s,e,cmd,arg = strfind( data, "%b<>%s+(%S+)%s+(.*)" )
      if (not (arg)) then
      arg = "Default away msg"
      end
      SendToAll(BotName,date("user "..user.sName.." told us at %T that he is away! He left this message: ")..arg.." .")
      awayArray[user.sName]=arg
   end
end
peace out...and love to your all scripter..that do the hard work  :D And all thx to your all there are here 2 help!!! :]

blade.lir.dk

bastya_elvtars

inh the 1st line of your script, include this:

awayArray={}


with this, you create the table, which is a must do thing to use it :)
Everything could have been anything else and it would have just as much meaning.

Themaster

no it do not work...maybe i miss something on it
peace out...and love to your all scripter..that do the hard work  :D And all thx to your all there are here 2 help!!! :]

blade.lir.dk

Themaster

peace out...and love to your all scripter..that do the hard work  :D And all thx to your all there are here 2 help!!! :]

blade.lir.dk

Themaster

i just wont to get some off the things on my script and now i got this
Syntax error: `end' expected (to close `if' at line 76);
  last token read: `if' at line 81 in file `...uments and Settings\den lille\Skrivebord\Hub\scripts\Blade? 1.0.lua'

No syntax errors in script file RightClicker.lua

and here are the settings there are errow on it
  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
      if cmd then 
         cmd = strlower(cmd) 
            cmd = strsub(cmd, 2,strlen(cmd)) 
            if cmd == "says" then
               local _,_,as,message = strfind(data, "%b<>%s+%S+%s+(%S+)%s+(.+)")
               SendToAll(as, message)
               return 1
            end
         end
      end

plz little bit off help
peace out...and love to your all scripter..that do the hard work  :D And all thx to your all there are here 2 help!!! :]

blade.lir.dk

VidFamne

Quotereturn and break statements can only be written as the last statements of a block
So try to put an "end" after 'return Commands'

SMF spam blocked by CleanTalk