PtokaX forum

Development Section => Your Developing Problems => Topic started by: WooshMan on 14 February, 2004, 15:33:34

Title: Using and not using the hubsoft commands
Post by: WooshMan on 14 February, 2004, 15:33:34
I understand that if I put:

Return 1 in the DataArrival function,  it stops the hubsoft from processing cmds.

Now what if I want to stop the hubsoft processing some commands but not others?

Example:

!help - will use hubsoft !help.  If I have my own !help, it processes both unless I return 1 in the DA but that turns all Hubsoft processing off so I loose commands like !ban user.

I thought this would work, but doesn't:

function DataArrival(user, data)

if( strsub(data, 1, 1) == "<" ) then
 data=strsub(data,1,strlen(data)-1)
 local s,e,cmd = strfind(data, "%b<>%s+(%S+)")
               if cmd == prefix .."help" then
                  MainCommands(user, data)
               return 1
               else
                  MainCommands(user, data)
               end
end

but it doesn't work.  When I tried that, any hubsoft command worked except !help.

Any Idea's please?

Thanks

Woosh
Title:
Post by: plop on 15 February, 2004, 06:22:12
it all depends where you place the return 1.
for a hint take a look @ crazy bot and then specialy what the global sssst does.
i'll make the hint a bit more clear, sssst starts with being 0.
if a bot command it found it's changed to 1.
next when your done with all the commands you check sssst in dataarrival, if it's 1 you do a return 1.

plop
Title:
Post by: WooshMan on 15 February, 2004, 11:17:13
Thank you Plop, my idea was right, but scripting wrong....

I have done it as per Cracy Bot and it works a treat... Thanks :-)

Solution:


function DataArrival(user, data)

xtracmd = 0

if( strsub(data, 1, 1) == "<" ) then
MainCommands(user, data)
if xtracmd == 1 then
return 1
end
end
end


-- cmds file ----
if cmd == prefix .."help" then
help(user,data)  --- go and do !help cmd
xtracmd = 1 -- make sure hubsoft ignores !help and does not run its own !help
end

Thanks again Plop :-)
Title:
Post by: NightLitch on 16 February, 2004, 00:39:26
Nice solusions. but you can do it simpler if you want to.

your code Woosh:
function DataArrival(user, data)

xtracmd = 0

if( strsub(data, 1, 1) == "<" ) then
MainCommands(user, data)
if xtracmd == 1 then
return 1
end
end
end


-- cmds file ----
if cmd == prefix .."help" then
help(user,data)  --- go and do !help cmd
xtracmd = 1 -- make sure hubsoft ignores !help and does not run its own !help
end

my code:
function DataArrival(user, data)
if( strsub(data, 1, 1) == "<" ) then
     MainCommands(user, data)
end
end


-- cmds file ----
if cmd == prefix .."help" then
help(user,data)  --- go and do !help cmd
return 1 -- make sure hubsoft ignores !help and does not run its own !help
end

just so you learn m8.

Talk soon. Visit sometime when hub is up.

/NL