heheheh 3
See the function arguments
GetUnitTypeId returns an INTEGER, a NUMBER (yeah, units are numbers). In hashtables you can save INTEGERS, so, you can save a unit Type.
Also specific units have their own Handle Id despite of the unit type Id, it's found using GetHandleId(unit).
In my triggers I saved the UNIT TYPE ID of X on Z, and of Z in X.
In this case, you don't need it to be this way. Lets asume you're selling the RIGHT facing unit, you need to store in the RIGHT FACING UnitTypeID the UnitTypeID of the LEFT facing unit.
How?
Check how I did in the triggers.
call SaveInteger(Hashtable, parentkey, childkey, integer)
Hashtable = The hashtable
parentkey = 'xxxx' (Asuming it's the RIGHTFACING UnitTypeId)
childkey = 0
integer = 'zzzz' (Asuming it's the LEFTFACING UnitTypeId)
* You can see the ID of everything in Warcraft by pressing Ctrl+D in the Object Editor. you'll see every element turns to be a 4 characters sequence like 'hfoo' (Human Footman) or 'Hpal' (Human Paladin)
Now just replace the values
call SaveInteger(udg_YourHashtableVariable, 'xxxx', 0, 'zzzz')
When your unit is selected from a tavern (RightFacing)
Set ThisUnit[PlayerNumber] = Sold Unit
Make ThisUnit look to 0 angle (East)
-- Now we retrieve the data from the Sold Unit Unit Type ID
Custom script: set udg_UnitId = GetUnitTypeId(GetSoldUnit()) (This is the 'xxxx')
-- Now we load 0 of the unit type id (which is where we saved the 'zzzz')
Custom script: set udg_OtherId = LoadInteger(udg_YourHashtableVariable, udg_UnitId, 0)
* Set this udg_OtherId not as an integer variable, but as a unittype variable.
-- Now you create the unit
Unit - Create 1 udg_OtherId anywhere facing 180 (West)
Set this unit = OtherUnit[PlayerNumber]
-- Now you have ThisUnit[PlayerNumber] (The one you're currently using) and OtherUnit[PlayerNumber[ which is the opposite. When you turn left, you swap the variable values: You set ThisUnit[PlayerNumber] = OtherUnit[PlayerUnit] and OtherUnit[PlayerUnit] = ThisUnit[PlayerNumber] (You need another variable to store the value of any of them just for the data transition, otherwise you would overwrite the variable values)
Good look with this
I can try to make it on the night.