display txt from file
 

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

display txt from file

Started by Madman, 28 September, 2004, 22:51:21

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Madman

I'm makeing a "FunScript"
And i want a function that reads some SendToAll lines from a txt

Ex..
If !insult Madman then
do insult.txt
SendToAll(Bot, Random text in insult.txt)

Ex.. of a line to send ;)
SendToAll("*** "..curUser.sName.." thinks that  "..vUser.sName.." smells like a 120 year old dead body ")
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

EXNET OWNER

...
#1
couldnt you do a random table like

RandomTable = {
["you stink"]=1,
["f**k you"]=2,
}

then say where it says random do 1-5 for example, easier than reading from a .txt file???

just an idea, i am tired so i dont know if i am making any sense

BottledHate

QuoteOriginally posted by madman
I'm makeing a "FunScript"
And i want a function that reads some SendToAll lines from a txt

Ex..
If !insult Madman then
do insult.txt
SendToAll(Bot, Random text in insult.txt)

Ex.. of a line to send ;)
SendToAll("*** "..curUser.sName.." thinks that  "..vUser.sName.." smells like a 120 year old dead body ")

have a look at StabBot (hubs scripts)... it can easily be an insult bot..
 all you have to do is add your replies to the file.. and
 chage the user defined commands. it reads the replies
from a file on load, and displays them at random when
triggered. so other silly stuff in there too... ;)


-BH
Homepage: www.bottledhate.webhop.org

Compiling  Lua scripts is LAME!!!!!

Madman

#3
Thanks BH =)

Can anybody help me with this?

I took this code to use with my insult function
function DataArrival(curUser, data)
	if strsub(data, 1, 1) == "<" then
		local _,_,cmd=strfind(data, "%b<>%s+(%S+).+")
		local IUser = curUser.sName
		local _,_,junk=strfind(data, "%b<>%s+%S+%s+(.+)|")
		local requestString = ""
			if cmd == "!insult" then
				local answer,victim = Stabs[random(getn(Stabs))], junk
				answer = gsub( answer, "(%[CURUSER%])", IUser )
				answer = gsub( answer, "(%[VIC%])", victim ) 
					SendToAll( answer.."|" )
			end
	end
end

Now.. Since it allready is a DataArival in the script
And i placed the code in it...
I though i could do this
--function DataArrival(curUser, data)
--	if strsub(data, 1, 1) == "<" then
		local _,_,cmd=strfind(data, "%b<>%s+(%S+).+")
		local IUser = curUser.sName
		local _,_,junk=strfind(data, "%b<>%s+%S+%s+(.+)|")
		local requestString = ""
			if cmd == "!insult" then
				local answer,victim = Stabs[random(getn(Stabs))], junk
				answer = gsub( answer, "(%[CURUSER%])", IUser )
				answer = gsub( answer, "(%[VIC%])", victim ) 
					SendToAll( answer.."|" )
			end
--	end
--end

And would still work...
but instead i get this..

Syntax error: bad argument #3 to `gsub' (string or function expected)
stack traceback:
   1:  function `gsub' [C]
   2:  function `DataArrival' at line 114 [file `...ram\Hub\PtokaX-0.330 madhouse\scripts\Funv3.lua']

Why?

Btw this is line 114
answer = gsub( answer, "(%[VIC%])", victim )
And what can i do to be able to remove The Second DataArival? (2nd is in that code)
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

BottledHate

the prob is in here:
local answer,victim = Stabs[random(getn(Stabs))], junk

what is your table with the answers called?? is it Stabs? ....
also have a look at the answers file in stabot for a look at the  format to set up your table.

post you data arrival as it is now, and i'll tell you how to remove that extra junk...

hope that helps.....


-BH
Homepage: www.bottledhate.webhop.org

Compiling  Lua scripts is LAME!!!!!

Madman

#5
My Script looks like this now...
The test version that is.. got many more cmds in the orginal....And Aslo got the OutThrow function for the throw command ;p


