Forum

> > CS2D > Scripts > Where is my mistake? (lua)
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Where is my mistake? (lua)

5 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Where is my mistake? (lua)

limonata
User Off Offline

Zitieren
Hello, may you tell me where is my mistake in this script?

1
2
3
4
5
6
7
8
9
10
addhook("startround","s")
function s(id)
	if player(id,"score") > 2 then
		if player(id,"health") > 0 then
		parse("equip "..id.. "47")
	else
		msg2(id,"You will get your RPG next round!")
		end
	end
end

alt Re: Where is my mistake? (lua)

Kirby7
User Off Offline

Zitieren
You also forgot an 'end' ( after line 5 ) for the 'if' in line 4 and you don't need the 'end' in line 8.

Fixed code :
Spoiler >


Also i would recommend using the spawnhook to equip weapons at the round start ( see spawn ). Just personal preference though.
1× editiert, zuletzt 06.06.13 21:31:50

alt Re: Where is my mistake? (lua)

limonata
User Off Offline

Zitieren
Thank you Kirby i was trying to select right hook. It was spawn i will use it okay
--------------------------

Edit: No error but doesnt working.

1
2
3
4
5
6
7
8
addhook("spawn","give_stf")
function give_stf(id)
     if player(id,"score") > 2 and player(id,"health") > 0  then
                parse("equip "..id.. " 47")
     elseif  player(id,"score") > 2 and player(id,"health") < 0  then
          msg2(id,"You will get your RPG next round!")
		end
end

When player reach the 2 score he will get rpg next spawn. For example in the game i killed three player then i died. I will get rpg next spawn.
1× editiert, zuletzt 06.06.13 23:25:03

alt Re: Where is my mistake? (lua)

tonton2d
User Off Offline

Zitieren
1
2
3
4
5
6
7
8
9
10
11
12
addhook("spawn","give_stf")
function give_stf(id)

for id=1,32 do
     if player(id,"score") > 2 and player(id,"health") > 0  then
                parse("equip "..id.. " 47")
     elseif  player(id,"score") > 2 and player(id,"health") < 0  then
          msg2(id,"You will get your RPG next round!")
          end
      end

end
give a value to id.

alt Re: Where is my mistake? (lua)

Conscience
User Off Offline

Zitieren
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
round = 1
maxround = 3

addhook("spawn","_spawn")
addhook("endround","_endround")

function _spawn(id)
	if round == 1 then -- Checks if it is round 1 (RPG Launcher round)
		return 47
	elseif round == 2 then -- Your next round, for example laser round
		return 45
	end
end

function _endround(mode)
	round = round + 1
	if round == maxround then -- This will loop the rounds, making the rounds never stop
		round = 1
	end
end
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht