Jump to content
Sign in to follow this  
General McTavish

Spectating Player Issue

Recommended Posts

I am trying to implement a spectate script that will run when double-clicking a player in a RscTree.

Now it works fine for static information such as UID, name etc, but i am unsure the best approach to make it "live" (I.E. will update if the player gets in a vehicle or changes weapon)

 

With weapon

https://i.gyazo.com/3fa65603994ee8e2c20b16e4de78da8f.jpg

 

Without 

https://i.gyazo.com/1117b84ba1c8e739d9006dd4c5b9bcf2.jpg

 

Code

private["_unit"];

_display = findDisplay 46;
_unit = tvData[9803,tvCurSel (9803)];
_unit = call compile format["%1", _unit];
_uid = getPlayerUID _unit;
_veh = vehicle _unit;

//Checks
if (isNil "_unit") exitWith {};
if (isNull _unit) exitWith {};
/*if (_unit == player) exitWith {["You can't do that dumbass.",true,"fast"] call RR_fnc_notificationSystem;};*/


[] spawn {
  while {dialog} do {
   closeDialog 0;
   uisleep 0.01;
  };
};

//Player Info
_ctrlText = '<t align=''left'' size=''0.9'' shadow=''2'' color=''#FFFFFF''>Spectating - F9 to show inventory, F10 to exit/stop spectating</t><br/>';
_info = format["Spectating Player: %1 (%2) %3",name _unit, _uid, _veh];
_ctrlText = _ctrlText + '<t align=''left'' shadow=''2'' size=''1.1'' color=''#11e602''>'+_info +'</t>';

//Weapon Info
_type = currentWeapon _unit;
_cammo = _veh ammo _type;
_pic = getText(configFile >> "CfgWeapons" >> _type >> "picture");
_displayName = getText(configFile >> "CfgWeapons" >> _type >> "displayName");
_info = format ["%1 (%2)",_displayName, _cammo];
_ctrlWep = '<img image='''+_pic+''' align=''left'' shadow=''2'' size=''1''/><t align=''left'' shadow=''2'' size=''1.1'' color=''#e68a00''>'+_info+'</t>';


//Controls
_ctrl = _display ctrlCreate ["RscStructuredText",6969];
_ctrl ctrlSetPosition [0.041094 * safezoneW + safezoneX, 0.071 * safezoneH + safezoneY, 0.3 * safezoneW, 0.055 * safezoneH];
_ctrl ctrlCommit 0;
_ctrl ctrlSetStructuredText parseText _ctrlText;

_wep = _display ctrlCreate ["RscStructuredText",6970];
_wep ctrlSetPosition [0.0410937 * safezoneW + safezoneX, 0.126 * safezoneH + safezoneY, 0.4 * safezoneW, 0.055 * safezoneH];
_wep ctrlCommit 0;

if ((_displayname != "")) then {
    _wep ctrlSetStructuredText parseText _ctrlWep;
    
  } else {

    _wep ctrlSetStructuredText parseText "";
};

//Spectate Camera
_unit switchCamera "INTERNAL";[format["You are now spectating %1 Press F10 to stop Spectating.",_unit getVariable ["playername", "Unknown Player"]],true,"fast"] call RR_fnc_notificationSystem;

AM_Exit = (findDisplay 46) displayAddEventHandler 
["KeyDown","if ((_this select 1) == 68) then {(findDisplay 46) displayRemoveEventHandler ['KeyDown',AM_Exit];
ctrlDelete ((findDisplay 46) displayCtrl 6969);
ctrlDelete ((findDisplay 46) displayCtrl 6970);
player switchCamera 'INTERNAL';[""You have stopped spectating"",true,""fast""] call RR_fnc_notificationSystem;};false"];

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×