Help/Req - Read 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

Help/Req - Read from file

Started by Madman, 08 October, 2004, 18:42:58

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Madman

Hello, i use this code
function NewUserConnected(user)
	if stats[user.sName] then
	local tmp = stats[user.sName]
	if tonumber(tmp[1]) < postcount0 then text0(user)
		elseif tonumber(tmp[1]) < postcount1 then text1(user)
		elseif tonumber(tmp[1]) < postcount2 then text2(user)
		elseif tonumber(tmp[1]) < postcount3 then text3(user)
		elseif tonumber(tmp[1]) < postcount4 then text4(user)
		elseif tonumber(tmp[1]) < postcount5 then text5(user)
		elseif tonumber(tmp[1]) < postcount6 then text6(user)
		elseif tonumber(tmp[1]) < postcount7 then text7(user)
		elseif tonumber(tmp[1]) < postcount8 then text8(user)
		elseif tonumber(tmp[1]) < postcount9 then text9(user)
		end
	end
end

postcount0 = 200 --//0-199 shows nothing (if empty)
function text0(user)
SendToAll("") --//Should be empty
end

postcount1 = 400 --//200-399 shows text1
function text1(user)
SendToAll(Bot, "The tiny "..user.sName.." is here")
end

postcount2 = 600 --//400-599 shows text2
function text2(user)
SendToAll(Bot, "The weak chatter "..user.sName.." is here")
end

postcount3 = 800
function text3(user)
SendToAll(Bot, "The little chatter "..user.sName.." is here")
end

postcount4 = 1000 --//shows 800-999
function text4(user)
SendToAll(Bot, "Does "..user.sName.." ever stoptalking?")
end

postcount5 = 1200
function text5(user)
SendToAll(Bot, "Non stop talking "..user.sName.." is in the building....")
end

postcount6 = 1400
function text6(user)
SendToAll(Bot, "Bigmouth "..user.sName.." crashed in to the hub")
end

postcount7 = 1600
function text7(user)
SendToAll(Bot, ""..user.sName.." sure knows how to chat...")
end

postcount8 = 1800
function text8(user)
SendToAll(Bot, "With license to chat - "..user.sName.." has dropped in to the hub")
end

postcount9 = 2000 --//shows 1800-1999
function text9(user)
SendToAll(Bot, "Oh no! The peace and quit is over! "..user.sName.." has kicked down the door")
end

It checks if user got Xnr of post send textX
What i want to do is to put textX part in to a file called greattings.dat
It is little har to explain
Something like this...

NewUserConnected
if tonumber(tmp[1]) < postcount1 then do greattings.dat
show msg..
end

postcount1 = 200

and the dat file... i guess wold look something like this..
["200"]= ""The weak chatter "..user.sName.." is here""

The entire Script can be found here http://destruction.myftp.org/filer/dc/chatsstatsv2.2.lua

Can anybody do this for me or give me some code sample of how it should be done....
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

Herodes

This is a nice thread to see ...

Especially read the thread for functions to Read a file and use  the serialize function for loading a table ....

furthermore ...  get some script that uses table to define the scripts behaviour from a table . .. and then make yours act like it ... it will save u so much code ...

Madman

Woow... I dont even understand half of what that thread said....
I'm not so good at this....it took me atleast a day to figuer how to do the

postcount9 = 2000 --//shows 1800-1999
function text9(user)
SendToAll(Bot, "Oh no! The peace and quit is over! "..user.sName.." has kicked down the door")
end

thing.....
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

Herodes

Do you really think it took me less than a day to understand how to lua ?

no .. it took lots of time , days and months ..

anyhow .. the best way is to expiriment and keep hoping ...
all the functions that u need are in that thread ... test them ! see what u can do with them ... if you are not understanding smth then have a look in this which really is the key to understanding the lang...

and A-l-w-a-y-s expiriment ! :)

SMF spam blocked by CleanTalk