• 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] Global triggers?

Status
Not open for further replies.
This is the most logical way I could think of doing this but it doesn't seem to work.

Typing -lvl after seeing the "only 1 player" messages does nothing.

JASS:
globals
    integer tempPlayerCheck
    trigger level
endglobals

function levelA takes nothing returns nothing
    local integer lv = GetHeroLevel(udg_PlayerBoat[2])
    call SetHeroLevel(udg_PlayerBoat[2],lv+1,true)
endfunction

function only1Add takes nothing returns nothing
    if GetPlayerSlotState(GetEnumPlayer())==PLAYER_SLOT_STATE_PLAYING and GetPlayerController(GetEnumPlayer())==MAP_CONTROL_USER then
        set tempPlayerCheck = tempPlayerCheck+1
    endif
endfunction

function Trig_only1Player_Actions takes nothing returns nothing
    set tempPlayerCheck = 0
    call ForForce(bj_FORCE_ALL_PLAYERS,function only1Add)
    call DisplayTextToPlayer(Player(2),0,0,I2S(tempPlayerCheck)+" in game")
    if tempPlayerCheck==1 then
        call DisplayTextToPlayer(Player(2),0,0,"Singleplayer mode detected, type -lvl for a level up")
        set level = CreateTrigger()
        call TriggerRegisterPlayerChatEvent(level,Player(0),"-lvl",true)
        call TriggerAddAction(level,function levelA)
    endif
endfunction

function InitTrig_only1Player takes nothing returns nothing
    set gg_trg_only1Player = CreateTrigger()
    call TriggerRegisterTimerEvent(gg_trg_only1Player,10,false)
    call TriggerAddAction(gg_trg_only1Player,function Trig_only1Player_Actions)
endfunction

Thanks for any help.
 
Status
Not open for further replies.
Top