Why is it not working? (SOLVED)
/////////////////////////////////////////////////////////////////////////////////
EDIT: Nvm. Very stupid of me. When reading this thread after I posted it I saw I forgot to change the values of the copied line "set AreaReg1 = CreateRegion()" to 2, 3, 4 and 5.
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
EDIT: Nvm. Very stupid of me. When reading this thread after I posted it I saw I forgot to change the values of the copied line "set AreaReg1 = CreateRegion()" to 2, 3, 4 and 5.
/////////////////////////////////////////////////////////////////////////////////
JASS:
scope AreaMove initializer init
globals
private integer PlayersInArea = 0
private trigger Trig_EnterArea = CreateTrigger()
private trigger Trig_LeaveArea = CreateTrigger()
private region AreaReg1
private region AreaReg2
private region AreaReg3
private region AreaReg4
private region AreaReg5
endglobals
private function EnterArea takes nothing returns nothing
local unit u = GetTriggerUnit()
local player p = GetOwningPlayer(u)
call BJDebugMsg("Players in Area: "+I2S(PlayersInArea))
if GetPlayerId(p) < 9 and IsUnitType(u, UNIT_TYPE_HERO) then
set PlayersInArea = PlayersInArea + 1
call BJDebugMsg("Players in Area: "+I2S(PlayersInArea))
endif
set u = null
set p = null
endfunction
private function LeaveArea takes nothing returns nothing
local unit u = GetTriggerUnit()
local player p = GetOwningPlayer(u)
if GetPlayerId(p) < 9 and IsUnitType(u, UNIT_TYPE_HERO) then
set PlayersInArea = PlayersInArea - 1
call BJDebugMsg("Players in Area: "+I2S(PlayersInArea))
endif
set u = null
set p = null
endfunction
private function init takes nothing returns nothing
local rect r
///PlayerCheck Regions///
set AreaReg1 = CreateRegion()
set r = gg_rct_ScorchedFarmFog1
call RegionAddRect(AreaReg1,r)
set AreaReg1 = CreateRegion()
set r = gg_rct_ScorchedFarmFog2
call RegionAddRect(AreaReg2,r)
set AreaReg1 = CreateRegion()
set r = gg_rct_ScorchedFarmFog3
call RegionAddRect(AreaReg3,r)
set AreaReg1 = CreateRegion()
set r = gg_rct_ScorchedFarmFog4
call RegionAddRect(AreaReg4,r)
set AreaReg1 = CreateRegion()
set r = gg_rct_WoodElfFog2
call RegionAddRect(AreaReg5,r)
///Enter/Leave Area///
call TriggerRegisterEnterRegion(Trig_EnterArea,AreaReg1,null)
call TriggerRegisterEnterRegion(Trig_EnterArea,AreaReg2,null)
call TriggerRegisterEnterRegion(Trig_EnterArea,AreaReg3,null)
call TriggerRegisterEnterRegion(Trig_EnterArea,AreaReg4,null)
call TriggerRegisterEnterRegion(Trig_EnterArea,AreaReg5,null)
call TriggerAddAction(Trig_EnterArea,function EnterArea)
call TriggerRegisterLeaveRegion(Trig_LeaveArea,AreaReg1,null)
call TriggerRegisterLeaveRegion(Trig_LeaveArea,AreaReg2,null)
call TriggerRegisterLeaveRegion(Trig_LeaveArea,AreaReg3,null)
call TriggerRegisterLeaveRegion(Trig_LeaveArea,AreaReg4,null)
call TriggerRegisterLeaveRegion(Trig_LeaveArea,AreaReg5,null)
call TriggerAddAction(Trig_LeaveArea,function LeaveArea)
set r = null
endfunction
endscope