• 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.

[vJASS] about selections

Status
Not open for further replies.
Level 7
Joined
Mar 22, 2010
Messages
228
JASS:
scope Selection initializer onInit

    private function select takes nothing returns nothing
        
    
        local integer index = GetPlayerId(GetTriggerPlayer())
        
    if DONT[index] == false then
        set PlayerTarget[index] = GetTriggerUnit()
        set DONT[index] = true
        call SelectUnitForPlayerSingle(gg_unit_Hmkg_0000, GetTriggerPlayer())
        set DONT[index] = false
    endif
    
    endfunction
    
    private function onInit takes nothing returns nothing
        local trigger t = CreateTrigger()
        local integer index = 0
        call TriggerAddAction(t, function select)
        loop
            call TriggerRegisterPlayerSelectionEventBJ(t, Player(index), true)
            set index = index + 1
            exitwhen index == bj_MAX_PLAYERS
        endloop
    endfunction

endscope

i was wondering why if i select another unit, it still says that PlayerTarget is gg_unit_Hmkg_0000..

i have this:
JASS:
scope Globals initializer onInit

    globals
        boolean array DONT
        constant string INV_TAR = "Invalid Target!"
        constant string NO_MAN = "Not Enought Mana!"
        constant string TOO_FAR = "Target Too Far Away!"
        constant string TOO_NEA = "Target Too Near!"
        constant string NO_TAR = "No Target!"
        constant string MAX_HP = "Your Target's HP is full!"
    endglobals

    function strings takes nothing returns nothing
        local integer index = 0
        debug call BJDebugMsg( "Globals initialized" )
        loop
            set DONT[index] = false
            set index = index + 1
            exitwhen index == bj_MAX_PLAYERS
        endloop
    endfunction

    private function onInit takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerAddAction(t, function strings)
        call TriggerRegisterTimerEventSingle(t, 1.00)
    endfunction

endscope

and:
JASS:
debug call BJDebugMsg(GetUnitName(PlayerTarget[index]))

what i want is when i select a unit, the unit becomes the
JASS:
PlayerTarget[index]
, after that the selection will go back to the hero.. please help me

i know its quite confusing but please ask me questions dealing this.
 
try changing the scope Globals into a library...

and its better if you post the whole code containing the function call for showing the name of the target...

not sure but maybe the select action still interferes with the code...

this is not related to prob, but use Conditions as its faster than actions... and also if DONT[index] == false is just the same as if not DONT[index] ...
 
Status
Not open for further replies.
Top