• 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] Handling leaving Players

Status
Not open for further replies.
Level 7
Joined
May 16, 2004
Messages
355
Alright I need some help. For my map I had to scrap the generic triggers that dictate what happens when a player leaves. Now I need to create a new one that will properly give control of their hero and display the message and such.

Now I tried it with GUI and it continues to disapoint me, if they leave under extraordinary conditions(lagout/disconnect) it will for some reason NOT detect them leaving and will only play a message, no shared control. So I now need some help with the sharing of control since I am not too sure on what the calls are for that.
 
Level 22
Joined
Jan 10, 2005
Messages
3,426
In my map I use this code: (This is a long 1, theres probably another way but...)

Events:
Time - Every 2.00 seconds of game time
Conditions: -----
Actions:
If ((Player 1 (Red) slot status) Equal to Has left the game) then do (Trigger - Turn off (This trigger)) else do (Do nothing)
If ((Player 1 (Red) slot status) Equal to Has left the game) then do (Game - Grant shared vision and full shared unit control of Player 1 (Red) units with his/her allies) else do (Do nothing)
If ((Player 1 (Red) slot status) Equal to Has left the game) then do (Game - Display to (All players) the text: ((Name of Player 1 (Red)) + |cff330066has left the game!|r)) else do (Do nothing)
If ((Player 1 (Red) slot status) Equal to Is unused) then do (Trigger - Turn off (This trigger)) else do (Do nothing)
If ((Player 1 (Red) slot status) Equal to Is unused) then do (Game - Grant shared vision and full shared unit control of Player 1 (Red) units with his/her allies) else do (Do nothing)
 
Level 3
Joined
Jul 12, 2005
Messages
48
Ok this is my trigger taken directly from my AoS map im working on. I did this along time ago (like 6 months) when i first started learning jass so there could probably be some more optimizations but it works.

JASS:
function PlayerLeaves_Actions takes nothing returns nothing
    local force f
    local integer i
    local integer imax 
    local player p = GetTriggerPlayer()
    if IsPlayerInForce(p, udg_Alliance) then
        set f = udg_Alliance
        set i = 0
        set imax = 5
    else
        set f = udg_Undead
        set i = 6
        set imax =11
    endif
    call ShareEverythingWithTeam( p )
    call ForceRemovePlayer( f, p )
    loop
        exitwhen i > imax
        call AdjustPlayerStateBJ( ( GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) / CountPlayersInForceBJ(f) ), Player(i), PLAYER_STATE_RESOURCE_GOLD )
        set i = i + 1
    endloop
    call DisplayTextToForce( GetPlayersAll(), "|cffffff00" + GetPlayerName(p) + "|r has left the game")
    set f = null
    set p = null
endfunction

//===========================================================================
function InitTrig_PlayerLeaves takes nothing returns nothing
    local integer p = 0
    set gg_trg_PlayerLeaves = CreateTrigger(  )
    loop
        exitwhen p > 11
        call TriggerRegisterPlayerEventLeave( gg_trg_PlayerLeaves, Player(p))
        set p = p + 1
    endloop
    call TriggerAddAction( gg_trg_PlayerLeaves, function PlayerLeaves_Actions )
endfunction
 
Status
Not open for further replies.
Top