Jump to content

Plot for Life + infiSTAR Owner Identification


Guest

Recommended Posts

Ever wanted to find out who owned a base without having to look up each object in the database?
 
Wrote this for that very reason.
 
Replace the admin_showid function in AH.sqf with this:

	admin_showid =
	{
		[] spawn {
			_obj = cursortarget;
			if (!isNull _obj) then
			{
				_charID = _obj getVariable["CharacterID","0"];
				_objID = _obj getVariable["ObjectID","0"];
				_objUID = _obj getVariable["ObjectUID","0"];
				_ownerPUID = _obj getVariable["OwnerPUID","0"];
				_lastUpdate = _obj getVariable["lastUpdate",time];
				_pos = getPosATL _obj;
				private ["_ownerName"];
				if (_ownerPUID != "0") then {
					getPlayerName = [player,_ownerPUID];
					publicVariableServer 'getPlayerName';
					waitUntil {!isNil 'retPlayerName'};
					_ownerName = retPlayerName;
				} else {
					_ownerName = "None!";
				};
				
				_log1 = format["%1, WorldSpace: [%2,%3], @%4, Owner: %5",typeOf _obj,getDir _obj,_pos,mapGridPosition _pos,_ownerName];
				_log2 = format["charID: %1, objID: %2, objUID: %3, lastUpdate: %4s ago",_charID,_objID,_objUID,time - _lastUpdate];
				if (isPlayer _obj) then
				{
					_log2 = format["Name: %1  PlayerUID: %2  charID: %3",_obj getVariable['bodyName',name _obj],getPlayerUID _obj,_charID];
				};
				if (!isNil "DZE_DoorsLocked" && !isNil "DZE_LockedStorage") then
				{
					_objType = typeOf _obj;
					if (_objType in DZE_DoorsLocked || _objType in DZE_LockedStorage) then
					{
						_log2 = format["LockCode: %1, objID: %2, objUID: %3, lastUpdate: %4s ago",_charID,_objID,_objUID,time - _lastUpdate];
					}
					else
					{
						_vID = parseNumber _charID;
						if (((_obj isKindOf 'LandVehicle') || (_obj isKindOf 'Air') || (_obj isKindOf 'Ship')) && (_vID > 0)) then
						{
							_colors = ["Green", "Red", "Blue", "Yellow", "Black"];
							_key = format["ItemKey%1%2", _colors select floor(_vID / 2500), (_vID - (floor(_vID / 2500) * 2500))];
							_displayName = (getText (configFile >> 'CfgWeapons' >> _key >> 'displayName'));
							
							_log2 = format["Key: %1 (%2) - CharID: %3, objID: %4, objUID: %5",_key,_displayName,_charID,_objID,_objUID];
						};
					};
				};
				{systemChat _x;diag_log _x;} forEach [_log1,_log2];
			};
		};
	};

Add these to the bottom of server_functions.sqf:

fnc_mdc_nameFromPID = {
	private ['_superkey', '_key', '_result', '_playerID'];
	_caller = owner (_this select 0);
	_playerID = _this select 1;
	_superkey = profileNamespace getVariable 'SUPERKEY';
	_key = format['CHILD:500:%1:Character.player_data:', _superkey];
	_result = _key call server_hiveReadWrite;

	_key = format["CHILD:501:Character.player_data:[""PlayerName""]:[[""PlayerUID"", ""="", ""%1""]]:1:", _playerID];
	_result = _key call server_hiveReadWrite;

	_key = format['CHILD:504:%1:',_result select 1];
	_result = _key call server_hiveReadWrite;

	_playerName = (_result select 1) select 0;
	retPlayerName = _playerName;
	_caller publicVariableClient "retPlayerName";
};

"getPlayerName" addPublicVariableEventHandler {
	_caller = (_this select 1) select 0;
	_playerID = (_this select 1) select 1;
	[_caller, _playerID] call fnc_mdc_nameFromPID;
};

And on line 1 of your publicvariable.txt, add !="getPlayerName" to the end.
 
Enjoy!

Link to comment
Share on other sites

I kinda have this working without infistar, however I have to look in arma2oaserver.RPT 

to see who the owner is..

is this correct or should it show in game dialog ???

my rpt now shows

 

11:57:19 "HOUSE SERVER: Owners Are: B1 [] B2 [] B3 [] H1 ["76561198015664111"] H2 ["76561198015664111"] H3 ["76561198015664111"] SG [] LG [] KING [] SH ["0"]"

 

is this how it should work or should it show in game ???

Link to comment
Share on other sites

I kinda have this working without infistar, however I have to look in arma2oaserver.RPT 

to see who the owner is..

is this correct or should it show in game dialog ???

my rpt now shows

 

11:57:19 "HOUSE SERVER: Owners Are: B1 [] B2 [] B3 [] H1 ["76561198015664111"] H2 ["76561198015664111"] H3 ["76561198015664111"] SG [] LG [] KING [] SH ["0"]"

 

is this how it should work or should it show in game ???

this is only from the origins building system, the function which he edit is if you look to a object and press I, then it will also show the owner name.

Link to comment
Share on other sites

Eeeeeexactly :)

Although theoretically the functions in server_functions.sqf could be used in ANYTHING which needs to resolve PlayerID to PlayerName, even for players who are offline.

The relevant syntax for this would be:

getPlayerName = [player,_playerID]; // Passes your clientID for the return PVC, and a string-formatted Player ID to query
publicVariableServer 'getPlayerName'; // Broadcasts the request to the server
waitUntil {!isNil 'retPlayerName'}; // Wait for server to query the DB
_playerName = retPlayerName; // Assign the results of the query to a variable
Link to comment
Share on other sites

Nice work, very handy tool!

Edit, after trying this out a bit I've crashed my server numerous times. Has anybody else experienced this? I thought it was down to spamming it but no, even when just going base to base it crashes :/

 

I've heard reports of CHILD:500 calls crashing CERTAIN servers (not all, but a few); I'm currently using Soul's SC HiveExt.dll, not sure if he's made any enhancements to that side of things but that could be a reason why.

 

Haven't had any crashing errors myself, but I've only done limited testing.

I've sent it to Chris but I'll make him aware of the potential issues so he can make it switchable in AHconfig.sqf if he does integrate it.

Link to comment
Share on other sites

I've heard reports of CHILD:500 calls crashing CERTAIN servers (not all, but a few); I'm currently using Soul's SC HiveExt.dll, not sure if he's made any enhancements to that side of things but that could be a reason why.

 

Haven't had any crashing errors myself, but I've only done limited testing.

I've sent it to Chris but I'll make him aware of the potential issues so he can make it switchable in AHconfig.sqf if he does integrate it.

 

Awww, that's a shame. I too am using that Hive dll. Damn, that renders it useless for me as I can't really be crashing the server all the time. Bummer.

 

Have you tried spamming it on a single object? If I spam it, after 5 seconds the server will crash. It's kind of like it has a limited amount of uses.

 

Another weird thing I'm experiencing, I have to do it twice to get the reveal information. I press I on a wall and it gives me what I got the last time I pressed I, I have to then press I again to get the actual information for the wall. It's like the request is being queued or something.

Link to comment
Share on other sites

Unfortunately I can confirm the crashing problem :(

 

I had to literally hold I down for about 30 seconds (about 200-300 queries), but eventually it crashed.

 

I'll try it with a 502 call instead of a 501 (asynchronous) and see if that helps things.

Link to comment
Share on other sites

Unfortunately I can confirm the crashing problem :(

 

I had to literally hold I down for about 30 seconds (about 200-300 queries), but eventually it crashed.

 

I'll try it with a 502 call instead of a 501 (asynchronous) and see if that helps things.

 

I hope it does, report back on any news please. Also I noticed a 505 call, so I added that on to close the request but it didn't help. Not sure if it's needed or not: 

	//_uid is from the 501/502 call
	_key = format['CHILD:505:%1:', _uid];
	_result = _key call server_hiveReadWrite;
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...