Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Lua Scripts/Questions/Help

6.770 Antworten
Seite
Zum Anfang Vorherige 1 2168 169 170338 339 Nächste Zum Anfang

alt Re: Lua Scripts/Questions/Help

Homer
User Off Offline

Zitieren
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?

alt Re: Lua Scripts/Questions/Help

- Dark Void -
User Off Offline

Zitieren
Homer hat geschrieben
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]*)
1× editiert, zuletzt 26.02.10 00:17:58

alt Re: Lua Scripts/Questions/Help

- Dark Void -
User Off Offline

Zitieren
Homer hat geschrieben
Doesn't work? I tried something else still doesn't work.

try this
Spoiler >

alt Re: Lua Scripts/Questions/Help

- Dark Void -
User Off Offline

Zitieren
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.
2× editiert, zuletzt 26.02.10 02:42:37

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
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"})
1× editiert, zuletzt 26.02.10 12:28:00

alt Re: Lua Scripts/Questions/Help

YellowBanana
BANNED Off Offline

Zitieren
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.

alt Re: Lua Scripts/Questions/Help

dENd
User Off Offline

Zitieren
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

alt Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Zitieren
Kking hat geschrieben
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

alt Re: Lua Scripts/Questions/Help

- Dark Void -
User Off Offline

Zitieren
Kking hat geschrieben
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

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
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!

alt Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Zitieren
Flacko hat geschrieben
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

alt Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Zitieren
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

alt Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Zitieren
Zitat
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

alt Re: Lua Scripts/Questions/Help

Decks
User Off Offline

Zitieren
Decks hat geschrieben
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?!

alt Re: Lua Scripts/Questions/Help

goweiwen
User Off Offline

Zitieren
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
Zum Anfang Vorherige 1 2168 169 170338 339 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht