Post by Ron4Swat on Mar 11, 2018 18:00:25 GMT
The initialization of multiple variables in TRGM2 seems to me to is implemented in a way which is easy to create problems.
See for example RandFramework/mainInit.sqf. This code is executed on server and all clients. There are multiple variables that are initalized and broadcasted to all other clients (and the server) via publicVariable.
One of the problems is that its undefined when a variable is actually transmitted to other clients after publicVariable calls. Especially at a start of a mission it can easily take 10-20 seconds and more until a variable is actually broadcasted.
So what happens for example if the commander creates the mission, bAndSoItBegins is set true and transmitted to everyone, however a bAndSoItBegins=false that was set in RandFramework/General/TRGMInitPlayerLocal.sqf and is transmitted late from a client to everyone else is comming in late?
Also several variables seem to be broadcasted to everyone unnecessarly as they are only used on the server anyway (for example bBaseHasChopper).
Similiar issue for example with KilledPlayers array. When player dies RandFramework\General\TRGMOnPlayerKilled.sqf is executed on players computer and the player is added to the KilledPlayers array, which then is broadcasted via publicVariable. If multiple players are killed at roughly the same time, then its completely undefined which player has which version of the array and which client is sending his version of the KilledPlayers last.
Imho it would be better to manage all that on the server as much as possible. In the case of KilledPlayers for example you could put all the logic to the server and call a function or script from a client with the needed parameters like playerUID and playerPos as parameters. This way you have the KilledPlayer array only on the server and don't have to worry about it being ever outdated or overwritten from another client.
See for example RandFramework/mainInit.sqf. This code is executed on server and all clients. There are multiple variables that are initalized and broadcasted to all other clients (and the server) via publicVariable.
One of the problems is that its undefined when a variable is actually transmitted to other clients after publicVariable calls. Especially at a start of a mission it can easily take 10-20 seconds and more until a variable is actually broadcasted.
So what happens for example if the commander creates the mission, bAndSoItBegins is set true and transmitted to everyone, however a bAndSoItBegins=false that was set in RandFramework/General/TRGMInitPlayerLocal.sqf and is transmitted late from a client to everyone else is comming in late?
Also several variables seem to be broadcasted to everyone unnecessarly as they are only used on the server anyway (for example bBaseHasChopper).
Similiar issue for example with KilledPlayers array. When player dies RandFramework\General\TRGMOnPlayerKilled.sqf is executed on players computer and the player is added to the KilledPlayers array, which then is broadcasted via publicVariable. If multiple players are killed at roughly the same time, then its completely undefined which player has which version of the array and which client is sending his version of the KilledPlayers last.
Imho it would be better to manage all that on the server as much as possible. In the case of KilledPlayers for example you could put all the logic to the server and call a function or script from a client with the needed parameters like playerUID and playerPos as parameters. This way you have the KilledPlayer array only on the server and don't have to worry about it being ever outdated or overwritten from another client.