• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

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