Hi,
i am not very used to return function,
the only thing i know how to return is boolean.
so here there is a function wich take a force and return an integer, i want to know if i can call it and use it like that?
[Jass=]
function pickPlayer takes force team returns integer
local integer i = 0
loop
exitwhen i > 11
if IsPlayerInForce(Player(i), team) == true then
return i
endif
set i = i + 1
endloop
return 12
endfunction
function Totem_Timer takes nothing returns nothing
local real x
local real y
local integer i = 1
local integer p
set udg_TimerCheck = false
call DestroyTrigger( gg_trg_Totem_Timer_Remover )
call PauseTimer( udg_Totem_timer )
call DestroyTimerDialog( udg_Totem_window )
loop
exitwhen i > 12
if GetUnitState( udg_Hero_Building, UNIT_STATE_LIFE ) > 0.00 then
call SetPlayerState( Player(i-1), PLAYER_STATE_RESOURCE_GOLD, 1000 )
call IssueNeutralImmediateOrderById( Player(i-1), udg_Hero_Building[udg_A], 'H001' )
endif
set i = i + 1
endloop
set i = 1
loop
exitwhen i > 3
if udg_TeamNumber > 0 then
if udg_TotemOwned == false then
if GetWidgetLife(udg_TotemKit) > 0 then
call RemoveItem( udg_TotemKit )
set x = GetRectCenterX(udg_TeamStart)
set y = GetRectCenterY(udg_TeamStart)
set p = pickPlayer(udg_Team)
set udg_Totem = CreateUnit( Player(p), 'h004', x, y, bj_UNIT_FACING )
set udg_TotemOwned = true
endif
endif
else
set x = GetRectCenterX(udg_TeamStart)
set y = GetRectCenterY(udg_TeamStart)
set udg_Totem = CreateUnit( Player(PLAYER_NEUTRAL_PASSIVE), 'h004', x, y, bj_UNIT_FACING )
call KillUnit( udg_Totem )
endif
set i = i + 1
endloop
call TriggerSleepAction( 1.00 )
call DestroyTrigger( GetTriggeringTrigger() )
endfunction
//===========================================================================
function InitTrig_Totem_Timer takes nothing returns nothing
set gg_trg_Totem_Timer = CreateTrigger( )
call TriggerRegisterTimerExpireEvent( gg_trg_Totem_Timer, udg_Totem_timer )
call TriggerAddAction( gg_trg_Totem_Timer, function Totem_Timer )
endfunction
[/code]
i wanted to return a player at first but it looked too complicated...
i am not very used to return function,
the only thing i know how to return is boolean.
so here there is a function wich take a force and return an integer, i want to know if i can call it and use it like that?
[Jass=]
function pickPlayer takes force team returns integer
local integer i = 0
loop
exitwhen i > 11
if IsPlayerInForce(Player(i), team) == true then
return i
endif
set i = i + 1
endloop
return 12
endfunction
function Totem_Timer takes nothing returns nothing
local real x
local real y
local integer i = 1
local integer p
set udg_TimerCheck = false
call DestroyTrigger( gg_trg_Totem_Timer_Remover )
call PauseTimer( udg_Totem_timer )
call DestroyTimerDialog( udg_Totem_window )
loop
exitwhen i > 12
if GetUnitState( udg_Hero_Building, UNIT_STATE_LIFE ) > 0.00 then
call SetPlayerState( Player(i-1), PLAYER_STATE_RESOURCE_GOLD, 1000 )
call IssueNeutralImmediateOrderById( Player(i-1), udg_Hero_Building[udg_A], 'H001' )
endif
set i = i + 1
endloop
set i = 1
loop
exitwhen i > 3
if udg_TeamNumber > 0 then
if udg_TotemOwned == false then
if GetWidgetLife(udg_TotemKit) > 0 then
call RemoveItem( udg_TotemKit )
set x = GetRectCenterX(udg_TeamStart)
set y = GetRectCenterY(udg_TeamStart)
set p = pickPlayer(udg_Team)
set udg_Totem = CreateUnit( Player(p), 'h004', x, y, bj_UNIT_FACING )
set udg_TotemOwned = true
endif
endif
else
set x = GetRectCenterX(udg_TeamStart)
set y = GetRectCenterY(udg_TeamStart)
set udg_Totem = CreateUnit( Player(PLAYER_NEUTRAL_PASSIVE), 'h004', x, y, bj_UNIT_FACING )
call KillUnit( udg_Totem )
endif
set i = i + 1
endloop
call TriggerSleepAction( 1.00 )
call DestroyTrigger( GetTriggeringTrigger() )
endfunction
//===========================================================================
function InitTrig_Totem_Timer takes nothing returns nothing
set gg_trg_Totem_Timer = CreateTrigger( )
call TriggerRegisterTimerExpireEvent( gg_trg_Totem_Timer, udg_Totem_timer )
call TriggerAddAction( gg_trg_Totem_Timer, function Totem_Timer )
endfunction
[/code]
i wanted to return a player at first but it looked too complicated...