Forum

> > CS2D > Scripts > Count players and if?
Forums overviewCS2D overview Scripts overviewLog in to reply

English Count players and if?

31 replies
Page
To the start Previous 1 2 Next To the start

old Re: Count players and if?

Masea
Super User Off Offline

Quote
Sir, your condition is going to be everytime true since there's no way someone dies on an empty server. So that would change nothing across the current code if we had added it. I'm quite sure that you tried to tell the issue wrongly.

user script favor has written
tested worked
1
2
3
4
5
6
7
8
9
10
11
function zp_die(p)
local t = player(p,'team')
for i = 1,1 do
if t == 2 then
parse('maket '..p)
     end
end
     zp_hudtxt2(p,2,1,'',0,0,0)
     zp_hudtxt2(p,4,1,'',0,0,0)
     return 1
end

Goodluck.
First learn Lua and then maybe you can say "Good luck" to others.

old Re: Count players and if?

Yates
Reviewer Off Offline

Quote
user script favor has written
I send him the script on pm and stop flame , fucking kiddy.

I would be delighted to know what code you cooked up judging your previous attempts.

Please enlighten us all oh glorious adult.

old important Re: Count players and if?

DC
Admin Off Offline

Quote
@user script favor: What other people here are trying to say is that you shouldn't try to help others if you're not sure what you're doing.

It's nice that you're trying to help but your attempts are misleading and no proper solution. This way you're only confusing others. So what you're actually doing is not helping but confusing people with wrong and weird "solutions". Which is a bad thing. In this case it would be better to not contribute at all - or to at least try to describe your attempt so people understand your thoughts and can help.

Moreover sending thread related content via PM is a very bad practice because you hide information from public this way. This renders the forum entirely useless and therefore it should never be done. The point is to share knowledge, not to hide it by using PMs.

old Re: Count players and if?

Talented Doge
User Off Offline

Quote
Everyone here thinks of using the for loop to count players, which is in fact in effective. The savior of this is to use the next function. The solution is as follows:

1
2
3
4
5
6
7
8
function zp_die(p)
	if player(p, "team") == 2 and next(player(0, "tableliving"), 1) then
		parse('maket '..p)
	end
    zp_hudtxt2(p,2,1,'',0,0,0)
    zp_hudtxt2(p,4,1,'',0,0,0)
    return 1
end

If you want to check overall players(including dead ones and spectators), simply change tableliving to table.

old Re: Count players and if?

VADemon
User Off Offline

Quote
@user Baloon: Yes. This is how the table returned by player(0, ...) looks:
{
[1] = playerID1,
[2] = playerID7,
[3] = playerID13,
[4] = playerID25,
}

#player(0,"tableliving") is 4 when 4 players are alive.

old Re: Count players and if?

Gaios
Reviewer Off Offline

Quote
user Gaios has written
What is
count
? A variable or count of players in-game?

This ^

Maybe he wants in-game players, or just alive. He didn't answer yet.
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview