help with freshstuff...track order..
 

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

help with freshstuff...track order..

Started by GaMeFaNaTiC, 18 December, 2003, 16:24:34

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

GaMeFaNaTiC

--FreshStuff v.2.0 
--You need a folder called "txt" in your Ptokax scripts folder, like this /scripts/txt/ 

--Name this bot to anything you like 
bot = "[gG?]Network" 

--Name the commands to what U like 
--This command adds stuff, syntax : +addalbum THESTUFF 
cmd1 = "+addalbum" 

--This command shows the stuff, syntax : +albums THESTUFF 
cmd2 = "+albums" 

--This command deletes an entry, syntax : +delalbum THESTUFFNUMBER 
cmd3 = "+delalbum" 


File1 = "AlbumsAll.txt" 
File2 = "AlbumsConnect.txt" 

function Main() 
frmHub:RegBot(bot)
end

newtunes={} 

curtime = date("[%d-%m-%Y]") 

function NewUserConnected(curUser) 
DoNotOpenFile(curUser, File2) 

end 

function OpConnected(curUser) 
DoNotOpenFile(curUser, File2) 
end 



function DataArrival(curUser,data) 

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

if (strfind(strlower(data), strlower(cmd1))) and curUser.bOperator then 
s,e,cmd,tune = strfind( data, "%b<>%s+(%S+)%s+(.*)" ) 
if ( tune == nil or tune == "" ) then 
curUser:SendPM(bot, " If you want to add a tune type +addalbum YOURSTUFF in main chat ") 
return 1 
else 
ReadTunes1(File1) 
curtune=" [gG?] "..tune.." " 
newtunes[1]=curtune 
SendToAll(newtunes[1]) 
WriteAddtunes1(File1) 
WriteNewTunes1(File2) 
return 1 
end 
end 

if (strfind(strlower(data), strlower(cmd2))) then 
OpenFile(curUser, File1) 
end 

if (strfind(strlower(data), strlower(cmd3))) and curUser.bOperator then 
if curUser.bOperator then 
s,e,cmd,num = strfind( data, "%b<>%s+(%S+)%s+(.*)" ) 
num2=tonumber (num) 
if ( num2 == nil ) then 
curUser:SendPM(bot, " To delete a Tune type +delalbum THESTUFFNUMBER!!! in main chat ") 
return 1 

else 

ReadTunes2(File1) 
newtunes[num2]=nil 
curUser:SendPM(bot, " Tune Nr. "..num2.." was deleted.") 
WriteAddtunes1(File1) 
WriteNewTunes1(File2) 
return 1 
end 
end 
end 
end 
end 
---------------------------------------------------------------------- 
function ReadTunes1(File1) 
local handle = openfile("txt/"..File1, "r") 
if (handle) then 
local line = read(handle) 
while line do 
s,e,ind,val = strfind( line, "(%S+)%s+(.*)") 
ind = ind+1 
newtunes[ind]=val 
line = read(handle) 
end 
closefile(handle) 
end 
end 
---------------------------------------------------------------------- 
function ReadTunes2(File1) 
local handle = openfile("txt/"..File1, "r") 
var1 = 0 
if (handle) then 
local line = read(handle) 
while line do 
var1 = var1 +1 
s,e,ind,val = strfind( line, "(%S+)%s+(.*)") 
newtunes[var1]=val 
line = read(handle) 
end 
closefile(handle) 
end 
end 
---------------------------------------------------------------------- 
function WriteAddtunes1(File1) 
local handle = openfile("txt/"..File1, "w") 
var2 = 0 
for index, value in newtunes do 
var2 = var2+1 
write(handle,var2.." "..value.."\r\n") 
if var2 == 20 then 
break 
end 
end 
closefile(handle) 
end 
---------------------------------------------------------------------- 
function WriteNewTunes1(File2) 
local handle = openfile("txt/"..File2, "w") 
var3 = 0 
for index, value in newtunes do 
var3 = var3+1 
write(handle,var3.." "..value.."\r\n") 
if var3 == 5 then 
break 
end 
end 
closefile(handle) 
end 
---------------------------------------------------------------------- 
function OpenFile(curUser, File) 
local msgfromtxt ="\r\n" 
readfrom("txt/"..File) 
while 1 do 
local line = read() 
if ( line == nil ) then 
break 
else 
msgfromtxt = msgfromtxt.." "..line.."\r\n" 
end 
end 
--end 
curUser:SendPM(bot, "\r\n".. 
"\r\n".. 
" --------- The Latest Albums -------- \r\n".. 
msgfromtxt.."\r\n".. 
" --------- The Latest Albums -------- \r\n".. 
"\r\n") 
readfrom() 
end 

--------------------------------------------------------------------------------


hi.. this script works yea but i want it to do one more thing to make it perfect.. u c wen i add something like Name - Text and then hit the command +albums, the txt comes at the top (number 1). this can be a problem if there are lots of them cse the new ones wont show and the old ones wil be at the bottom. so i was wondering..  is there a way to make it come at the bottom wen u addalbum instead of the top... plzzz help.. cheers  :))

GaMeFaNaTiC

can any1 help plz  :(  ;(

c h i l l a

if think I did this script once but its way old..

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

	if (strfind(strlower(data), strlower(cmd1))) and curUser.bOperator then 
		s,e,cmd,tune = strfind( data, "%b<>%s+(%S+)%s+(.*)" ) 
		if ( tune == nil or tune == "" ) then 
			curUser:SendPM(bot, " If you want to add a tune type +addalbum YOURSTUFF in main chat ") 
			return 1 
		else 
			ReadTunes1(File1) 
			curtune=" [gG?] "..tune.." " 
			newtunes[1]=curtune 
			SendToAll(newtunes[1]) 
			WriteAddtunes1(File1) 
			WriteNewTunes1(File2) 
			return 1 
		end 
	end

but this code is weird...
anyway get a newer version from here
I don't do anything with it anymore, maybe someone else wants to keep it up dunno..  but just replace this line

tinsert ( newstuff, 1, { str1,str2,str3.sName,str4 } )

whith this

tinsert ( newstuff, { str1,str2,str3.sName,str4 } )

should do the trick..

GaMeFaNaTiC

hmm yo chilla this new 1 is confusing me too much lol.. evrything if different. ah wel guess i gotta leave it like this unless sme1 knows.. thanks tho  :)

BlazeXxX

Hi GaMeFaNaTiC,
I done the changes for you as per chilla's advice :)

Get the fixed version ---= HERE =---

I will be deleting the file in 7 days time :)

GaMeFaNaTiC

thanks blazexxx..  :]  :]  :]

GaMeFaNaTiC

btw... uno the 'fresh-files' folder... do i need to rename it to txt or shal i jus put it in the ptokax folder?

GaMeFaNaTiC

hello again, so to bother u lot once again but the new version had too much of what i didnt want. i also found out from the old version...

newtunes[1]=curtune 
SendToAll(newtunes[1])


this bit where it says [1] meanin it will add at 1 all the time.. if i make it 21 then it wil go at 21 all the time.. thre prob isnt a way but how can i mke it go at the bottom .. lol any help??? chillaa? :))

c h i l l a

#8
GaMeFaNaTiC

simple

tinsert(newtunes,curtune)
SendToAll(newtunes[getn(newtunes)])

or

tinsert(newtunes,curtune)
SendToAll(curtune)


GaMeFaNaTiC

yo thankss chilla.. one thing tho.. i was close to 20 listings. i added some but it only goes up to 20 then wen i add more it dont show anymore than 20 :/ damn so close aswel.. wtz the problem here chilla.. any idea..

--FreshStuff v.2.0 
--You need a folder called "txt" in your Ptokax scripts folder, like this /scripts/txt/ 

--Name this bot to anything you like 
bot = "[gG?]Network" 

--Name the commands to what U like 
--This command adds stuff, syntax : +addalbum THESTUFF 
cmd1 = "+addalbum" 

--This command shows the stuff, syntax : +albums THESTUFF 
cmd2 = "+albums" 

--This command deletes an entry, syntax : +delalbum THESTUFFNUMBER 
cmd3 = "+delalbum" 


File1 = "AlbumsAll.txt" 
File2 = "AlbumsConnect.txt" 

function Main() 
frmHub:RegBot(bot)
end

