How to know shared slots
 

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

How to know shared slots

Started by xjr13sp, 21 December, 2003, 11:01:02

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

xjr13sp

Hi all,

I'd like to add a new command for my OPs.
A command wich give the number of a user's shared slots... as '+nbslots '

Is someone knows haw to parse the $SR command in order to find the good information?

plop

if you mean the amount of uploads slots then give this a try.
TheCommand = "+nbslots"

function DataArival(user, data)
   if user.bOperator ~= nil then
      if (strsub(data, 1, 1) == "<") then
         data = strsub(data, 1, (strlen(data)-1))
         s,e,cmd,who = strfind(data, "%b<>%s+(%S+)%s*(%S*)")
         if cmd == TheCommand then
            if who == "" then
               user:SendData("Slots", "I really need to know a username as i'm not psychic|")
            else
               victem = GetItemByName(who)
               if victem == nil then
                  user:SendData("Slots", who.." is not in the hub|")
               else
                  local _,b, slots = strfind(victem.sMyInfoString,"S:(%x+)") 
                  if slots ~= nil then
                     user:SendData("Slots", who.." has "..slots.." upload slots|")
                  end
               end
            end
         end
      end
   end
end
if you want 2 see the amount of used/free slots i have some more work 2 do. lol

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 <----<<

xjr13sp

I think it's what I search for, but how does it work ?  :D
When I type '+nbslots' or '+nbslots xjr13sp 'in the main chat I have no responses  :(

plop

sorry spelling error on DataArrival   seems that that is spelled with 2 r's. lol
Bot = "Slots"

TheCommand = "+nbslots"

function DataArrival(user, data)
   if user.bOperator ~= nil then
      if (strsub(data, 1, 1) == "<") then
         data = strsub(data, 1, (strlen(data)-1))
         s,e,cmd,who = strfind(data, "%b<>%s+(%S+)%s*(%S*)")
         if cmd == TheCommand then
            if who == "" then
               user:SendData(Bot, "I really need to know a username as i'm not psychic|")
            else
               victem = GetItemByName(who)
               if victem == nil then
                  user:SendData(Bot, who.." is not in the hub|")
               else
                  local _,b, slots = strfind(victem.sMyInfoString,"S:(%x+)") 
                  if slots ~= nil then
                     user:SendData(Bot, who.." has "..slots.." upload slots|")
                  end
               end
            end
            return 1
         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 <----<<

xjr13sp

Hi,

I tested your changes, but it doesn't work more  :(
I have this :

+nbslots
I really need to know a username as i'm not psychic
+nbslots ludo
(no response with this last command)

plop

funny works here.
next try, this gives output if no slots were found, maby it can help 2 find the error.
Bot = "Slots"

TheCommand = "+nbslots"

function DataArrival(user, data)
   if user.bOperator ~= nil then
      if (strsub(data, 1, 1) == "<") then
         data = strsub(data, 1, (strlen(data)-1))
         s,e,cmd,who = strfind(data, "%b<>%s+(%S+)%s*(%S*)")
         if cmd == TheCommand then
            if who == "" then
               user:SendData(Bot, "I really need to know a username as i'm not psychic|")
            else
               victem = GetItemByName(who)
               if victem == nil then
                  user:SendData(Bot, who.." is not in the hub|")
               else
                  local _,b, slots = strfind(victem.sMyInfoString,"S:(%d+)") 
                  if slots ~= nil then
                     user:SendData(Bot, who.." has "..slots.." upload slots|")
                  else
                     user:SendData(Bot, who.." made me confused, couldn't find his slots|")
                  end
               end
            end
            return 1
         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 <----<<

xjr13sp

It seems to work prefectly!!
Thank you plop  :))

SMF spam blocked by CleanTalk