• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Not sure how to sort players..

Status
Not open for further replies.
Level 3
Joined
Jul 15, 2007
Messages
36
Not sure how to sort players.. (EDITWhy i Love Jasscraft)

Hi again (can you tell i've been busy?) and thanks for all the previous help.

Near the startup of my map, I'm trying to find which players actually have a player in them, and remove their units from the game.

At the moment, the trigger catches computer controlled players, and gets rid of them, however if a player slot is empty it doesn't catch it.

The code is below:
JASS:
function Trig_ContinueMultiboard_Actions takes nothing returns nothing
    local integer i = 0
    local integer r = 0
    local player p = null
    local group g = CreateGroup()
    local unit u = null
    loop
        exitwhen i == 8
        set r = i + 2
        set p = Player(i)
        if  GetPlayerController(p) != MAP_CONTROL_USER then
            set udg_Lives[i] = 0
            set udg_Income[i] = 0
            call MultiboardSetItemValueBJ( udg_Scoreboard, 2, r, "<<NotPlaying>>" )
            call MultiboardSetItemValueBJ( udg_Scoreboard, 3, r, I2S(udg_Lives[i]) )
            call MultiboardSetItemValueBJ( udg_Scoreboard, 4, r, I2S(udg_Income[i]) )
            set g = GetUnitsOfPlayerAll(Player(i))
            set u = FirstOfGroup(g)
            loop
                exitwhen u == null
                call GroupRemoveUnit(g,u)
                call KillUnit(u)
                set u = FirstOfGroup(g)
            endloop
        else
            call MultiboardSetItemValueBJ( udg_Scoreboard, 2, r, GetPlayerName(Player(i)) )
            call MultiboardSetItemValueBJ( udg_Scoreboard, 3, r, I2S(udg_Lives[i]) )
            call MultiboardSetItemValueBJ( udg_Scoreboard, 4, r, I2S(udg_Income[i]) )
        endif
        set i = i + 1
        call TriggerSleepAction( 0.50 )
    endloop
    set p = null
    set i = 0
    set u = null
    call GroupClear(g)
    call DestroyGroup(g)
endfunction

//===========================================================================
function InitTrig_ContinueMultiboard takes nothing returns nothing
    set gg_trg_ContinueMultiboard = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( gg_trg_ContinueMultiboard, 1.00 )
    call TriggerAddAction( gg_trg_ContinueMultiboard, function Trig_ContinueMultiboard_Actions )
endfunction

==============={EDIT}==================

Why I love JASScraft: sometimes, after spending hours on a problem, you find what you're looking for at random in the native list;

JASS:
function Trig_ContinueMultiboard_Actions takes nothing returns nothing
    local integer i = 0
    local integer r = 0
    local player p = null
    local group g = CreateGroup()
    local unit u = null
    loop
        exitwhen i == 8
        set r = i + 2
        set p = Player(i)
        if  GetPlayerSlotState(p) != PLAYER_SLOT_STATE_PLAYING then
            set udg_Lives[i] = 0
            set udg_Income[i] = 0
            call MultiboardSetItemValueBJ( udg_Scoreboard, 2, r, "<<NotPlaying>>" )
            call MultiboardSetItemValueBJ( udg_Scoreboard, 3, r, I2S(udg_Lives[i]) )
            call MultiboardSetItemValueBJ( udg_Scoreboard, 4, r, I2S(udg_Income[i]) )
            set g = GetUnitsOfPlayerAll(Player(i))
            set u = FirstOfGroup(g)
            loop
                exitwhen u == null
                call GroupRemoveUnit(g,u)
                call KillUnit(u)
                set u = FirstOfGroup(g)
            endloop
        else
            call MultiboardSetItemValueBJ( udg_Scoreboard, 2, r, GetPlayerName(Player(i)) )
            call MultiboardSetItemValueBJ( udg_Scoreboard, 3, r, I2S(udg_Lives[i]) )
            call MultiboardSetItemValueBJ( udg_Scoreboard, 4, r, I2S(udg_Income[i]) )
        endif
        set i = i + 1
        call TriggerSleepAction( 0.50 )
    endloop
    set p = null
    call GroupClear(g)
    call DestroyGroup(g)
    set u = null
    set i = 0
endfunction

//===========================================================================
function InitTrig_ContinueMultiboard takes nothing returns nothing
    set gg_trg_ContinueMultiboard = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( gg_trg_ContinueMultiboard, 1.00 )
    call TriggerAddAction( gg_trg_ContinueMultiboard, function Trig_ContinueMultiboard_Actions )
endfunction

============{/EDIT}=========

Ty Ty
 
Status
Not open for further replies.
Top