Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
Nicolas Eymerich

How to check how many player in a Mp section...

Recommended Posts

Hi smile_o.gif

I need a little suggestion.

In particular, I've succeded to edit a script that check how many player are present in the same team.

The script looks like:

_unit = units group player

_num = count _unit

_i = 0; _b = 0;

#lp

? ((_unit select _i) == player) : _b = _b + 1

? (_b > 1) : goto ""

_i = _i + 1

? (_i >= num) : exit

~0.5

goto "lp"

But I've a question.

I'm doubtful that this script will work when two persons are playing in different teams.

In such case, how can I solve the problem? banghead.gif

Thanks for reading...

Share this post


Link to post
Share on other sites

Use arrays to define all playable units. Like westplayableunits=[W01, W02, W03, W04...]; and eastplayableunits=[E01, E02...]; Then allplayableunits=westplayableunits + eastplayableunits. You can also use triggers to count units with thislist parameter.

What's this do?

? (_b > 1) : goto ""

And here should be _num I think:

? (_i >= num) : exit

Share this post


Link to post
Share on other sites

Thanks!

2) Yes it is _num (just a mistake!wink_o.gif.

1) Well ---> ? (_b>1) : goto "another part of the script".

It was useless for the resolution of the problem.

Your answer is pretty good for me.

I've read somewhere that "list" statement is a command to avoid. Except the array and the list functions... (maybe i'm requesting too much) there'nt no other way?

I mean a way, how can I put this..., "automatic"... or better: a way to allow user to avoid him to define, every time, every single playable unit (in the array [by the way: what's happen if there is the respawn?]) or to use a trigger in the mission editor?

Share this post


Link to post
Share on other sites
Guest [B.B.S.] T_D

Maybe this command helps you:

Quote[/b] ]playersNumber side

Operand types:

side: Side

Compatibility:

Version 1.8 required.

Type of returned value:

Number

Description:

Return count of players playing on given side.

Share this post


Link to post
Share on other sites

I once tried to make a script to check if any players were in different groups, and if there were no players in the group, then delete the whole group. Problem was, for some reason it worked sometimes, but then suddenly it deleted all the AI in all the playable groups...no matter if there were a player in the group confused_o.gif

The way I did it, was to run a script for every playable unit, then check if the unit was player...if the unit was a player, then add 1 to a variable, 3 variables, 1 for each group, then when the scripts were done, count the variables, and if one was 0, then delete that group...dunno why it failed...maybe the game can't count properly huh.gif

Share this post


Link to post
Share on other sites

---> To Garcia: Maybe your script it was a bit... complicated huh.gif

I've learned that Mp mission have to be most simple as much as you can. Especially for scripts in it.

---> to [b.B.S.] T_D: Well, the command "playersNumber side"

return me a number. In other words: now I know how many players are present in a Mp sessions. But for my purpose I need an array...

However... Thanks again to you all...

wink_o.gif

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×