newtunes={} 

curtime = date("[%d-%m-%Y]") 

function NewUserConnected(curUser) 
DoNotOpenFile(curUser, File2) 

end 

function OpConnected(curUser) 
DoNotOpenFile(curUser, File2) 
end 



function DataArrival(curUser,data) 

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

if (strfind(strlower(data), strlower(cmd1))) and curUser.bOperator then 
s,e,cmd,tune = strfind( data, "%b<>%s+(%S+)%s+(.*)" ) 
if ( tune == nil or tune == "" ) then 
curUser:SendPM(bot, " If you want to add a tune type +addalbum YOURSTUFF in main chat ") 
return 1 
else 
ReadTunes1(File1) 
curtune=" [gG?] "..tune.." " 
tinsert(newtunes,curtune) 
SendToAll(curtune) 
WriteAddtunes1(File1) 
WriteNewTunes1(File2) 
return 1 
end 
end 

if (strfind(strlower(data), strlower(cmd2))) then 
OpenFile(curUser, File1) 
end 

if (strfind(strlower(data), strlower(cmd3))) and curUser.bOperator then 
if curUser.bOperator then 
s,e,cmd,num = strfind( data, "%b<>%s+(%S+)%s+(.*)" ) 
num2=tonumber (num) 
if ( num2 == nil ) then 
curUser:SendPM(bot, " To delete a Tune type +delalbum THESTUFFNUMBER!!! in main chat ") 
return 1 

else 

ReadTunes2(File1) 
newtunes[num2]=nil 
curUser:SendPM(bot, " Tune Nr. "..num2.." was deleted.") 
WriteAddtunes1(File1) 
WriteNewTunes1(File2) 
return 1 
end 
end 
end 
end 
end 
---------------------------------------------------------------------- 
function ReadTunes1(File1) 
local handle = openfile("txt/"..File1, "r") 
if (handle) then 
local line = read(handle) 
while line do 
s,e,ind,val = strfind( line, "(%S+)%s+(.*)") 
ind = ind+1 
newtunes[ind]=val 
line = read(handle) 
end 
closefile(handle) 
end 
end 
---------------------------------------------------------------------- 
function ReadTunes2(File1) 
local handle = openfile("txt/"..File1, "r") 
var1 = 0 
if (handle) then 
local line = read(handle) 
while line do 
var1 = var1 +1 
s,e,ind,val = strfind( line, "(%S+)%s+(.*)") 
newtunes[var1]=val 
line = read(handle) 
end 
closefile(handle) 
end 
end 
---------------------------------------------------------------------- 
function WriteAddtunes1(File1) 
local handle = openfile("txt/"..File1, "w") 
var2 = 0 
for index, value in newtunes do 
var2 = var2+1 
write(handle,var2.." "..value.."\r\n") 
if var2 == 20 then 
break 
end 
end 
closefile(handle) 
end 
---------------------------------------------------------------------- 
function WriteNewTunes1(File2) 
local handle = openfile("txt/"..File2, "w") 
var3 = 0 
for index, value in newtunes do 
var3 = var3+1 
write(handle,var3.." "..value.."\r\n") 
if var3 == 5 then 
break 
end 
end 
closefile(handle) 
end 
---------------------------------------------------------------------- 
function OpenFile(curUser, File) 
local msgfromtxt ="\r\n" 
readfrom("txt/"..File) 
while 1 do 
local line = read() 
if ( line == nil ) then 
break 
else 
msgfromtxt = msgfromtxt.." "..line.."\r\n" 
end 
end 
--end 
curUser:SendPM(bot, "\r\n".. 
"\r\n".. 
" --------- The Latest Albums -------- \r\n".. 
msgfromtxt.."\r\n".. 
" --------- The Latest Albums -------- \r\n".. 
"\r\n") 
readfrom() 
end 

--------------------------------------------------------------------------------

GaMeFaNaTiC

yo chilla things are messin up now.. i fink we shud forget this eh.. thanks for the help tho. dont wory bout the order thing. cheers :))

BlazeXxX

I think it got something do here in this line, maybe wrong..

if var2 == 20 then

Try changing that value to something higher!

c h i l l a