--//Fun Script Made By Madman
--//Thanks NightLitch for the help with the victim function
--//Sendto Stuff stolen from zRightClicker ;p
--//Version 2
--//Random Function Added... Do You Feel Lucky? ;p
--//Random Re written, Now Works Correct..
--//-=NewCommand=- Added Beacuse It Is So Many Commands
--//"Rewrote" --==NewCommand==-- ;p Now Script More Sorted
--//--==NewVictimCommand==-- Added
--//--==NewFunctionCommand==-- Added
--//Version 3
--//Stab Commandd Added Thankx BottledHate
--//Stab Text Readed From FunScript.txt

--//Add Ver 2 cmd later!


Bot = "FunScript"
dofile("FunScript.txt")

--// This function is fired at the serving start
function Main()
frmHub:RegBot(Bot)
end

--//User To send Text 2 (Victim function)
-- 1=on / 0=off
SendTo = {
[0] = 0,   -- Masters
[1] = 1,   -- Operators
[2] = 1,   -- Vips
[3] = 1,   -- Regs
[4] = 0,   -- Moderator
[5] = 0,   -- NetFounder
[-1] = 1,  -- Users
}

--// This function is fired when a new data arrives
function DataArrival(curUser,data)
	if strsub(data, 1, 1) == "<" then
	data=strsub(data,1,strlen(data)-1)
	s,e,cmd = strfind(data,"%b<>%s+(%S+)")
	--==NewVictimCommand==--
	--//Victim funtion
		--//Call command
		if cmd == "!throw" then
		--//Parse the data string to catch the "victim" nick
		local s,e,victim = strfind(data,"%b<>%s+%S+%s+(%S+)")
			--//if no victim nick entered then return syntax message
			if victim == nil then
				curUser:SendData(Bot, "Syntax: !throw nick")
				return 1
			end
				--//Check if nick/user is online
				vUser = GetItemByName(victim)
				if not vUser then
					curUser:SendData(Bot, " *** " ..victim.." is not online or wrong name...")
					return 1
				end
					--//Check if you is victim
					if curUser.sName == vUser.sName then
						curUser:SendData(Bot, "Why throw your self?")
						return 1
					end
					--//Safe Function 4 Ops
						if vUser.bOperator then
							--//Send sendData To Users in Send To List (in the begining....)
							if (SendTo[curUser.iProfile]==1) then
								curUser:SendData(Bot, "You Are Not Allowd To Throw Ops!")
						--//But if master or higher, throw user and skip above text... Mohaha! Evil!
							elseif (curUser.iProfile == 0) and (vUser.bOperator) then
							--//Do the "Throw" code here...
							--//Random function							
							OPThrow = random (2)
								--//Throw victim
								if OPThrow == 1 then
									SendToAll(Bot, vUser.sName.." has been thrown out of the hub by "..curUser.sName)
									vUser:SendData(Bot, "You have been thrown out of the hub by "..curUser.sName.."!")
									vUser:Disconnect()
								elseif OPThrow == 2 then OutThrow(curUser)
								--//Ops... Throwed your self (Unless OutThrow)
--									SendToAll(Bot, curUser.sName.." got unlucky and throwed him/herself out "..curUser.sName)
--									curUser:SendData(Bot, "Whoops.. You throwed your self out"..curUser.sName.."!")
--									curUser:Disconnect()						
								end
							--//End of random fuction
						end
					--//End of Safe function
				else
				--//Do the "Throw" code here...
				UserThrow = random (2)
					--//Throw victim
					if UserThrow == 1 then
						SendToAll(Bot, vUser.sName.." has been thrown out of the hub by "..curUser.sName)
						vUser:SendData(Bot, "You have been thrown out of the hub by "..curUser.sName.."!")
						vUser:Disconnect()
					elseif UserThrow == 2 then OutThrow(curUser)
						--//Ops... Throwed your self (Unless OutThrow)
--						SendToAll(Bot, curUser.sName.." got unlucky and throwed him/herself out "..curUser.sName)
--						curUser:SendData(Bot, "Whoops.. You throwed your self out"..curUser.sName.."!")
--						curUser:Disconnect()		
					end
				end
			end
	--//End of vicim function
		--==NewVictimCommand==--
--//Stab function
function DataArrival(curUser, data)
	if strsub(data, 1, 1) == "<" then
		local _,_,cmd=strfind(data, "%b<>%s+(%S+).+")
		local User = curUser.sName
		local _,_,junk=strfind(data, "%b<>%s+%S+%s+(.+)|")
		local requestString = ""
			if cmd == "!stab" then
				local answer,victim = Stabs[random(getn(Stabs))], junk
				answer = gsub( answer, "(%[CURUSER%])", User )
				answer = gsub( answer, "(%[VIC%])", victim ) 
					SendToAll( answer.."|" )
			end
	end
end
		--//End Of Stab function
	end
end

Ripped from funscript.txt...
--// 3 values can be plugged into the answer as many time..[CURUSER] = invoking user, [VIC] = target
Stabs = {
"*** [CURUSER] gets behind the wheel of a Volvo and back up over [VIC]'s dog. ***" ,
"*** [CURUSER] beats the shit out of [VIC]!*** " , 
}--//this is the end of the answers...
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

Madman

Does any one have a soulation to my problem? :/
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

nErBoS

Hi,

You have 2 DataArrival, you can't have 2, you have to join both DataArrival in one.

Best regards, nErBoS
--## nErBoS Spot ##--

Madman

Okey... but i dont know how to do that....
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

Madman

#9
unfortnaly neither do i... my pc got f*cked up and refuses to install Xp... have to wait untill my freind come ger tomorrow and help me....Lucky i got more then one pc.. so i can surf and chat on dc =)


*edit*

I dont have ptokax now.. but just create a txt called funscript and insert to it...

--// 3 values can be plugged into the answer as many time..[CURUSER] = invoking user, [VIC] = target
Stabs = {
"*** [CURUSER] gets behind the wheel of a Volvo and back up over [VIC]'s dog. ***" ,
"*** [CURUSER] beats the shit out of [VIC]!*** " ,
}--//this is the end of the answers...

thats all it is in it.. just more stab text...
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

Madman

Okey.. Got my pc working...kind of...
anyway... That did not help mutor..
The problem semmes to be without that 2nd Data arival it cant find the victim
Becuse
answer = gsub( answer, "(%[VIC%])", victim )
dont work, but
answer = gsub( answer, "(%[VIC%])", User )--victim )
this does
but then i stab my self..so my guess is that we need something to tell the script who the victim is without using the DataArival...
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

nErBoS

Hi,

Let's us take by parts...

1) With User you will get stab your self because of this...

local User = curUser.sName

2) So it leaves us it the var victim that is catch in here...

local _,_,junk=strfind(data, "%b<>%s+%S+%s+(.+)|")

and used here...

local answer,victim = Stabs[random(getn(Stabs))], junk

Now i belive that isn't working because of the catch, you can catch a phrase and not a nick so i would recomend you to use this...

local _,_,junk=strfind(data, "%b<>%s+%S+%s+(%S+)")

instead of this...

local _,_,junk=strfind(data, "%b<>%s+%S+%s+(.+)|")

For futher understanding of my change check out in the LUA Manual or plop's magical char how to topic, to see how magical chars work.

Best regards, nErBoS
--## nErBoS Spot ##--

Madman

#12
QuoteOriginally posted by nErBoS
For futher understanding of my change check out in the LUA Manual or plop's magical char how to topic, to see how magical chars work.

Thanks, That solved the problem...

And plop's magical char how to.... i cant find it... could u give me a link?
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

nErBoS

Hi,

Check it HERE

Best regards, nErBoS
--## nErBoS Spot ##--

SMF spam blocked by CleanTalk