// description.ext
class CfgFunctions {
class CYC {
class pingpong {
class ping {
preInit = 1;
postInit = 0;
recompile = 0;
ext = ".sqf";
file = "ping.sqf";
};
class pong {
preInit = 1;
postInit = 0;
recompile = 0;
ext = ".sqf";
file = "pong.sqf";
};
};
};
};
// ping.sqf
if (isDedicated) exitWith {};
sendPing = {
diag_log "sending ping";
ping = player;
while {isNil "pong"} do {
publicVariableServer "ping";
};
};
[] spawn {
"pong" addPublicVariableEventHandler {
diag_log "pong detected";
diag_log (_this select 1);
};
};
[] call sendPing;
// pong.sqf
if (!isDedicated) exitWith {};
[] spawn {
"ping" addPublicVariableEventHandler {
_sender = _this select 1;
diag_log format ["ping detected from %1",name _sender];
pong = "pong from publicVariable";
publicVariable "pong";
pong = "pong from publicVariableClient";
(owner _sender) publicVariableClient "pong";
diag_log "pong sent";
};
};
/*
On the client, ping will send to the server a player that does not yet exist during pre-Init.
On the server, the ping public variable listener will log the "player" who sent it, but because the player object sent does not yet exist, "name _sender" results in an error. Responding to the ping, the pong sent by the server using publicVariable will succeed whilst the pong sent by publicVariableClient will fail, evidently because "owner _sender" produces an erroneous value.
*/