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

I want to make a simple trigger in jass that kicks the player after he dies

Status
Not open for further replies.
Level 7
Joined
Nov 18, 2012
Messages
312
JASS:
//But I failed.
//I don't really know how the native works
function Trig_PlayerDies_Actions takes nothing returns nothing
call CustomDefeatBJ(Player(GetPlayerId(GetTriggerPlayer())),"You lose")
endfunction
function HeroDeadConditions takes nothing returns boolean
return IsUnitType(GetDyingUnit(),UNIT_TYPE_HERO)
endfunction
//===========================================================================
function InitTrig_PlayerDies takes nothing returns nothing
local integer i=0  //so it runs for all players
    set gg_trg_PlayerDies = CreateTrigger(  )
    loop
    exitwhen i>11
    call TriggerRegisterPlayerUnitEvent(gg_trg_PlayerDies, Player(i), EVENT_PLAYER_UNIT_DEATH, Condition(function HeroDeadConditions) )
    set i=i+1
    endloop
   call TriggerAddAction( gg_trg_PlayerDies, function Trig_PlayerDies_Actions )
    set i=0
endfunction
 
Level 7
Joined
Nov 18, 2012
Messages
312
thanks solved!
JASS:
function Trig_PlayerUnitDies_Actions takes nothing returns nothing
call CustomDefeatBJ(GetOwningPlayer(GetTriggerUnit()),"You lose")
endfunction
function HeroDeadConditions takes nothing returns boolean
return IsUnitType(GetDyingUnit(),UNIT_TYPE_HERO)
endfunction
//===========================================================================
function InitTrig_PlayerUnitDies takes nothing returns nothing
local integer i=0  //so it runs for all players
    set gg_trg_PlayerUnitDies = CreateTrigger(  )
    loop
    exitwhen i>11
    call TriggerRegisterPlayerUnitEvent(gg_trg_PlayerUnitDies, Player(i), EVENT_PLAYER_UNIT_DEATH, Condition(function HeroDeadConditions) )
    set i=i+1
    endloop
   call TriggerAddAction( gg_trg_PlayerUnitDies, function Trig_PlayerUnitDies_Actions )
    set i=0
endfunction
 
Status
Not open for further replies.
Top