Created
May 15, 2021 03:43
-
-
Save indig0fox/19a19cb79b8b8b067cc988db84428056 to your computer and use it in GitHub Desktop.
FetchStaffInfo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
script that uses the url_fetch x64 extension to poll (every 180 seconds) a PHP site with a query param of playerUID to return an array containing player name and staff role, which is then folded into a broadcast variable and used on clients for rendering 3d icons, measuring restrictions, etc. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//file: url_fetch.sqf | |
if (isServer) then { | |
params ["_uid", "_url"]; | |
private "_result"; | |
waitUntil { | |
if ("url_fetch" callExtension format [ | |
"%1", | |
_url | |
] == "OK") exitWith {true}; | |
false | |
}; | |
waitUntil { | |
_result = "url_fetch" callExtension "OK"; | |
if (_result != "WAIT") exitWith {true}; | |
false | |
}; | |
if (_result == "ERROR") exitWith { | |
//deal with error here | |
diag_log format [ | |
">>> [url_fetch v2.0] >>> ERROR: %1; ARGUMENTS: %2", | |
"url_fetch" callExtension "ERROR", | |
_url | |
]; | |
}; | |
//deal with result here | |
diag_log format [ | |
">>> [url_fetch v2.0] >>> RESULT: %1", | |
_result | |
]; | |
if (_result != "") then {(missionNamespace getVariable "staffInfo") set [_uid, _result]}; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
missionNamespace setVariable["staffInfo", createHashMap]; | |
pollStaffInfo = [{ | |
{ | |
_uid = getPlayerUID _x; | |
[_uid, format["http://ops.fridaynightfight.org/9062staff/?playerUID=%1", _uid]] execVM "url_fetch.sqf"; | |
} forEach allPlayers; | |
publicVariable "staffInfo"; | |
}, 180] call CBA_fnc_addPerFrameHandler; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment