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 2141 142 143338 339 Nächste Zum Anfang

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
You can use table.insert to add a value into a table with a new index or you can use t[n] = v
Where t is your table, n is your index or key and v is your value.

alt Re: Lua Scripts/Questions/Help

Zanahoria
User Off Offline

Zitieren
Help me!
I want to select the five-seven laser is created.
Everything was fine with Usp (1) but the change (6) no longer works. What do I wrong?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
laser=initArray(32)
laser01=initArray(32)

addhook("select","laserz")
function laserz(id,type,mode)
	if type == 6 then
		if (laser01[type] == 6) then
			laser01[type]=0
			freeimage(laser[type])
		else 
			laser01[type]=6
			laser[type]=image("gfx/!Huevitorojo Sprites/laser.png",1,1,200+type)
			imageblend(laser[type],1)
			imagecolor(laser[type],255,0,0)
			imagealpha(laser[type],0.7)
		end
		return 1
	end
end

alt Re: Lua Scripts/Questions/Help

wups
User Off Offline

Zitieren
Zanahoria hat geschrieben
Help me!
I want to select the five-seven laser is created.
Everything was fine with Usp (1) but the change (6) no longer works. What do I wrong?


Why do you use [type] instead of id?
If you add players it will always give the player with id "type" the laser.

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
function initArray(m)
	local array = {}
	for i = 1, m 
	do array[i]=0
	end
		return array
end 

laser=initArray(32)
laser01=initArray(32)

addhook("select","laserz")
function laserz(id,t,mode)
     if t == 1 then
          if (laser01[id] == 1) then
               laser01[id]=0
               freeimage(laser[id])
          else
               laser01[id]=1
               laser[id]=image("gfx/!Huevitorojo Sprites/laser.png",1,1,200+id)
               imageblend(laser[id],1)
               imagecolor(laser[id],255,0,0)
               imagealpha(laser[id],0.7)
          end
    else 
	-- If not selected the right weapon, Remove the laser.
		laser01[id]=0
		freeimage(laser[id])
     end
end

Something is wrong with the tabs, i don't know why.
Looks good in notepad++...
1× editiert, zuletzt 21.01.10 02:20:09

alt Re: Lua Scripts/Questions/Help

Zanahoria
User Off Offline

Zitieren
THX MEN! U R THE BEST!
1)if I do it with another weapon, I do another?
2) i want make this with F3 and not F2
Spoiler >

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
1
2
3
4
5
6
7
8
t = {12,"hi"}
print(t[3])
-->Output: Nil

t = {12,"hi"}
table.insert(t,"hello")
print(t[3])
-->Output: hello

alt Re: Lua Scripts/Questions/Help

wups
User Off Offline

Zitieren
How do i script this thing the best way too make more of them? And i'm really newbie with arrays, and how i should create it too work best without lag and things.

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
x = 0
addhook("say","discot")
function discot(p,t)

	if t == "disco" then

		test = image("gfx/sprites/flare1.bmp", player(p,"x"), player(p,"y"),1)
		testx = player(p,"x")
		testy = player(p,"y")
		imageblend(test,1)
		imagescale(test,2,2)
	end
end

addhook("ms100","sec")
function sec()
	if test ~= nil then
		x = x + 30
		rand = math.random(1,3)
		if x < 360 then
			imagepos(test,testx,testy,x)
			imagecolor(test,x+80,x*2,x-100)
			imagescale(test,rand,rand)
		else
			x = 0
			imagepos(test,testx,testy,x)
		end
	end
end

alt Some one help me

TicTac
BANNED Off Offline

Zitieren
Help me .. it shows me a error how fix this?


I just want make reload script sounds but dont know how fix it
1
2
3
4
5
6
7
8
9
10
11
12
--hooks
addhook("reload","op4_rw")

--funcs

function op4_rw(id,mode)
	if (mode==1) then
		if (player(id,"weapontype")==30) then
			parse("sv_sound2 "..id.." \"lolwtf/ak47rld.wav\"")
		elseif (player(id,"weapontype")==32) then
			parse("sv_sound2 "..id.." \"lolwtf/m4a1rld.wav\"")
			end

alt Re: Lua Scripts/Questions/Help

Starkkz
Moderator Off Offline

Zitieren
TicTac hat geschrieben
Help me .. it shows me a error how fix this?


I just want make reload script sounds but dont know how fix it
1
2
3
4
5
6
7
8
9
10
11
12
--hooks
addhook("reload","op4_rw")

--funcs

function op4_rw(id,mode)
	if (mode==1) then
		if (player(id,"weapontype")==30) then
			parse("sv_sound2 "..id.." \"lolwtf/ak47rld.wav\"")
		elseif (player(id,"weapontype")==32) then
			parse("sv_sound2 "..id.." \"lolwtf/m4a1rld.wav\"")
			end


1
2
3
4
5
6
7
8
9
addhook("reload","op4_rw")
function op4_rw(id,m)
wpn = player(id,"weapontype")
	if (wpn==30) then
		parse("sv_sound2 "..id.." \"lolwtf/ak47rld.wav\"")
	elseif (wpn==32) then
		parse("sv_sound2 "..id.." \"lolwtf/m4a1rld.wav\"")
	end
end

alt Re: Lua Scripts/Questions/Help

Zanahoria
User Off Offline

Zitieren
I want change the server action 1(F2) by serveraction 2(F3]
What i need to change?
Spoiler >

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
Change
1
if p == 1 then
With this
1
if p == 2 then

You should use right function parameters... You switched them.
Zitat
serveraction(id,action)     

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
I already said the problem, everything works if it's fixed.

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
function initArray(m)
	local array = {}
	for i = 1, m do
		array[i]=0
	end
	return array
end

light01=initArray(32)
light=initArray(32)

addhook("serveraction","menuss")
function menuss(id,button)
	if button == 2 then
		if (light01[id] == 1) then
			light01[id]=0
			freeimage(light[id])
		else
			light01[id]=1
			light[id]=image("gfx/!Huevitorojo Sprites/linterna.png",1,1,200+id)
			imageblend(light[id],1)
			imagecolor(light[id],200,200,100)
			imagealpha(light[id],0.7)
		end
	end
end

alt Re: Lua Scripts/Questions/Help

Redefinder
User Off Offline

Zitieren
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
-- Explosive --
        if (sample.zombie.class[id]==6) then
                if (player(id,"team")==1) then
                        parse ("setmaxhealth "..id.." 120")
                        parse ("speedmod "..id.." -4")
                        parse ("equip "..id.." 51")
                        msg2(id,"©255000000Class:Explosive")
	                sample.zombie.teleports[id]=0    
                end
        end
	function explosion(x, y, size, damage)
     	parse("explosion "..x.." "..y.." "..size.." "..damage)
	end
	addhook("die","explode")
	function explode(id,x,y)
		if (sample.zombie.class[id]==6) then
		explosion(x,y,300, 300)
		end
	end
This is supposed to make an explosion on the place where the player is killed,but instead it makes an explosion on a specific place of the map.

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
Blazzingxx hat geschrieben
You should use right function parameters... You switched them

Again, you switched player ID and button parameters.

So in your script button was player id.
And player ID was button.

alt Re: Lua Scripts/Questions/Help

Redefinder
User Off Offline

Zitieren
redefinder hat geschrieben
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
-- Explosive --
if (sample.zombie.class[id]==6) then
if (player(id,"team")==1) then
parse ("setmaxhealth "..id.." 120")
parse ("speedmod "..id.." -4")
parse ("equip "..id.." 51")
msg2(id,"©255000000Class:Explosive")
      sample.zombie.teleports[id]=0
end
end
     function explosion(x, y, size, damage)
     parse("explosion "..x.." "..y.." "..size.." "..damage)
     end
     addhook("die","explode")
     function explode(id,x,y)
          if (sample.zombie.class[id]==6) then
          explosion(x,y,300, 300)
          end
     end
This is supposed to make an explosion on the place where the player is killed,but instead it makes an explosion on a specific place of the map.

someone help me plz
Zum Anfang Vorherige 1 2141 142 143338 339 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht