Forum
CS2D Scripts Lua Scripts/Questions/HelpHow I can let read a special line (like the 4. line) in a .txt file?
pls help
Snake_Eater has written
Hi guys
How I can let read a special line (like the 4. line) in a .txt file?
pls help
How I can let read a special line (like the 4. line) in a .txt file?
pls help
use the split function
Heres an simple reading function with split
thanks to flacko for the split and thanks to me for the code lool!!!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function string.split(text,delimiter) local buff = {} delimiter = delimiter or "%s" delimiter = "[^"..delimiter.."]+" for w in string.gmatch(text,delimiter) do table.insert(buff,w) end return buff end addhook("spawn","readfunc") function readfunc(id) 	for l in io.lines("sys/lua/whatever.txt") 		l = l:split() 		local whatever = tonumber(l[4]) -- line 4 	end end
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
parse("mp_wpndmg deagle 0") function initArray(m) 	local array = {} 	for i = 1, m do 		array[i]=0 	end 	return array end lives=initArray(32) function lives_hud(id) 	parse('hudtxt2 '..id..' 1 "©000100255Lives: '..lives[id]..' " 13 117') end addhook("spawn","lives_spawn") function lives_spwan(id) 	lives[id]=5 	lives_hud(id) 	parse("equip "..id.." 3")	 end addhook("hit","lives_hit") function lives_hit(id) 	if lives[id] == 1 then 		return 0 	else 		lives[id]=lives[id]-1 	end end addhook("buy","lives_buy") function lives_buy() 	return 1 end addhook("walkover","lives_walkover") function lives_walkover(id) 	return 1 end addhook("drop","lives_drop") function lives_drop() 	return 1 end addhook("die","lives_die") function lives_die() 	return 1 end
EDIT: Fixed
edited 1×, last 26.09.10 02:05:41 pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function string.split(text,delimiter) local buff = {} delimiter = delimiter or "%s" delimiter = "[^"..delimiter.."]+" for w in string.gmatch(text,delimiter) do table.insert(buff,w) end return buff end addhook("say","readfunc") function readfunc(id) for l in io.lines("sys/lua/whatever.txt") do l = l:split() local whatever = tonumber(l[4]) -- line 4 end end
If somebody say somrthing the 4. line will show up in msg how to make?
1
2
2
--addhook("usebutton","gunbuy") --function gunbuy(id,x,y)
(EDIT 1st time>>)i know how tile id's work (x,y tiles i mean) .. i knewed how to do this before ... (EDIT 2nd time >>)and how i can do so there shall be only four players in one team ?
edited 2×, last 26.09.10 03:05:38 pm
First, a script for save money, license, add-ons in my RolePlay server, in USGN ...
After, just a little script, when ->CT<- say : !car a car picture appear in him. My car is called : car_04 ...
I hope you help me ...
Tanks you very much !
cts can spawn cars and stuff, But i want ct in return
1
2
3
2
3
addhook("second","healsystem") function healsystem() parse("sethealth "..id.." +10")
i wanted to get when i got hurt i get refill health points by 10
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
addhook("second","healsystem") function healsystem() for id=1,32 do if player(id,"exists") then parse("sethealth "..id.." "..player(id,"health")+10) end end end
try this
BureX has written
i want to make something like cod5 nazi zombies gun buying on wall and i stopped right here ... *facepalm* stupid me...
(EDIT 1st time>>)i know how tile id's work (x,y tiles i mean) .. i knewed how to do this before ... (EDIT 2nd time >>)and how i can do so there shall be only four players in one team ?
1
2
2
--addhook("usebutton","gunbuy") --function gunbuy(id,x,y)
(EDIT 1st time>>)i know how tile id's work (x,y tiles i mean) .. i knewed how to do this before ... (EDIT 2nd time >>)and how i can do so there shall be only four players in one team ?
1
2
3
4
5
2
3
4
5
addhook("usebutton","gunbuy") function gunbuy(id,event,data,x,y) 	if x==x and y==y then 		-- 	end end
And i have my RP lua, i just want the save !
What is your pseudo in game ?
...
1
2
3
4
2
3
4
if (title == "Hell door") then 		if (key == 1) then 		end 	end
BureX has written
how do i do so this doors can be opened if player has money (like buying a ticket or smthing...)
1
2
3
4
2
3
4
if (title == "Hell door") then 		if (key == 1) then 		end 	end
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
if (title == "Hell door") then 		if (key == 1) then 			local money = player(id,"money") 			if money>3999 then -- if player has 4000 or more then 				-- What ever 			end 		end 	end end
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
if (title == "Hell door") then 		if (key == 1) then 			local money = player(id,"money") 			if money>3999 then 			-- over here i want to lose money 			end 		end 	end end
i tried like this
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
if (title == "Hell door") then 		if (key == 1) then 			local money = player(id,"money") 			if money>999 then 			parse("setmoney "..id.." -1000") 			end 		end 	end end
BureX has written but i want to lose money
i tried like this
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
if (title == "Hell door") then 		if (key == 1) then 			local money = player(id,"money") 			if money>3999 then 			-- over here i want to lose money 			end 		end 	end end
i tried like this
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
if (title == "Hell door") then 		if (key == 1) then 			local money = player(id,"money") 			if money>999 then 			parse("setmoney "..id.." -1000") 			end 		end 	end end
change
1
2
3
2
3
parse("setmoney "..id.." -1000") to parse("setmoney "..id.." "..(player(id,"money") - 1000))