PtokaX forum

Archive => Archived 5.0 boards => Help with scripts => Topic started by: Genius on 13 April, 2005, 23:33:14

Title: Convert to LUA 5
Post by: Genius on 13 April, 2005, 23:33:14
Hi

i need this script to Lua 5 :)
Sory my bad inglish



--changed 2 testdrive4, really buggy.

BotName = "(??M?3?T?g?)?"

tabSlots = {n=0}

tmrSlots = 55

function DataArrival(user, data)

if( strsub(data, 1, 1) == "<" ) then

data=strsub(data,1,strlen(data)-1)

s,e,cmd = strfind(data,"%b<>%s+(%S+)")

if (cmd == "+slots" or cmd == "!slots") then

s,e,cmd,nr = strfind(data,"%b<>%s+(%S+)%s*(.*)")

frmHub:EnableSearchData(1) --opening search

user:SendData("(??M?3?T?g?)?", "Checking...")

-- new user to keep track of, also save the time we started

tinsert(tabSlots, { sName = user.sName, iClock = clock(), tItems = {} })

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

end

end

if (strsub(data, 1, 3) == "$SR") then

-- incoming search results.. lets extract info about free slots

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

local i = 1 while tabSlots do

local table = tabSlots

if not table.tItems[user.sName] then

-- first results from user.sName

table.tItems[user.sName] = free.."/"..all

if (nr == "" and free ~= "0") then

SendToNick(table.sName, "< (??M?3?T?g?)? >  ?  O user  ?  "..user.sName.."  ?  "..free.."/"..all.."  ? ")

elseif (nr ~= "" and all >= nr) then

SendToNick(table.sName, "<(??M?3?T?g?)?> user ~ "..user.sName.." ~ "..all)

end

end

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

-- listing timeout

if getn(table.tItems) == 0 then

SendToNick(table.sName, "<(??M?3?T?g?)?> No users with free slots found", pm)

elseif getn(table.tItems) >= nr then

SendToNick(table.sName, "<(??M?3?T?g?)?> No users with that kind of slots found", pm)

end

SendToNick(table.sName, "<(??M?3?T?g?)?> Done") tremove(tabSlots, i)

frmHub:EnableSearchData(0) -- closing search

else

i = i + 1

end

end

end

end
Title:
Post by: ??????Hawk?????? on 14 April, 2005, 00:05:56
QuoteConvert to LUA 5


LEARN TO USE THE FORUM  



It took me longer to type this reply than it did to find an already converted script...

SEARCH   SEARCH   SEARCH   ....  

and if that Fails  ...   Try LOOKING FOR IT...

??????Hawk??????
Title:
Post by: jiten on 14 April, 2005, 07:21:06
Check this (http://board.univ-angers.fr/thread.php?threadid=4069&boardid=26&sid=2695d29b641dc4a9932bce2533a57bea) thread.

Best regards,

jiten
Title:
Post by: Genius on 01 May, 2005, 05:51:33
hi

sory but i?m loking for script and is not =
my script send info in main chat for user, and another send in pm. Sory my inglish
Title:
Post by: jiten on 01 May, 2005, 11:34:25
QuoteOriginally posted by ?[-?Genius?-]?
hi

sory but i?m loking for script and is not =
my script send info in main chat for user, and another send in pm. Sory my inglish
Just change in the script "SendPM" to "SendData" and the messages will appear on main instead of in PM.

Cheers
Title:
Post by: Genius on 01 May, 2005, 14:24:56
hi

i gangue the script but don?t work :(

Syntax ...\Ambiente de trabalho\Ptolax 17.03\scripts\slots.lua:43: attempt to index global `user' (a nil value)

In main chat apearence this

[13:22] <(??????)?M?3?T?g??>  ? A procurar... ?

and stop :(
Title:
Post by: Dessamator on 01 May, 2005, 14:35:19
--By Tezlo

slots = {}
nslots = 0
timeout = 360 -- cache life in seconds
message = "%s has %d slots free [as of %d minutes ago]"
botname = frmHub:GetHubBotName()

function Main()
SendToAll("$Search Hub:"..botname.." T?F?0?1?.|")
end

function SRArrival(user, data)
local s, e, free, all = string.find(data, " (%d+)/(%d+)\005")
if free ~= "0" then
if not slots[user.sName] then
nslots = nslots + 1
end
slots[user.sName] = { tonumber(free), os.clock() }
end
end

function ChatArrival(user, data)
local s, e, cmd = string.find(data,"^%b<> [!+](%a+)")
if cmd == "slots" then
local now = os.clock()
for k, v in pairs(slots) do
if now > v[2] + timeout then
nslots = nslots - 1
slots[k] = nil
else
user:SendData(botname, string.format(message, k, v[1], math.floor((now-v[2])/60)))
end
end
user:SendData(botname, nslots.." items")
return 1
end
end        
Done!!,

Try that
Title:
Post by: Genius on 02 May, 2005, 01:07:21
Tankx :)
Its working