What's up guys,
I have a question about dtm's. Should they be called and freed every time u use one? Or is it all right if they get called before starting the mainloop and freed before the script stops?
What's up guys,
I have a question about dtm's. Should they be called and freed every time u use one? Or is it all right if they get called before starting the mainloop and freed before the script stops?
Good practice is to add this line after you loaded the DTMs, before your main loop:
StopScript is the name of a procedure you create. It can be called anything really, so long as there is a procedure that corresponds with the name.Simba Code:Addonterminate('StopScript');
This will fire every time the script is terminated. Anything you want to happen before the script stops, put it in this procedure.
Here is an example extract from my NMZ script:
Simba Code:procedure StopScript;
var
SessionXP: integer;
begin
freeDTM(Item_AbsorbPot.DTM);
freeDTM(Item_RockCake.DTM);
freeDTM(Item_AbsorbPotion.DTM);
freeDTM(Item_RangedPot.DTM);
freeDTM(Item_Overload.DTM);
XPH := Round((CurrentSkillXp) / (GetTimeRunning / 3600000.0));
SessionXP := GetSkillXP(SkilLToTrain) - StartingXP;
AddReport('Script Terminated', True);
AddReport('Elapsed time: ' + msToTime(GetTimeRunning, Time_Formal), True);
AddReport('Experience gained: ' + IntToStr(SessionXP), True);
AddReport('Experience gained per hour: ' +IntToStr(XPH), True);
end;
The benefit of this over simply putting FreeDTM at the bottom of your script, is that it will fire even if the script encounters an error, or is manually stopped.
Yes, even so, Simba still frees DTMs + Bitmaps on termination unless interrupted.
There are currently 1 users browsing this thread. (0 members and 1 guests)