Forum

> > CS2D > Scripts > Using variable in concatenating
Forums overviewCS2D overview Scripts overviewLog in to reply

English Using variable in concatenating

4 replies
To the start Previous 1 Next To the start

old Using variable in concatenating

Casper-
User Off Offline

Quote
I .. think I said it alright in title, haha.

Well, what I'm trying to do is just as the title says.
I'm trying to get a player that isn't a bot, get health regeneration

1
2
3
4
5
6
7
8
9
10
playerRegen = 1

addhook("second","healsystem")
function healsystem()
	for id=1,32 do
		if player(id,"bot") == false then
			parse("sethealth "..id.." "..player(id,"health").. + playerRegen)
		end
	end
end

I've tried doing it in other ways; failed.
So I'm asking here if someone can help me with this, since I can't get my head around this.

old Re: Using variable in concatenating

Cure Pikachu
User Off Offline

Quote
It's actually quite easy.
parse("sethealth "..id.." "..player(id,"health").. + playerRegen)
should be
parse("sethealth "..id.." "..player(id,"health") + playerRegen)
.

old Re: Using variable in concatenating

GeoB99
Moderator Off Offline

Quote
Replace the numerical
for
loop with this:
1
for _, id in pairs( player(0, 'tableliving') ) do
Your numerical loop iterated over 32 players to gather their ID however since, assuming you were the only player online, it would have iterated over to you, the rest of the iteration resulting in
false
hence boolean.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview