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 2115 116 117338 339 Nächste Zum Anfang

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
Here.
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
map_objects = 0
function player_flashlight()
	for i=1,32,1 do
		id=image("gfx/sprites/flashlight.png",1,1,200+i)
		if i == 1 then map_objects =  id - 1 end
		imagecolor(id,255,255,255)
		imageblend(id,1)
		imagealpha(id,0.5)
		imagescale(id,1,1)
	end
end

player_flashlight()

addhook("startround","player_flashlight")
     
addhook("serveraction","server_serveraction")
function server_serveraction(id,button)
	if (button==1) then
		imagealpha(map_objects+id,0.0)
		parse([[sv_sound "flashlight.wav"]])
	else
		imagealpha(map_objects+id,0.5)
		parse([[sv_sound "flashlight.wav"]])
	end
end

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
Oh, yeah, I forgot about that because I thought you wanted it like in the function you gave me >.>
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
function array(s,v)
	local t={}
	for i=1,s do t[i]=v end
	return t
end

map_objects = 0
flashlight_is_on = array(32,false)
function player_flashlight()
	for i=1,32,1 do
		id=image("gfx/sprites/flashlight.png",1,1,200+i)
		if i == 1 then map_objects = id - 1 end
		imagecolor(id,255,255,255)
		imageblend(id,1)
		imagealpha(id,0.5)
		imagescale(id,1,1)
		flashlight_is_on[id] = false
	end
end

player_flashlight()

addhook("startround","player_flashlight")

addhook("serveraction","server_serveraction")
function server_serveraction(id,button)
	if (button==1) then
		flashlight_is_on[id] = not flashlight_is_on[id]
		if flashlight_is_on[id] then
			imagealpha(map_objects+id,0.5)
		else
			imagealpha(map_objects+id,0.0)
		end
		parse([[sv_sound "flashlight.wav"]]) 
	end
end
1× editiert, zuletzt 13.12.09 04:55:02

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
You mean, the hook "movetile"?
info.txt hat geschrieben
movetile(id,x,y)                         on moving on a different tile
-id: id of player who reached a new tile
-x: new tile x position (tiles)
-y: new tile y position (tiles)

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
@Starkkz
It's duplicate, you can't use functions or values names of used hooks.
1
2
3
:notok: addhook("[b]move[/b]","[b]move[/b]") 

:ok: addhook("move","move[b]s[/b]")

alt Re: Lua Scripts/Questions/Help

Admir
User Off Offline

Zitieren
What is this?

1
attempt to concatenate a boolean value

I got this error when I test some lua script, and I don't what exactly that problem

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
@Admirdee
Boolean valuable returns only true (1) or false (0)
Probably you are using Boolean as normal valuable, that's problem.

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
Hey guys, maybe I'm high/drunk but does setting an image's position exactly over another one (same x and y) delete the old one?
I've tried something like this:
1
2
3
4
5
addhook("projectile","flackos_projectile")
function flackos_projectile(id,wep,x,y)
	img = image("gfx/paintball/stain"..rsp..".bmp",0,0,0)--Global variable (!)
	imagepos(img,x,y,player(id,"rot"))
end

If I throw two or more snowballs exactly in the same position, the old sprite is deleted, and the new image gets the id of the old one.

alt Re: Lua Scripts/Questions/Help

Starkkz
Moderator Off Offline

Zitieren
i need help with this buildings..

Zitat
T = Turret
W = Wall III
P = Player Coordinates/Position.
G = Gate Field

TwGwT
W___W
G_P_G
W___W
TwGwT


how can i do that. but in command
Spawnobject. ( lua )

alt Re: Lua Scripts/Questions/Help

Vectarrio
User Off Offline

Zitieren
use:
You must set id as player.
1
2
x=player(id,"tilex")
y=player(id,"tiley")
And parse("spawnobject "..x|+- value you want to spawn from player|.." "..y|+- value you want to spawn from player|.." |other stuff, see in cs2d help(server commands) and here|")

alt Re: Lua Scripts/Questions/Help

Vectarrio
User Off Offline

Zitieren
parse("spawnobject 8 "..x-2.." "..y-2.." 0 "..player(id,"team").." "..id)
It will spawn a turret(8) in tile x and y, with mode 0(i dont know whats this). Turret is for team of player, and created by player.
If it is not working, try not tilex, tiley, but just pixel x and y.
To do with pixels, replace this:
1
2
x=player(id,"tilex")
y=player(id,"tiley")

to this:
1
2
x=player(id,"x")
y=player(id,"y")
and make not x-2 or y-2, but x-64 or y-64
Zum Anfang Vorherige 1 2115 116 117338 339 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht