- Joined
- Jun 16, 2008
- Messages
- 1,939
how do i clear a location with custom script that uses player number of owner of triggering unit as an array?
n help fast? +rep all who help!
n help fast? +rep all who help!
Simple as an orange -_-
Clearing specific location:
Clearing all locations:
- Actions:
- Custom script: call RemoveLocation(udg_TempLoc[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))+1])
- Actions:
- For each (Integer A) from 1 to 12, do (Actions)
- Actions:
- Custom script: call RemoveLocation(udg_TempLoc[bj_forLoopAIndex])
Airandus said:Why did you use that +1 you silly goose.
I wrapped that function to avoid bj, because most of bj functions are naturally useless evil.
At least I have an ability "BJ evasion" with 100% value =)
function GetConvertedPlayerId takes player whichPlayer returns integer
return GetPlayerId(whichPlayer) + 1
endfunction
No sir, you're wrong. I used GetPlayerId, you used GetConvertedPlayerId. Look at this:
JASS:function GetConvertedPlayerId takes player whichPlayer returns integer return GetPlayerId(whichPlayer) + 1 endfunction
it still is öhm, thx @ all
does getplayerid(whichplayer) result as 0 if not +1?
then it would be correct
Well, the function will return 0 for Player 1, 1 for Player 2, 2 for Player 3 and so on... So thats why you add +1, because in Guiwill result 1 for Player 1, 2 for Player 2...
- Set something[Get player number of triggering player]
If you dont add +1 in that custom script it will try to destroy a location which doesnt exist, and forget the last one every time.
function Trig_JASS_Actions takes nothing returns nothing
set udg_TempPoint[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))] = GetRectCenter(GetPlayableMapRect())
endfunction
//===========================================================================
function InitTrig_JASS takes nothing returns nothing
set gg_trg_JASS = CreateTrigger( )
call TriggerAddAction( gg_trg_JASS, function Trig_JASS_Actions )
endfunction
udg_TempPoint[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))]
So basically I'm not cleaning my leaks properly?
Well, when I create an array I want to clean, for example:
When I convert it I just get:
- GUI
- Events
- Conditions
- Actions
- Set TempPoint[(Player number of (Owner of (Triggering unit)))] = (Center of (Playable map area))
JASS:function Trig_JASS_Actions takes nothing returns nothing set udg_TempPoint[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))] = GetRectCenter(GetPlayableMapRect()) endfunction //=========================================================================== function InitTrig_JASS takes nothing returns nothing set gg_trg_JASS = CreateTrigger( ) call TriggerAddAction( gg_trg_JASS, function Trig_JASS_Actions ) endfunction
So basically it returns to me for that variable:
JASS:udg_TempPoint[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))]
Now I'm a total noob on Jass, but if I put that part in the custom script to clean the leak, it will return the correct value to clean right? =/
EDIT: I have always done it this way.
Indeed, GetConvertedPlayerId will return 1 for Player 1, 2 for Player 2...
I was just speaking on the behalf of using GetPlayerId(whichPlayer) which, in that function, should add +1 like Shadow Daemon said, to make it 'proper Gui'.
Sorry if I confused you