HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Player String Event

01-23-2007, 10:45 PM#1
Joker
Collapse JASS:
function TeamHu_Filter takes nothing returns boolean
    return IsUnitType( GetFilterUnit(), UNIT_TYPE_HERO ) == true
endfunction

function Hero_Name takes nothing returns nothing
    local unit b = GetEnumUnit()
    call DisplayTextToPlayer( GetTriggerPlayer(), 0, 0, udg_PlayerNames[GetConvertedPlayerId(GetOwningPlayer(b))] + " controls " + GetUnitName(b) )
    call BJDebugMsg( "works" )
    set b = null
endfunction 

function Trig_Other_Teams_Hu_Actions takes nothing returns nothing
    if GetEventPlayerChatString() == "-team 2" then
        call ForGroup( GetUnitsOfPlayerMatching( Player(3), Condition( function TeamHu_Filter ) ), function Hero_Name )
        call DestroyGroup( bj_lastCreatedGroup )
        call ForGroup( GetUnitsOfPlayerMatching( Player(4), Condition( function TeamHu_Filter ) ), function Hero_Name )
        call DestroyGroup( bj_lastCreatedGroup )
        call ForGroup( GetUnitsOfPlayerMatching( Player(5), Condition( function TeamHu_Filter ) ), function Hero_Name )    
        call DestroyGroup( bj_lastCreatedGroup )
    elseif GetEventPlayerChatString() == "-team 3" then
        call ForGroup( GetUnitsOfPlayerMatching( Player(6), Condition( function TeamHu_Filter ) ), function Hero_Name )
        call DestroyGroup( bj_lastCreatedGroup )
        call ForGroup( GetUnitsOfPlayerMatching( Player(7), Condition( function TeamHu_Filter ) ), function Hero_Name )
        call DestroyGroup( bj_lastCreatedGroup )
        call ForGroup( GetUnitsOfPlayerMatching( Player(8), Condition( function TeamHu_Filter ) ), function Hero_Name )
        call DestroyGroup( bj_lastCreatedGroup )
    elseif GetEventPlayerChatString() == "-team 4" then
        call ForGroup( GetUnitsOfPlayerMatching( Player(9), Condition( function TeamHu_Filter ) ), function Hero_Name )
        call DestroyGroup( bj_lastCreatedGroup )
        call ForGroup( GetUnitsOfPlayerMatching( Player(10), Condition( function TeamHu_Filter ) ), function Hero_Name )
        call DestroyGroup( bj_lastCreatedGroup )
        call ForGroup( GetUnitsOfPlayerMatching( Player(11), Condition( function TeamHu_Filter ) ), function Hero_Name )
        call DestroyGroup( bj_lastCreatedGroup )
    endif
endfunction

//===========================================================================
function InitTrig_Other_Teams_Hu takes nothing returns nothing
    set gg_trg_Other_Teams_Hu = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_Other_Teams_Hu, Player(0), "-team", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_Other_Teams_Hu, Player(1), "-team", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_Other_Teams_Hu, Player(2), "-team", false )
    call TriggerAddAction( gg_trg_Other_Teams_Hu, function Trig_Other_Teams_Hu_Actions )
endfunction
I cant seem to get this work. Everything seems fine b/c theres no errors and i dont see anything terribly wrong with it. Why is it not working?
01-23-2007, 11:02 PM#2
SFilip
call DestroyGroup( bj_lastCreatedGroup ) doesn't do anything in this case and your trigger still leaks.
bj_lastCreatedGroup is only set when creating units using CreateNUnitsAtLoc and it doesn't need to be destroyed.

As for the problem itself...care to give some more information? What exactly happens? Does the message "works" come up? Tried adding one between if and one of the elseif?
01-23-2007, 11:05 PM#3
Joker
no the "works" doesnt even show...no text shows up
01-24-2007, 12:02 AM#4
The_AwaKening
I'm guessing maybe your variable udg_PlayerNames is set wrong somewhere else, because it should be working.