Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
Forums overviewCS2D overview Scripts overviewLog in to reply

English Lua Scripts/Questions/Help

6,770 replies
Page
To the start Previous 1 2168 169 170338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Homer
User Off Offline

Quote
1
2
3
file = io.open("File.txt","w")
file:write("text")
file:close()
Is this valid to open a text document and write in it text?

old Re: Lua Scripts/Questions/Help

- Dark Void -
User Off Offline

Quote
Homer has written
1
2
3
file = io.open("File.txt","w")
file:write("text")
file:close()
Is this valid to open a text document and write in it text?

yes, that would work but if you are planning on using that a lot use the function in the spoiler
Spoiler >

now to open and then write something in a file write just type
1
writeFile("[i]*filename.extention*[/i], "[i]what to write[/i]", "[i]*mode[/i]*)
edited 1×, last 26.02.10 12:17:58 am

old Re: Lua Scripts/Questions/Help

- Dark Void -
User Off Offline

Quote
Homer has written
Doesn't work? I tried something else still doesn't work.

try this
Spoiler >

old Re: Lua Scripts/Questions/Help

- Dark Void -
User Off Offline

Quote
I do not see the problem... could you give me the script (the part where you called the function) just post it here and then maybe I can help you.
edited 2×, last 26.02.10 02:42:37 am

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
you could remove the mode parameter, writing always uses the "w" mode, unless you want to append.
1
2
3
4
5
6
7
8
9
10
11
fileWrite(path,data)
	local file = io.open(path,"w")
	if type(data) == "table" then
		for i,v in ipairs(data) do file:write(v) end
	else
		file:write(data)
	end
	file:close()
end
fileWrite("my_epic_file.txt","hi")
fileWrite("my_second_file.txt",{"Hi ","I'm ","Writing ","To ","a ","text ","file"})
edited 1×, last 26.02.10 12:28:00 pm

old Re: Lua Scripts/Questions/Help

YellowBanana
BANNED Off Offline

Quote
0ito, i'm not gonna make the full script for you, although it should not be more than 30 lines.
Nevertheless, i will give you some tips.

Try to draw an image directly over the player with the same angle. Hint: Use the image function.


time:
Try to setup a timer ( or use a second hook) and use os.time() function.

old Re: Lua Scripts/Questions/Help

dENd
User Off Offline

Quote
Hi guys...I will need a good scripter for this.Okay i need a script for my map so when a player walks over a bandage or medikit the medikit or bandage disepear and appears in a menu (it opens with F2) and that is plz help...
Contact:MasterWarior2008@hotmail.com

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
Kking has written
Hi guys...I will need a good scripter for this.Okay i need a script for my map so when a player walks over a bandage or medikit the medikit or bandage disepear and appears in a menu (it opens with F2) and that is plz help...
Contact:MasterWarior2008@hotmail.com


I can do this for $50

old Re: Lua Scripts/Questions/Help

- Dark Void -
User Off Offline

Quote
Kking has written
Hi guys...I will need a good scripter for this.Okay i need a script for my map so when a player walks over a bandage or medikit the medikit or bandage disepear and appears in a menu (it opens with F2) and that is plz help...
Contact:MasterWarior2008@hotmail.com

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
addhook("walkover", "wo")
addhook("menu", "_menu")

function wo (i, item)
	if ( item == 64 ) then
		menu(id, "Pickup Item?,  Medkit|(1)")
		return 1
	elseif ( item == 65 ) then
		menu(id, "Pickup Item ?, Bandage|(1)")
		return 1
	else
		return 0
	end
end

function _menu(i, title, b)
	if ( title == "Pickup Item?") then
		if b == 1 then
			parse("equip "..i.." 64")
		end
	elseif ( title == "Pickup Item ?") then
		if b == 1 then
			parse("equip "..i.." 65")
		end
	end
end

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Oh well, I guess we will find another way to earn cash writing scripts :p
But void forgot about making the medikit dissapear. I can add it for just $20, it's a good deal!

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
Flacko has written
Oh well, I guess we will find another way to earn cash writing scripts :p
But void forgot about making the medikit dissapear. I can add it for just $20, it's a good deal!


I bid $15

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
plt=player(0,"table")
function ritem()
	pli=playerweapons(i)
	for i=1,plt and w=1,pli and ii=1,90 do
		if item(ii,"exists") then
	parse("strip "..plt[i].." "..pli[w])
	parse("equip "..plt[i].." "..pli[w])
	end
	break
end
addhook("second","ritem2")
rnum = math.random(2,6)
sec = 0
rsec = math.random(1,rnum)
function ritem2()
	sec = sec + 1
	if sec == 7 then
		sec = 0
	end
	if sec = rsec then
		ritem()
	end
end

I got bored so i made this
I don't think its that good.

I don't even think it might work

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
Quote
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
plt=player(0,"table") [b]-- plt will always be {} as there are no players at Lua init[/b]
function ritem()
	pli=playerweapons(i) -- [b]i is nil[/b]
	for i=1,plt and w=1,pli and ii=1,90 do -- [b]incorect syntax: for pointer, max, step do[/b]
		if item(ii,"exists") then
	parse("strip "..plt[i].." "..pli[w])
	parse("equip "..plt[i].." "..pli[w])
	end [b]-- You're missing an end for the for loop[/b]
	break
end
addhook("second","ritem2")
rnum = math.random(2,6) [b]-- You must seed the random generator first
--[[--
math.randomseed(os.time());math.random()
--]]--[/b]
sec = 0
rsec = math.random(1,rnum)
function ritem2()
	sec = sec + 1
	if sec == 7 then
		sec = 0
	end
	if sec = rsec then
		ritem()
	end
end

old Re: Lua Scripts/Questions/Help

Decks
User Off Offline

Quote
Decks has written
someone clever can help me with my problem?

its very important for me how create lua scrypt for other specmode for spectators or simple player

someone help me?


HALLO?! someone can answer?!

old Re: Lua Scripts/Questions/Help

goweiwen
User Off Offline

Quote
Does the function timer() work properly?
It seems to call the function repeatedly after each time I use it.

e.g.
1
2
3
timer(1000,'print','test')
... after some time
timer(3000,'print','hi')
outputs
1
2
3
4
test
... after some time
test
hi
To the start Previous 1 2168 169 170338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview