fn_Quiksilver 1636 Posted August 23, 2015 Hi guys, Trying to detect if a variable in a certain namespace (object/group/etc) is public. For instance unit setVariable ["isDrunk",TRUE,TRUE]; vs. unit setVariable ["isDrunk",TRUE,FALSE]; Is there a method to return the difference between those two uses of setVariable? getVariable AFAIK only returns the value. Share this post Link to post Share on other sites
MrCopyright 107 Posted August 23, 2015 A simple way of detecting if the setVariable is public would be to try and retrieve it from another client. If you use the getVariable command on a unit and it returns nil, then you know the variable is not public. Here's a quick demonstration: Example A Server: unit1 setVariable ["isDrunk", true, false]; Client: unit1 getVariable "isDrunk" // -- This will return nothing and can be detected by using isNil Example B Server: unit1 setVariable ["isDrunk", true, true]; Client: unit1 getVariable "isDrunk" // -- This will return true I hope this is what you are looking for. 1 Share this post Link to post Share on other sites
fn_Quiksilver 1636 Posted August 24, 2015 A simple way ... :D If thats a simple way ... Sending messages back and forth via publicvariableclient / publicvariableserver, and hold the script until that stuff is done ... Thought there might be something a little harder! So here is how I see that working, rough sketch: //init server 0. server initializes, create a server array and a public variable event handler to add stuff to that array //init player 1. player initializes, create a public variable event handler to check the variable and provide a return // server script 2. in the script, publicvariableclient a random player the variable to check. 3. hold the script in a loop while waiting for the server array to be updated. 4. continue publicvariableclient spamming until a response is received with the correct variable name. 5. once the server array is updated, iterate through it to find the correct variable name 6. pull the details from the array and check the result. 7. delete any corresponding elements from the array. 8. move on :( Share this post Link to post Share on other sites
dreadedentity 278 Posted August 25, 2015 I wrote a little function for you, unfortunately I don't have a server to test it on at the moment. I have no idea if it will work but it's been a while since I've tried anything crazy. testVar = { /* Params: P1: Array of objects - Should only be player units To easily get an array of all players use: _allPlayers = []; { if (isPlayer _x) then { _allPlayers pushBack _x }; }forEach allUnits; P2: Namespace - The namespace that you want to retreive a variable from P3: String - The name of the variable you want to retreive Example Call: [[_array,_of,_players], missionNamespace, "test"] call testVar; */ [ [[(_this select 1),(_this select 2)],{ _varResult = (_this select 0) getVariable [(_this select 1), "NULL"]; [[[_namespace, _variable, _varResult],{hintSilent format ["Variable Retrieved!\nNamespace: %1\nVarible: %2\nResult: %3",(_this select 0),(_this select 1),(_this select 2)]}], "BIS_fnc_call", 0, true] call BIS_fnc_MP; }], "BIS_fnc_call", owner ((_this select 0) call BIS_fnc_selectRandom), true ] call BIS_fnc_MP; }; It's (supposed) to work by picking out a random player from a list of players you provide, use BIS_fnc_MP to drop a code bomb on that player, he checks the variable, and sends a BIS_fnc_MP packet back to the server with the result. By the way, if the variable doesn't exist, it will show "NULL" (provided that this code works at all). By the way, this is not a recommended way to use BIS_fnc_MP. Share this post Link to post Share on other sites