Forum

> > CS2D > Scripts > Where is my mistake? (lua)
Forums overviewCS2D overview Scripts overviewLog in to reply

English Where is my mistake? (lua)

5 replies
To the start Previous 1 Next To the start

old Where is my mistake? (lua)

limonata
User Off Offline

Quote
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

old Re: Where is my mistake? (lua)

Kirby7
User Off Offline

Quote
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.
edited 1×, last 06.06.13 09:31:50 pm

old Re: Where is my mistake? (lua)

limonata
User Off Offline

Quote
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.
edited 1×, last 06.06.13 11:25:03 pm

old Re: Where is my mistake? (lua)

tonton2d
User Off Offline

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

old Re: Where is my mistake? (lua)

Conscience
User Off Offline

Quote
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
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview