• 🏆 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!

[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