• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] Counting the number of human players

Status
Not open for further replies.
Level 10
Joined
Jun 6, 2007
Messages
392
I'm working on a hero siege, and I'm going to make a different number of creatures to spawn per wave depending on the number of players. How can I check how many human players there are? CheckPlayersByMapControl() also counts players that aren't actually playing, so It can't be used for this.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
GUI:
  • Set PlayerAmount = (Number of players in (All players matching ((((Matching player) controller) Equal to User) and (((Matching player) slot status) Equal to Is playing))))
JASS:
JASS:
loop
    exitwhen i == 16
    
    if GetPlayerController( Player(i) ) == MAP_CONTROL_USER and GetPlayerSlotState( Player(i)_) == PLAYER_SLOT_STATE_PLAYING then
        set playerAmount = playerAmount + 1
    endif
    set i = i + 1
endloop

Probably could've been done in a different way. Those should work though.

Edit: You shouldn't mind the player group in the GUI-form all that much. Yes, it's better to clean player groups, but 1 instance won't change anything.
 
Status
Not open for further replies.
Top