Find free slot script
 

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

Find free slot script

Started by bokkepoot, 02 March, 2005, 23:23:25

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

bokkepoot

I'm searching for a script which let users in my hub find free slots.

In the old Prokaxhub (before LUA5 script language) the users can type: "findslots" in the mainchat and they receive a list of all people with free slots.

Is it possible to write such a script in LUA5 ?


Thanks in advance
(also from all the users because they can't without the findslots function)



Bokkepoot

Evo

I am also looking for a script like this, many thanks to anyone who can help.

- Evo.

bokkepoot

Maybe it gives some inspiration when I copy the old LUA4 script here:


________________________________________________________
-- SlotsBot for PtokaX DC Hub 0.3.2.6 Test Drive 4

-- On command +slots, sends a search and checks the results for free slots & total number of slots

-- Sends the results in PM from Hub bot

-- Adaptation by OpiumVolage (01 July 2003) based on

-- retrobot? v0.99?

-- slots module

-- by tezlo

-- 2003

-- Twiddled a bit to have results sent in PM - by bolamix 1 July 2003



-- unused sTarget left for future syntax parsing.



botName = "your_hub_bot"



-- library



function getid(table, name)

return foreachi(table, function(id, item) if item.sName == %name then return id end end)

end



function putitem(table, item)

if not item then return end

local id = getid(table, item.sName)

if id then table[id] = item

else tinsert(table, item) id = table.n

end return id

end





-- events



function OnTimer()

local i = 1 while tabSlots do

local table = tabSlots

if clock() >= table.iClock + tmrSlots then

if table.tItems.n == 0 then SendPmToNick(table.sName, botName, "No users with free slots found|") end

SendPmToNick(table.sName, botName, "Done|")

tremove(tabSlots, i)

if tabSlots.n == 0 then frmHub:EnableSearchData(0) end

else i = i + 1 end

end

end



function slotsOnHub(user, args)

local s, e, free, all = strfind(args, " (%d+)/(%d+)"..strchar(5))

foreachi(tabSlots, function(id, item)

if not getid(item.tItems, %user.sName) then

putitem(item.tItems, { sName = %user.sName, sValue = %free.."/"..%all })

-- if item.sTarget and (%user.sName == item.sTarget) then

-- SendToNick(item.sName, " user "..%user.sName.." "..%free.."/"..%all.."|")

-- item.iClock = item.iClock - tmrSlots

-- elseif not item.sTarget and

if (tonumber(%free) >= item.iNR) then

SendPmToNick(item.sName, botName, " user "..%user.sName.." "..%free.."/"..%all.."|")

end

end end)

end



function doSlots(user, nr, nick)

user:SendPM(botName, "Checking..|")

frmHub:EnableSearchData(1)

SendToAll("$Search Hub:"..Command.." T?F?0?1?.|")

putitem(tabSlots, { sName = user.sName, iClock = clock(), iNR = nr, tItems = {n=0} })

-- putitem(tabSlots, { sName = user.sName, sTarget = nick, iClock = clock(), iNR = nr, tItems = {n=0} })

end





-- init



tmrSlots = 5 -- Number of seconds waiting for replys

tabSlots = {n=0}

Command = "findslots"



function DataArrival(user, data)

if strfind(data, "%b<>%s+("..Command..").*|") then

s, e, nr = strfind(data, "%b<>%s+"..Command.."%s+([0-9]+)")

if s then nr = tonumber(nr) else nr = 1 end

doSlots(user, nr) return 1

end

if strfind(data, "^%$SR") then slotsOnHub(user, data) end

end



function Main()

SetTimer(tmrSlots*1000)

StartTimer()

end
____________________________________________________

bolamix

#3
Hi,
I am also hoping that someone will have the time and knowledge to convert this script. Try as I might, I can't get past the table-handling functions :( I was thinking that maybe nErBoS's "load and save table" script snippet (http://board.univ-angers.fr/thread.php?threadid=3672&boardid=30&styleid=1) could help me, but I don't understand how to use it... ?( It hurts to realize i'm dumber than I thought :rolleyes:

Edit: btw bokkepoot, when you post script code, please use [ code ] [ /code ] tags (without spaces), makes it easier to read ;)
Sharing is of the essence!

Live music >> Aiwadirock! live music hub
PtokaX knowledge >> The PtokaX Wiki

jiten

Check this  thread.

Best regards.

SMF spam blocked by CleanTalk