[Vscript] CS:GO / Squirrel scripting assistance wanted

Hi, as some of you may know, I recently released a CTF gameplay example map for CS:GO. That gameplay was based on entities alone and suffers from bugs on dedicated servers due to ‘whatever’. I’ve decided to rewrite the gameplay mode to Vscript (squirrel for CS:GO) to ensure a solid working gamemode. I’ve completed around 95% of the mode already, but I’m stuck on handling the event in which a person is flagcarrier and disconnects, leaving null references etc.

I seek help from people who have experience with Squirrel in particular, many programmer friends fail to see the logic in what currently is happing.

The script checks if a carrier exists, and if yes, checks its HP. If the hp is above 0, updates its position, if its 0, resets the ‘carrier’ value to null. Whilst that works perfectly, the carrier (and its parented objects such as the flag model) are destoyed and the script will spam null references since the carrier value isn’t filled properly anymore. Even if I try to catch this with a big if (carrier != null ) {} around the function that ‘crashes’, it continues to spam errors.

A nice printl(carrier) shows me perfectly that when a flag is not taken, it’s value is (null : 0x00000000). If a player has it, the value is ([2] player) (where value 2 is depending on the player in the server).

Some sample console output: http://pastebin.com/FKFkQzYX
You can see there that it spams nicely that the carrier for either flag is null or a player, which is correct. After the player disconnects, it fails, even with the “if (carrier != null ) {}” around the function that it shows to be referencing a null instance. Direct assitance is wished over the forum as the issue can probably be solved faster that way. SpherixNL on steam.

Thanks a bunch.