Hi,
My hub has been runned by ynhub earlier and i figure out that ptokax woudn't been bad.. :)
Now here's my problem. With Ynhub i could create a text commands that:
- Only shows in main and is broadcasted to everyone..
ex: If someone want's to tell the entire hub in main that his go to bed i had a ASCII picture for that...
Is that possible in ptokax?
Please help me
Deeds
So basically it displays a text file. I. e. +bed show an ASCII art and shows: "Joe is going to bed.", where joe is the actual user's name. Or not?
a three step plan..
1. enable textfiles support ..
2. put a file named "bedtime.txt" in ptokaxfolder/txt and paste your ascii of the bed in there.
3. use command !bedtime
-----------------------------------
a three step plan..
1. enable textfiles support ..
2. put a file named "bedtime.txt" in ptokaxfolder/txt and paste your ascii of the bed in there.
3. use command !bedtime
-----------------------------------
Well UwV...
It's not that simple,,,, yes now i got the text command.
But it's sent in pm and only to "the one that writing"!
I would like to have it in MAIN and sent to everyone...
There are quite a lot of scripts that do that, just Search the forum
Do you got any good examples that works?
QuoteOriginally posted by d-deeds
Do you got any good examples that works?
Yes we got loads of good Examples ...
You could too IF only you used the forums Search..
i didn't find very much...
but i find "hawk"s script with ascii,,, this is probably not what i search for? or isit?
/deeds
-- Yet another version AsciiTexter Bot
-- By ??????Hawk?????? 03/07/2005
-- Create an ascii folder within the scripts folder and copy all your ascii files in.
AsciiBotName = botname --// Set Bot name here
SendTo = { --> 1=on/0=off
- = 1, -- Masters
[1] = 1, -- Operators
[2] = 1, -- Vips
[3] = 1, -- Regs
[4] = 1, -- Moderator
[5] = 1, -- NetFounder
[-1] = 1, -- Users
}
function ChatArrival(curUser, data)
data = string.sub(data,1,string.len(data)-1)
local _,_,PRFX,text = string.find( data, "%b<>%s+(%S)(%S+).*" )
if PRFX == Prefix and text and AsciiTable[text] then
local handle,Er = io.open("ascii/"..text..".txt", "r")
if handle then
local line = handle:read("*l")
TempAsciifile = "\r\n"
while line do
TempAsciifile = TempAsciifile.."\r\n"..line
line =handle:read("*l")
end
handle:close()
end
SendToAll(AsciiBotName, "<"..curUser.sName..">\r\n"..TempAsciifile)
return 1
end
end
function Main()
Prefix = "+"
AsciiTable = {}
local sDirectory = "ascii"
local sFileName = "nn.txt"
local sLine = nil;
os.execute("dir /b /a-d \""..sDirectory.."\" > \""..sFileName.."\"");
local ahFile,e = io.open(sFileName,"r")
sLine = ahFile:read("*l");
sLine = string.sub(sLine, 1, (string.len(sLine)-4))
AsciiTable[sLine] = 1
while ( sLine ) do
sLine = ahFile:read("*l");
if sLine ~= nil then
sLine = string.sub(sLine, 1, (string.len(sLine)-4))
AsciiTable[sLine] = 1
end
end
ahFile:close()
os.remove(sFileName);
end
for your needs you are "probably " best following UwV's suggestion..
QuoteOriginally posted by UwV
a three step plan..
1. enable textfiles support ..
2. put a file named "bedtime.txt" in ptokaxfolder/txt and paste your ascii of the bed in there.
3. use command !bedtime
??????Hawk??????
yes but then it's not useful..
the idea is that a person can tell the entire hub something in main with a command...
Uwv's sugestion is very good, but it's sent to the one that writing and in pm... :)
/deeds
ahhh ic ..
the script you posted should work for you ..
create a folder in your scripts folder called ' ascii '
and put all your ascii text files in it ...
??????Hawk??????
well... it works...
but i can't get any message in main,,, well,,, nothing happends at all... i can't even see the command i've typed in main +bed
QuoteOriginally posted by d-deeds
well... it works...
but i can't get any message in main,,, well,,, nothing happends at all... i can't even see the command i've typed in main +bed
does the file bed.txt exist in the ascii folder ... ?
AND did you restart scripts when you put the text file in .. ?
??????Hawk??????
yes and yes...
This sample code can show you where to start, because LUA is really very easy and is fun to work with.-- Reads 'sFile' and sends it to main when command
-- '!bed', '+bed', '?bed', '#bed' is sent to main chat
-- by GeceBekcisi
sBotName = frmHub:GetHubBotName()
sFile = "ascii/bed.txt"
function ChatArrival(curUser, data)
local data = string.sub(data,1, -2)
local s,e,cmd = string.find(data, "%b<>%s[%!%+%?%#%+](%S+)")
if cmd == "bed" then
local filedata ="\r\n\r\n"
for line in io.lines(sFile) do
filedata = filedata..line.."\r\n"
end
SendToAll(sBotName, filedata..curUser.sName.." goes to bed and says: Good night all!\r\n")
return 1
end
end
Play with code, and please feel free to ask about anything. Best regards
THANKS GECEBEKCISI!!!!
That did work just perfect...
Just one tiny little thing...
how do i change in the script so the text "nick goes to bed and says: Good night all! " comes before the ascii? :)
Thank you again VERY MUCH!!
/deeds
You're welcome mate and here it goes: Just change local filedata ="\r\n\r\n"
for line in io.lines(sFile) do
filedata = filedata..line.."\r\n"
end
SendToAll(sBotName, filedata[COLOR=red]..curUser.sName.." goes to bed and says: Good night all!\r\n"[/COLOR])
to local filedata ="\r\n\r\n"[COLOR=red]..curUser.sName.." goes to bed and says: Good night all!\r\n"[/COLOR]
for line in io.lines(sFile) do
filedata = filedata..line.."\r\n"
end
SendToAll(sBotName, filedata)
I hope you see how easy it is in fact ;)
Best Regards
So if i would use two of them they would look like this:
(but if i use that one, only "+rock" works???)
------------------------------
-- Reads 'sFile' and sends it to main when command
-- '!bed', '+bed', '?bed', '#bed' is sent to main chat
-- by GeceBekcisi
sBotName = frmHub:GetHubBotName()
sFile = "ascii/nn.txt"
function ChatArrival(curUser, data)
local data = string.sub(data,1, -2)
local s,e,cmd = string.find(data, "%b<>%s[%!%+%?%#%+](%S+)")
if cmd == "nn" then
local filedata ="\r\n\r\n"..curUser.sName.." Goes to bed, and wish you all.. \r\n"
for line in io.lines(sFile) do
filedata = filedata..line.."\r\n"
end
SendToAll(sBotName, filedata)
return 1
end
end
sBotName = frmHub:GetHubBotName()
sFile = "ascii/rock.txt"
function ChatArrival(curUser, data)
local data = string.sub(data,1, -2)
local s,e,cmd = string.find(data, "%b<>%s[%!%+%?%#%+](%S+)")
if cmd == "rock" then
local filedata ="\r\n\r\n"..curUser.sName.." headbangs and hope that the rest of the hub are with him? \r\n"
for line in io.lines(sFile) do
filedata = filedata..line.."\r\n"
end
SendToAll(sBotName, filedata)
return 1
end
end
Hmm first of all, you need to understand you can define unique functions and you must define unique strings only once in a script (unless you need to define a string again), with only one equation mark..
If I typesString = "StringValue1"
sString will be equal to "StringValue1" whenever I call it in my script. But if I typesString = "StringValue1"
...
sString = "StringValue2"
sString will be equal to "StringValue2" whenever I call it in my script. And also if I typesString = "StringValue1"
...
sString = "StringValue1"
sString will be equal to "StringValue1" whenever I call it in my script. So there is no need to write it again.
And also, in a script two functions of same name will confuse PtokaX, so here you go:-- Reads files and sends it to main when command typed to main chat
-- by GeceBekcisi
sBotName = frmHub:GetHubBotName()
sBedFile = "ascii/nn.txt"
sRockFile = "ascii/rock.txt"
function ChatArrival(curUser, data)
local data = string.sub(data,1, -2)
local s,e,cmd = string.find(data, "%b<>%s[%!%+%?%#%+](%S+)" )
if cmd == "bed" then
local filedata = "\r\n\r\n"..curUser.sName.." goes to bed and says: Good night all!\r\n"
for line in io.lines(sBedFile) do
filedata = filedata..line.."\r\n"
end
SendToAll(sBotName, filedata)
return 1
end
if cmd == "rock" then
local filedata = "\r\n\r\n"..curUser.sName.." headbangs and hope that the rest of the hub are with him? \r\n"
for line in io.lines(sRockFile) do
filedata = filedata..line.."\r\n"
end
SendToAll(sBotName, filedata)
return 1
end
end
And please use [C0DE] and [/C0DE] (and don't forget to replace C0DE with CODE when posting ;)) to wrap script codes when posting.
Best regards.