Author Topic: SC3 Where to destruct global variables  (Read 2111 times)

0 Members and 1 Guest are viewing this topic.

Offline JotEmI

  • Soldier
  • **
  • Posts: 188
SC3 Where to destruct global variables
« on: January 02, 2015, 04:51:20 am »
Consider following example where I create a global variable of type TStringList and fill it with couple of name/value pairs:
Code: [Select]
var
sprees: TStringList

begin
sprees:=File.CreateStringList();
sprees.Append('5=is on killing spree');
sprees.Append('8=is on rampage');
end.

Falcon stressed out how important it is to destruct objects by calling Free() procedure. But where do I destruct object declared as a global variable that I intend to use throughout the whole script? Is it automatically destroyed during recompilation?

DarkCrusade

  • Guest
Re: SC3 Where to destruct global variables
« Reply #1 on: January 02, 2015, 06:00:41 am »
Was there not a procedure called OnShutDown()? I remember it from somewhere.

Offline JotEmI

  • Soldier
  • **
  • Posts: 188
Re: SC3 Where to destruct global variables
« Reply #2 on: January 02, 2015, 06:09:40 am »
I think it was in SC2, in SC3 there is no such event.

Offline Shoozza

  • Retired Soldat Developer
  • Veteran
  • ******
  • Posts: 1632
  • Soldat's Babysitter
    • Website
Re: SC3 Where to destruct global variables
« Reply #3 on: January 02, 2015, 08:28:15 am »
In Delphi you could use the finalization part. Not sure if this is implemented in the scriptcore though.
http://www.delphibasics.co.uk/RTL.asp?Name=Unit&ExpandCode1=Yes
Rules
Tools: ARSSE - SARS - SRB - chatMod

Offline JotEmI

  • Soldier
  • **
  • Posts: 188
Re: SC3 Where to destruct global variables
« Reply #4 on: January 03, 2015, 02:58:39 pm »
In Delphi you could use the finalization part. Not sure if this is implemented in the scriptcore though.
http://www.delphibasics.co.uk/RTL.asp?Name=Unit&ExpandCode1=Yes
Thanks, I'll check it out.

Offline Mighty

  • Camper
  • ***
  • Posts: 276
Re: SC3 Where to destruct global variables
« Reply #5 on: January 07, 2015, 04:06:15 am »
I was negotiating with Falcon about that, and finalization can be used by separate units included, but not the main file itself. A dummy main file only to use a unit works as far as i remember.
xFire: macmil        e-mail: macekmil@gmail.com
My scripts: Accuracy Script       Flashbang       Punishments GUID
            CatchMe Gamemod       AntiFake
            CW System             AntiFakeGUID