- Joined
- Aug 1, 2013
- Messages
- 4,658
How?
native SaveTimerHandle takes hashtable table, integer parentKey, integer childKey, timer whichTimer returns boolean
native LoadTimerHandle takes hashtable table, integer parentKey, integer childKey returns timer
native GetExpiredTimer takes nothing returns timer
Simple, you cant
I don't think it exists imo, I'm not sure if there is any specific way for assigning IDs to different types of objects.
I'm not sure I quite understand.
HandleId is an integer. Timer is new complex type. So you can't.
Yan can save a timer (handle) into hashtable with using any HandleId as key.
You can load a timer (handle) from hashtable with using the same HandleId as key.
native SaveTimerHandle takes hashtable table, integer parentKey, integer childKey, timer whichTimer returns boolean
native LoadTimerHandle takes hashtable table, integer parentKey, integer childKey returns timer
.
function GetTimerById takes integer id returns timer
return LoadTimerHandle(udg_Timer_Hashtable, id, 0)
endfunction
function SaveTimer takes timer t returns nothing
call SaveTimerHandle(udg_Timer_Hashtable, GetHandleId(t), 0, t)
endfunction
function GetTimerById takes integer id returns timer
return LoadTimerHandle(udg_Timer_Hashtable, id, 0)
endfunction
function SaveTimer takes timer t returns nothing
call SaveTimerHandle(udg_Timer_Hashtable, GetHandleId(t), 0, t)
endfunction
call GetTimerById(GetHandleId(myTimer))
will again return "myTimer".LoadTimerHandle
!= GetHandleId
.Difference = nullYou do not convert any HandleId into a timer. You just use it as key, when you save/load.
Then you want to load the timer basing on a given HandleId. Where should you get this HandleId from?
That implies you already have the timer, so:
call GetTimerById(GetHandleId(myTimer))
will again return "myTimer".
Title: "Convert timer handle id to timer"LoadTimerHandle
!=GetHandleId
.
Pick whichever you mean, you said handle of timer, this can mean various things, thats why I said to be more specific.
You turn around the question. The question was how do you get the timer if you have its handle id.Also while you are right, but it is not entirely true. You dont save the handle id of timer into hashtable. You store the timer under X index of handle id of the timer, and Y of 0.
function GetTimerById takes integer id returns timer
return LoadTimerHandle(udg_Timer_Hashtable, id, 0)
endfunction
function SaveTimer takes timer t returns nothing
call SaveTimerHandle(udg_Timer_Hashtable, GetHandleId(CreateGroup()), 0, t)
endfunction
function GetTimerById takes integer id returns timer
return LoadTimerHandle(udg_Timer_Hashtable, id, 0)
endfunction
function SaveTimer takes timer t returns nothing
call SaveTimerHandle(udg_Timer_Hashtable, GetHandleId(t), 0, t)
endfunction