PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: [NL]ZeroX on 17 March, 2004, 13:58:11

Title: Send Rules from rules.txt
Post by: [NL]ZeroX on 17 March, 2004, 13:58:11
i just want to send the rules from rules.txt whitout getting every line a new line from the txt file

rules.txt: (with the "enters")
rule 1
rule 2
rule 3
rules!!!

than we get the lua code:
if cmd == "!rules" or cmd == "+rules"  then
SendRules(user)
return 1

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

function SendRules(user)
readfrom("txt/rules.txt")
while 1 do
line = read()
if line == nil then
break
end
user:SendData(Bot,line)
end
readfrom()
end

i get as result:
[13:56] <-=[ToXiC?]=-> rule 1
[13:56] <-=[ToXiC?]=-> rule 2
[13:56] <-=[ToXiC?]=-> rule 3
[13:56] <-=[ToXiC?]=-> rules!!!

but i want the results like:
[13:56] <-=[ToXiC?]=->
rule 1
rule 2
rule 3
rules!!!

can some1 help me fixt it??


sorry for my crappy engish ;-)

//ZeroX
Title:
Post by: plop on 17 March, 2004, 15:28:24
here are some hints, you try 2 place them on the right place.
local text = "\r\n" --- declare text which is gone hold the full file (starting with a line feed)

text = line.."\r\n" -- insert the line into text ending with a line feed

user:SendData(Bot,text.."|") -- sending the full text
as you see every line has it's comments so it should be easy 2 find there place.

plop
Title:
Post by: [NL]ZeroX on 17 March, 2004, 18:47:39
i dont get it now i'm getting after every rule a break

[18:44] <-=[ToXiC?]=-> rule 1

[18:44] <-=[ToXiC?]=-> rule 2

[18:44] <-=[ToXiC?]=-> rule 3

[18:44] <-=[ToXiC?]=-> rules!!!

(i had it a few hours ago when i was try-ing a lot of things)

my code currentyl says:
function SendRules(user)
readfrom("txt/rules.txt")
while 1 do
line = read()
local text = "\r\n"
if line == nil then
break
end
text = line.."\r\n"
user:SendData(Bot,text.."|")
end
readfrom()
end

hope some1 can help me out

ZeroX
Title:
Post by: ??????Hawk?????? on 17 March, 2004, 19:08:21
try this m8 :-   ( untested )




function SendRules(user)
readfrom("txt/rules.txt")
local text = "\r\n"
while 1 do
line = read()
if line == nil then
break
end
text = text.."\r\n"..line
end
user:SendData(Bot,text.."|")
readfrom()
end


Title:
Post by: [NL]ZeroX on 17 March, 2004, 20:15:34
yup thnx m8 its WORKING  8)  :D  :))  :]
Title:
Post by: ??????Hawk?????? on 17 March, 2004, 20:36:18
:))
Title:
Post by: plop on 17 March, 2004, 23:05:35
damn my hints had a bug. lol
but thx for fixing it hawk.

plop
Title:
Post by: ??????Hawk?????? on 17 March, 2004, 23:17:32
he he he

plop

i learned it all from you and the other great scripters in here m8

unfortunately its taken me 4 months to learn enough to be of some use here, however little it is