GML Circular variable requirement dilemma


So, I have this code for the weapon object of a tank on the server side:
    var projectile_spawned = instance_create(tipx, tipy, obj_projectile);
        image_angle = other.image_angle;
        damage = other.damage;
        client_id_to_send = other.client_id_to_send;
Upon the creation of the projectile, I need the client_id_to_send be declared in the projectile... but the problem is, from what I can recall, once the projectile is created, all of its initiation code is executed. That is a problem. Upon initiating, the weapon's running code will stop until the initiation code for the projectile has finished. And that's a problem, because the projectile in its create event will send a packet of data to the client, which requires data for its client_id_to_send variable, which upon initiation is empty, but which the weapon declares after it has created the projectile. And the data can't not be empty for the projectile at the start and then be declared by the weapon, because that data will vary depending on the incoming client data that the server object deals with.

So, how do I solve this issue?

Could having another variable check that encompasses the projectile's buffer writing and packet sending code, with the variable declared to false at first, but the turret then setting it to true after changing the projectile's empty string variable work? Cause all of this does run in just one frame. So, the question is, will the game run through the projectile's creation code again just because two variables have been changed that would impact the outcome if the code were to run again?

Or may be I'm miss-remembering and the projectile's creation code doesn't run until the weapon's code for one frame has completed or something?


If the content of your packet depends on data that is set after the creation event is run, then you need to write/send your packet sometime after the creation event is complete, not at the tail end while the create event is still running.