| 10-03-2006, 04:03 AM | #1 |
Ok, ive almost decided to run off a cliff in regards to this damn stuff. I want to learn handle vars, but im having trouble grasping it. Can someone show me the code to do the following; Unit dies, a timer is set up and run. I want to store the unit that died and how long it has to wait for using handles. When the timer expires, i want it to run a function and use the stored unit handle to revive the unit. Help????!!!! |
| 10-03-2006, 04:15 AM | #2 |
GC() is whichever initialized gamecache you're using usually this is just a variable which you set to InitGameCache("cache.w3v") during initialization. JASS:function HtoI takes handle h returns integer return h return 0 endfunction function ItoT takes integer i returns timer return i return null endfunction function ItoU takes integer i returns unit return i return null endfunction function UnitDies_cb takes nothing returns nothing local integer t = HtoI(GetExpiredTimer()) local unit u = ItoU(GetStoredInteger(GC(),I2S(t),"deadunit")) // revive however you want to do that call DestroyTimer(ItoT(t)) set u = null endfunction function UnitDiesAction takes nothing returns nothing local integer t = HtoI(CreateTimer()) call StoreInteger(GC(),I2S(t),"deadunit",HtoI(GetTriggerUnit())) //timer, delay, true = periodic false = single, callback function call TimerStart(ItoT(t),36.7,false,function UnitDies_cb) endfunction |
| 10-03-2006, 04:50 AM | #3 |
Got it, i wasnt doing the gamecache part of it. Excellent, i learnt something new! :D |