true  BazeXxX,...  its that,  some things would need to be rewritten, haven't thaught about that, but hey, feel free to do what you want, anybody actually :)

BlazeXxX

Yipee Got it rite then.. lol..

GaMeFaNaTiC, Download the file from the same location i gave b4 and just delete ur old freshstuff scripts and the texts in the txt folder.

Just copy the Fresh-Files into the script directory. So don't bother moving the files inside it to txt/ .

e.g. C:\Hub\Scripts\Fresh-Files
e.g. C:\Hub\Scripts\FreshStuff-V.2.60.lua

Thats how it wud look like if u install it properly!
You are using 2.0 V, which is way too old!

The file i am hosting for u is v2.6!! It has setting file, which will let u modify the maximum no of releases to display,etc..

Please take a look at it again! I feel its 200 x better than the one u using now!

Byezz,
BlazeX

GaMeFaNaTiC

thanks guys.. blazexxx , the new one has a lot of extra stuff which i dont realy need, all i want is this basic thing. anyway. i followed ur instructions and it worked. a number cmes underneath it tho, dno why. lol for example
25  [gG?] testing this out today 
 26 26


it shows 26 26 lol.. any idea on this very lst thing ..

BlazeXxX

Hmm.. so its showing after 25th record?

Is it coming after every lines? or just the last line after 25th record?

Could u pls tell me where to get the 2.0v? so i can modify it for u and give it to u ?

Send me the one u got in my pvt or upload it to some site and give me the link..

GaMeFaNaTiC

yo blaze, it happens after all the lines, also when i delete a few lines, the numbers remain ther like

15 18
16 18
17 18
18

i cant seem to find the original of freshstuff 2.0 and itz hard to find on the net. i gt it from chilla's site on old scripts page but that dont work now. all i did was change the script so ops can only use the add and del fnction and that it wud show in pm. blaze, can u modify the script above that i posted becasue thaz all of it. sory to bother again. cheers...

BlazeXxX

Hmm.. I will try my best! Give me some time to find the old script, or is it possible for you  to zip the files u have and send it to me? If yes, i will leave u my mail id in ur pvt..

GaMeFaNaTiC

Freshstuff [GaMeFaNaTiC]

this has my 3 lua files along wit its txt files. hope you can fix the problem here blaze.. thnks for the help. msg ere asap once you've fnishd. cheers.

BlazeXxX

OK i tried and it seems the problem is here:

tinsert(newtunes,curtune)
SendToAll(newtunes[getn(newtunes)])

or

tinsert(newtunes,curtune)
SendToAll(curtune)


I tried increasing the no of listing to 500 and the bug is not there. Since i am not a advanced programmer, does anyone know what to replace those lines with to make the newest item go at bottom ?

plop

tinsert(newtunes, -1, curtune)
that should do it.

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

GaMeFaNaTiC

