an easy one
 

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

an easy one

Started by Pieltre, 21 January, 2004, 03:55:54

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Pieltre

Hi,

I got this script that pretty simple:

botname = "Bot"

function Main()
frmHub:RegBot(botname)
end

function DataArrival(user,data)
if strfind(data, "+rules",1,1) then
   readfrom("rules.txt")
   while 1 do
      line = read()
      if line == nil then break end
      user:SendPM(botname,line)
      end
   readfrom()
   end
end


But I want to make it so when the command it performed by OPs, a files called, say, rules_Y.txt is displayed in a PM  and when regs or VIP perform the same command, a file called rules_X.txt is displayed.

thanks in advance,
pieltre

Pieltre

Hi again,

I forgot to mention, ideally I'd like the bot to pick the txt files from a 'text' folder in the script folder...

thanks again,
pieltre

pHaTTy

well hers a little example

Kos = "[RuLeR]"

Command = "+rules"

MasRules = "text/masrules.txt"
OpRules = "text/oprules.txt"
VipRules = "text/viprules.txt"
RegRules = "text/regrules.txt"

function Main() 
	frmHub:RegBot(Kos) 
end 

function DataArrival(ustring,dstring) 
	if strsub(dstring, 1, 1) == "<" then
		dstring=strsub(dstring,1,strlen(dstring)-1)
		local s,e,cmd = strfind(dstring,"%b<>%s+(%S+)")
	
		if cmd == Command then
			if ustring.iProfile == 0 then
				file = MasRules
				WhileRead(ustring,file)
			elseif ustring.bOperator then
				file = OpRules
				WhileRead(ustring,file)
			elseif ustring.iProfile == 2 then
				file = VipRules
				WhileRead(ustring,file)
			else
				file = RegRules
				WhileRead(ustring,file)
			end
		end 
	end
end

function WhileRead(ustring,file)
	readfrom(file)
	while 1 do 
		line = read() 
		if line == nil then
			break
		end 
		ustring:SendPM(Kos,line) 
	end
 	readfrom()
end

gives u a start (depending on ur profiles.dat)

cant remember the idx thingy not used in long time
Resistance is futile!

Pieltre

works fine. thanks.

????L?F??

damn I even i know the answer to that question ^^

I wanted to help, but oh wel i'll let phatty off this time ^^
Whos ya daddy  :]

pHaTTy

QuoteOriginally posted by ????L?F????
 oh wel i'll let phatty off this time ^^

?? pmsl
Resistance is futile!

????L?F??

lol, just messing man
Whos ya daddy  :]

SMF spam blocked by CleanTalk