Forum

> > CS2D > Scripts > attemp to compare number with boelan
Forums overviewCS2D overview Scripts overviewLog in to reply

English attemp to compare number with boelan

3 replies
To the start Previous 1 Next To the start

old Re: attemp to compare number with boelan

Lee
Moderator Off Offline

Quote
1
2
3
4
5
for _,id in player(0, "table") do
	if player(id, "health") > 0 then
		...
	end
end

or more idiomatically

1
2
3
for _,id in player(0, "tableliving") do
	...
end

old Re: attemp to compare number with boelan

Apache uwu
User Off Offline

Quote
Oh I see it, not all 32 players exist, therefor when you try to get the health of a non-existent player it returns false.

When you compare false with greater than 0 the game Lua returns an error.

Here I fixed it.

1
2
3
4
5
function hhminute()
	for _,id in ipairs(player(0,"tableliving")) do
	--xxx
	end
end

Remember to put your code in the code tags as well as tabbing.

EDIT: Sorry !! I was typing this out before you posted -.-''
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview