Skip to content

Commit

Permalink
First release
Browse files Browse the repository at this point in the history
  • Loading branch information
Cultti committed Jul 27, 2014
0 parents commit 090eda3
Show file tree
Hide file tree
Showing 8 changed files with 268 additions and 0 deletions.
1 change: 1 addition & 0 deletions $PBOPREFIX$
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CULTTI_ShowPlayers
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# ShowPlayers A2 Addon
Addon will add button into cba FlexiMenu(aka Interaction Menu) that allow players to check who is inside current vehicle in which seat. Team member names are colored with corresponding colors and other than team members are in grayish. In addition addon shows current taken seats/maximium available seats in this vehicle.
16 changes: 16 additions & 0 deletions config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class CfgPatches
{
class Cultti_ShowPlayers
{
units[] = {};
weapons[] = {};
requiredVersion = 1.0;
requiredAddons[] = {"Extended_EventHandlers"};

};
};

class Extended_PostInit_EventHandlers
{
CULTTI_ShowPlayers_Post_Init = "CULTTI_ShowPlayers_Post_Init_Var = [] execVM ""\CULTTI_ShowPlayers\init.sqf""";
};
33 changes: 33 additions & 0 deletions fnc_ColorUnit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
private
[
"_unit"
];

_unit = _this;
_txt = "";

if(_unit in (units player)) then {
_team = assignedTeam _unit;
switch(_team) do {
case("MAIN"): {
_txt = format["<t color='#FFFFFF'>%1</t>", name _unit];
};
case("RED"): {
_txt = format["<t color='#f8abb1'>%1</t>", name _unit];
};
case("GREEN"): {
_txt = format["<t color='#a8ffb9'>%1</t>", name _unit];
};
case("BLUE"): {
_txt = format["<t color='#aeacf5'>%1</t>", name _unit];
};
case("YELLOW"): {
_txt = format["<t color='#fbff97'>%1</t>", name _unit];
};
};
}
else {
_txt = format["<t color='#8C8C8C'>%1</t>", name _unit];
};

_txt
79 changes: 79 additions & 0 deletions fnc_GetAllTurretPaths.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*******************************************************************************
* Project: Mushi
* Module: fnc_GetAllTurretPaths.sqf
* Project version: [1.0.0] 20.03.2014
* Module version: [1] 20.03.2014
* Author: RAB, Prodavec, Marbot, DumbkRat, SPESNAZ
* Function: fnc_GetAllTurretPaths
* Comments: --//--
*******************************************************************************/

/*
INPUT:
vehicle : OBJECT
OUTPUT:
paths_array : ARRAY
EXAMPLE:
_allPaths = MyTank call fnc_GetAllTurretPaths;
// _allPaths: [[0], [0,0], [0,1]]
*/

private
[
"_result",
"_vehicle",
"_currentNode",
"_depth",
"_currentConfig",
"_cfgTurrets"
];

_result = [];

if ((!isNil "_this") && {(typeName _this) in ["ARRAY", "OBJECT"]}) then
{
_vehicle = objNull;
_currentNode = [];
_depth = -1;
_currentConfig = objNull;

switch (typeName _this) do
{
case "ARRAY":
{
if ((count _this) == 5) then
{
_vehicle = _this select 0;
_currentConfig = _this select 1;
_currentNode = _this select 2;
_depth = _this select 3;
_result = _this select 4;
};
};
case "OBJECT":
{
_vehicle = _this;
_currentConfig = configFile >> "CfgVehicles" >> (typeOf _vehicle);
_depth = 0;
};
};

if ((!isNil "_vehicle") && (!isNil "_currentNode") && (!isNil "_depth") && (!isNil "_result") && (!isNil "_currentConfig") && {((typeName _vehicle) == "OBJECT") && ((typeName _currentNode) == "ARRAY") && ((typeName _depth) == "SCALAR") && ((typeName _result) == "ARRAY") && ((typeName _currentConfig) == "CONFIG")} && {!isNull _vehicle}) then
{
_cfgTurrets = _currentConfig >> "Turrets";

if (isClass _cfgTurrets) then
{
for "_i" from 0 to ((count _cfgTurrets) - 1) step 1 do
{
_currentNode set [_depth, _i];
_result set [count _result, +_currentNode];
[_vehicle, _cfgTurrets select _i, _currentNode, _depth + 1, _result] call fnc_GetAllTurretPaths;
};
};
};
};

_result;
7 changes: 7 additions & 0 deletions fnc_menu.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
_menu = [
["main", "test", "popup"],
[
["Show players","[cursorTarget] execVM '\CULTTI_ShowPlayers\showPlayers.sqf'","", "", "", -1, 1, 1]
]
];
_menu
6 changes: 6 additions & 0 deletions init.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
sleep 5; //wait for start

waitUntil {!isNil "ace_sys_interaction_key_self"}; //wait for start
waitUntil {!isNil "ace_sys_interaction_key"}; //wait for start

["AllVehicles", [ace_sys_interaction_key], -20, ["\CULTTI_ShowPlayers\fnc_menu.sqf", "main"]] call CBA_ui_fnc_add;
124 changes: 124 additions & 0 deletions showPlayers.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
private
[
"_temp",
"_target",
"_cargo",
"_driver",
"_commander",
"_turretPaths",
"_turret",
"_txt"
];

_target = _this select 0;

if( isNull _target or vehicle player != player ) then {
_target = vehicle player;
};


/*
_players = "Players inside vehicle:";
_txt = "";
{
if( _x == player) then {
}
else {
if(_x in (units player)) then {
//_txt = format["<t color='#FF0000'>%1</t>", name _x];
_team = assignedTeam _x;
switch(_team) do {
case("MAIN"): {
_txt = format["<t color='#FFFFFF'>%1</t>", name _x];
};
case("RED"): {
_txt = format["<t color='#f8abb1'>%1</t>", name _x];
};
case("GREEN"): {
_txt = format["<t color='#a8ffb9'>%1</t>", name _x];
};
case("BLUE"): {
_txt = format["<t color='#aeacf5'>%1</t>", name _x];
};
case("YELLOW"): {
_txt = format["<t color='#fbff97'>%1</t>", name _x];
};
};
}
else {
_txt = format["<t color='#8C8C8C'>%1</t>", name _x];
};
_role = assignedVehicleRole _x select 0;
if(_role != "CARGO") then {
_txt = format["%1(%2)", _txt, _role];
};
_players = format["%1 <br/> %2", _players, _txt];
};
} forEach crew _target;
*/

fnc_GetAllTurretPaths = compile preprocessFile "\CULTTI_ShowPlayers\fnc_GetAllTurretPaths.sqf";
fnc_ColorUnit = compile preprocessFile "\CULTTI_ShowPlayers\fnc_ColorUnit.sqf";
_temp = "";
_max = getNumber(configFile >> "CfgVehicles" >> TypeOf _target >> "transportSoldier");

if(getNumber(configFile >> "CfgVehicles" >> TypeOf _target >> "hasCommander") == 1) then {
_max = _max + 1;
};
if(getNumber(configFile >> "CfgVehicles" >> TypeOf _target >> "hasDriver") == 1) then {
_max = _max + 1;
};

_txt = "Players:";

_cargo = crew _target;
_driver = driver _target;
_commander = commander _target;
_turretPaths = _target call fnc_GetAllTurretPaths;

_max = _max + count _turretPaths;

_turret = [];
{
_temp = _target turretUnit _x;
if( !isNull _temp ) then {
_turret = _turret + [_temp];
};
} forEach _turretPaths;
_turret = _turret - [_commander];

_cargo = _cargo - [_driver, _commander] - _turret;

_current = 0;

if( !isNull _driver ) then {
_current = _current + 1;
};
if( !isNull _commander ) then {
_current = _current + 1;
};

_current = _current + count _turret + count _cargo;

_txt = format["%1 %2/%3", _txt, _current, _max];

if( !isNull _driver ) then {
_txt = format["%1<br/>%2(Driver)", _txt, _driver call fnc_ColorUnit];
};

if( !isNull _commander ) then {
_txt = format["%1<br/>%2(Commander)", _txt, _commander call fnc_ColorUnit];
};
if ( !(count _turret == 0)) then {
{
_txt = format["%1<br/>%2(Turret)", _txt, _x call fnc_ColorUnit];
} forEach _turret;
};
if( !(count _cargo == 0)) then {
{
_txt = format["%1<br/>%2", _txt, _x call fnc_ColorUnit];
} forEach _cargo;
};


hintSilent parseText format["%1", _txt];

0 comments on commit 090eda3

Please sign in to comment.