it worked the first time.. then wen i added smething else.. the previous ones went at the top :S.. can u chek it plop n see what happns.  :(

plop

QuoteOriginally posted by GaMeFaNaTiC
it worked the first time.. then wen i added smething else.. the previous ones went at the top :S.. can u chek it plop n see what happns.  :(
instead of fixing it i made a fresh new version, i hope it works like you would like it.
has some more commands.
+albums -- shows the full list
+newalbums -- shows the latest xx
+reloadalbums -- reloads the txt file (incase you manualy edit the file)
it uses only 1 file (AlbumsAll.txt)
from that i'm pulling the latest xx entry's 2 show on +newalbums.
-- FreshStuff v.3.0 
-- original idea/script by chilla
-- completely rewriten by plop


-- Name the commands to what U like 
-- This command adds stuff, syntax : +addalbum THESTUFF2ADD 
cmd1 = "+addalbum" 

-- This command shows the stuff, syntax : +albums
cmd2 = "+albums" 

-- This command deletes an entry, syntax : +delalbum THESTUFF2DELETE 
cmd3 = "+delalbum" 

-- This command shows the latest stuff, syntax : +newalbums
cmd4 = "+newalbums"

-- This command reloads the txt file. syntax : +reloadalbums 
-- (this command is needed if you manualy edit the text file)
cmd5 = "+reloadalbums"

-- Show latest stuff on entry 1=yes, 0=no
ShowOnEntry = 1

-- Max stuff shown on newalbums/entry
MaxNew = 20

-- The file storing the stuff
file = "txt/AlbumsAll.txt"

-- Name of the bot
Bot = "post-it_memo"

--------------------- don't change anything below here
AllStuff = {}
NewestStuff = {}

function Main() 
   frmHub:RegBot(Bot)
   Reload()
end

function NewUserConnected(user) 
   if ShowOnEntry == 1 then
      user:SendPM(Bot, MsgNew.."|")
   end
end 

function OpConnected(user) 
   if ShowOnEntry == 1 then
      user:SendPM(Bot, MsgNew.."|")
   end
end 

function DataArrival(user,data) 
   if (strsub(data, 1, 1) == "<") then 
      data = strsub(data,1,strlen(data)-1) 
      s,e,cmd,tune = strfind(data, "%b<>%s+(%S+)%s*(.*)")
      if cmd == cmd2 then
         user:SendPM(Bot, MsgAll.."|")
         return 1
      elseif cmd == cmd4 then
         user:SendPM(Bot, MsgNew.."|")
         return 1
      elseif user.bOperator then
         if cmd == cmd3 then
            if tune ~= "" then
               DelStuff(user, tune)
            else
               user:SendData(Bot, "yea right, like i know what i got 2 delete when you don't tell me!|")
            end
            return 1
         elseif cmd == cmd1 then
            if tune ~= "" then
               AddStuff(user, tune)
            else
               user:SendData(Bot, "yea right, like i know what you got 2 add when you don't tell me!|")
            end
            return 1
         elseif cmd == cmd5 then
            Reload()
            user:SendData(Bot, "Albums reloaded!|")
            return 1
         end
      end
   end
end

function OpenStuff()
   AllStuff = nil
   NewestStuff = nil
   AllStuff = {}
   NewestStuff = {}
   Count = 0
   Count2 = 0
   readfrom(file)
   while 1 do
      local line = read() 
      if ( line == nil ) then 
         break 
      else 
         Count = Count +1
         AllStuff[Count]=line
      end
   end
   readfrom()
   if Count > MaxNew then
      local temp = Count - MaxNew + 1
      for i=temp, Count do
         Count2 = Count2 + 1
         NewestStuff[Count2]=AllStuff[i]
      end
   else
      NewestStuff = AllStuff
   end
end

function SaveStuff()
   writeto(file)
   for i=1,Count do
      if AllStuff[i] then
         write(AllStuff[i].."\n")
      end
   end
   writeto()
end

function ShowAlbums(table)
   Msg = "\r\n"
   if table == NewestStuff then
      for i=1, Count2 do
         Msg = Msg..NewestStuff[i].."\r\n"
      end
      MsgNew = "\r\n\r\n".." --------- The Latest Albums -------- \r\n"..Msg.."\r\n --------- The Latest Albums -------- \r\n\r\n"
   else
      for i=1, Count do
         Msg = Msg..AllStuff[i].."\r\n"
      end
      MsgAll = "\r\n\r\r\n".." --------- All The Albums -------- \r\n"..Msg.."\r\n --------- All The Albums -------- \r\n\r\n"
   end
end

function AddStuff(user, what)
   Count = Count + 1
   AllStuff[Count]=what
   user:SendData(Bot, what.." is added to the albums|")
   SaveStuff()
   Reload()
end

function DelStuff(user, what)
   Okie = nil
   for a,b in AllStuff do
      if b == what then
         AllStuff[a]=nil
         user:SendData(Bot, what.." is removed from the albums|")
         Okie = 1
         break
      end
   end
   if Okie then
      SaveStuff()
      Reload()
   else
      user:SendData(Bot, what.." wasn't found in the albums|")
   end
end

function Reload()
   OpenStuff()
   ShowAlbums(NewestStuff)
   ShowAlbums(AllStuff)
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 <----<<

GaMeFaNaTiC

yo plop
thankss for this.. when i type +albums or +newalbums it dont work? :S

GaMeFaNaTiC

i get this

Syntax Error: attempt to concat global `MsgAll' (a nil value)


when i type +albums or the other 1

SMF spam blocked by CleanTalk