Advertisement
secondcoming

statusBar.sqf

Mar 15th, 2016
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 12.21 KB | None | 0 0
  1. /*
  2.     @file Version: 0.1
  3.     @file Name: statusBar.sqf
  4.     @file  EpochMod StatusBar Port for Wasteland / EXILE by CRE4MPIE
  5.     @file Created: 21/4/2015
  6.     @notes: Added custom Icons and ported Wasteland info. Still
  7.             needs to be cleaned up a bit.
  8. */
  9.  
  10. waitUntil {!(isNull (findDisplay 46))};
  11. disableSerialization;
  12.  
  13.     _rscLayer = "osefStatusBarAdmin" call BIS_fnc_rscLayer;
  14.     _rscLayer cutRsc["osefStatusBarAdmin","PLAIN"];
  15. //  systemChat format["StatusBar Initialized", _rscLayer];
  16.     [] spawn
  17.     {
  18.  
  19.         uiSleep 5;
  20.         //set the color values.
  21.         //Additional color codes can be found here:  http://html-color-codes.com/
  22.         _colourDefault  = parseText "#adadad"; //set your default colour here
  23.         _colour108      = parseText "#FF7000";
  24.         _colour107      = parseText "#FF9000";
  25.         _colour106      = parseText "#FFBB00";
  26.         _colour105      = parseText "#FFCC00";
  27.         _colour104      = parseText "#81CCDD";
  28.         _colour103      = parseText "#33AACC";
  29.         _colour102      = parseText "#3388CC";
  30.         _colour101      = parseText "#3366CC";
  31.         _colour100      = parseText "#336600";
  32.         _colour90       = parseText "#339900";
  33.         _colour80       = parseText "#33CC00";
  34.         _colour70       = parseText "#33FF00";
  35.         _colour60       = parseText "#66FF00";
  36.         _colour50       = parseText "#CCFF00";
  37.         _colour40       = parseText "#CCCC00";
  38.         _colour30       = parseText "#CC9900";
  39.         _colour20       = parseText "#CC6600";
  40.         _colour10       = parseText "#CC3300";
  41.         _colour0        = parseText "#CC0000";
  42.         _colourDead     = parseText "#000000";
  43.         _uid = getPlayerUID player;
  44.    
  45.        
  46.     while {true} do
  47.     {
  48.    
  49.         uiSleep 1;
  50.                
  51.         //moved the creation of the status bar inside the loop and create it if it is null,
  52.         //this is to handle instance where the status bar is disappearing
  53.         if(isNull ((uiNamespace getVariable "osefStatusBarAdmin")displayCtrl 55554)) then
  54.         {
  55.             diag_log "statusbar is null create";
  56.             disableSerialization;
  57.             _rscLayer = "osefStatusBarAdmin" call BIS_fnc_rscLayer;
  58.             _rscLayer cutRsc["osefStatusBarAdmin","PLAIN"];
  59.         };     
  60.        
  61.         //initialize variables and set values
  62.         _players = count playableUnits;
  63.         _unit = _this select 0;
  64.         _damage = round ((1 - (damage player)) * 100);
  65.         //_damage = (round(_damage * 100));
  66.         _hunger = round (ExileClientPlayerAttributes select 2);
  67.         _thirst = round (ExileClientPlayerAttributes select 3);
  68.         _bodyTemp = round (ExileClientPlayerAttributes select 5);
  69.         _ambientTemp = [ExileClientEnvironmentTemperature, 1] call ExileClient_util_math_round;
  70.         _wallet = ExileClientPlayerMoney;
  71.         _stamina = ExileClientPlayerScore;
  72.         _energy = 100;
  73.         _energyPercent = 100;
  74.         _serverFPS = round diag_fps;
  75.         _pos = getPosATL player;
  76.         _dir = round (getDir (vehicle player));
  77.         _grid = mapGridPosition  player;
  78.         _xx = (format[_grid]) select  [0,3];
  79.         _yy = (format[_grid]) select  [3,3];
  80.        
  81.         _time = timeToNextRestart;
  82.        
  83.         if (isNil "timeToNextRestart") then
  84.         {
  85.             _time = (round(240-(serverTime)/60));  //edit the '240' value (60*4=240) to change the countdown timer if your server restarts are shorter or longer than 4 hour intervals
  86.         };
  87.  
  88.         _hours = (floor(_time/60));
  89.         _minutes = (_time - (_hours * 60));
  90.        
  91.         _radiation = ExilePlayerRadiation;
  92.         if (isNil "ExilePlayerRadiation") then
  93.         {
  94.             _radiation = 0;
  95.         };     
  96.        
  97.         _statusRadiation = round (_radiation*100);
  98.        
  99.         switch(_minutes) do
  100.     {
  101.         case 9: {_minutes = "09"};
  102.         case 8: {_minutes = "08"};
  103.         case 7: {_minutes = "07"};
  104.         case 6: {_minutes = "06"};
  105.         case 5: {_minutes = "05"};
  106.         case 4: {_minutes = "04"};
  107.         case 3: {_minutes = "03"};
  108.         case 2: {_minutes = "02"};
  109.         case 1: {_minutes = "01"};
  110.         case 0: {_minutes = "00"};
  111.     };
  112.        
  113.        
  114.                
  115.         //Colour coding
  116.         //Damage
  117.            
  118.         _colourDamage = _colourDefault;
  119.         if(_damage >= 100) then{_colourDamage = _colour100;};
  120.         if((_damage >= 90) && (_damage < 100)) then {_colourDamage =  _colour100;};
  121.         if((_damage >= 80) && (_damage < 90)) then {_colourDamage =  _colour80;};
  122.         if((_damage >= 70) && (_damage < 80)) then {_colourDamage =  _colour70;};
  123.         if((_damage >= 60) && (_damage < 70)) then {_colourDamage =  _colour60;};
  124.         if((_damage >= 50) && (_damage < 60)) then {_colourDamage =  _colour50;};
  125.         if((_damage >= 40) && (_damage < 50)) then {_colourDamage =  _colour40;};
  126.         if((_damage >= 30) && (_damage < 40)) then {_colourDamage =  _colour30;};
  127.         if((_damage >= 20) && (_damage < 30)) then {_colourDamage =  _colour20;};
  128.         if((_damage >= 10) && (_damage < 20)) then {_colourDamage =  _colour10;};
  129.         if((_damage >= 1) && (_damage < 10)) then {_colourDamage =  _colour0;};
  130.         if(_damage < 1) then{_colourDamage =  _colourDead;};
  131.        
  132.         //Radiation        
  133.         _colourRadiation = _colour60;
  134.         if(isNil "_statusRadiation") then {_statusRadiation = 0; };
  135.         if(_statusRadiation >= 100) then{_colourRadiation = _colour0;};
  136.         if((_statusRadiation >= 90) && (_statusRadiation < 100)) then {_colourRadiation =  _colour0;};
  137.         if((_statusRadiation >= 80) && (_statusRadiation < 90)) then {_colourRadiation =  _colour20;};
  138.         if((_statusRadiation >= 70) && (_statusRadiation < 80)) then {_colourRadiation =  _colour30;};
  139.         if((_statusRadiation >= 60) && (_statusRadiation < 70)) then {_colourRadiation =  _colour40;};
  140.         if((_statusRadiation >= 50) && (_statusRadiation < 60)) then {_colourRadiation =  _colour40;};
  141.         if((_statusRadiation >= 40) && (_statusRadiation < 50)) then {_colourRadiation =  _colour40;};
  142.         if((_statusRadiation >= 30) && (_statusRadiation < 40)) then {_colourRadiation =  _colour40;};
  143.         if((_statusRadiation >= 20) && (_statusRadiation < 30)) then {_colourRadiation =  _colour40;};
  144.         if((_statusRadiation >= 10) && (_statusRadiation < 20)) then {_colourRadiation =  _colour40;};
  145.         if((_statusRadiation >= 1) && (_statusRadiation < 10)) then {_colourRadiation =  _colour50;};
  146.         if(_statusRadiation < 1) then{_colourRadiation =  _colour60;};
  147.        
  148.        
  149.        
  150.         //Hunger
  151.         _colourHunger = _colourDefault;
  152.         if(_hunger >= 100) then{_colourHunger = _colour100;};
  153.         if((_hunger >= 90) && (_hunger < 100)) then {_colourHunger =  _colour90;};
  154.         if((_hunger >= 80) && (_hunger < 90)) then {_colourHunger =  _colour80;};
  155.         if((_hunger >= 70) && (_hunger < 80)) then {_colourHunger =  _colour70;};
  156.         if((_hunger >= 60) && (_hunger < 70)) then {_colourHunger =  _colour60;};
  157.         if((_hunger >= 50) && (_hunger < 60)) then {_colourHunger =  _colour50;};
  158.         if((_hunger >= 40) && (_hunger < 50)) then {_colourHunger =  _colour40;};
  159.         if((_hunger >= 30) && (_hunger < 40)) then {_colourHunger =  _colour30;};
  160.         if((_hunger >= 20) && (_hunger < 30)) then {_colourHunger =  _colour20;};
  161.         if((_hunger >= 10) && (_hunger < 20)) then {_colourHunger =  _colour10;};
  162.         if((_hunger >= 1) && (_hunger < 10)) then {_colourHunger =  _colour0;};
  163.         if(_hunger < 1) then{_colourHunger =  _colourDead;};
  164.        
  165.                
  166.         //Thirst
  167.         _colourThirst = _colourDefault;    
  168.         switch true do{
  169.        
  170.             case(_thirst >= 100) : {_colourThirst = _colour101;};
  171.             case((_thirst >= 90) && (_thirst < 100)) :  {_colourThirst =  _colour102;};
  172.             case((_thirst >= 80) && (_thirst < 90)) :  {_colourThirst =  _colour103;};
  173.             case((_thirst >= 70) && (_thirst < 80)) :  {_colourThirst =  _colour104;};
  174.             case((_thirst >= 60) && (_thirst < 70)) :  {_colourThirst =  _colour105;};
  175.             case((_thirst >= 50) && (_thirst < 60)) :  {_colourThirst =  _colour106;};
  176.             case((_thirst >= 40) && (_thirst < 50)) :  {_colourThirst =  _colour107;};
  177.             case((_thirst >= 30) && (_thirst < 40)) :  {_colourThirst =  _colour108;};
  178.             case((_thirst >= 20) && (_thirst < 30)) :  {_colourThirst =  _colour20;};
  179.             case((_thirst >= 10) && (_thirst < 20)) :  {_colourThirst =  _colour10;};
  180.             case((_thirst >= 1) && (_thirst < 10)) :  {_colourThirst =  _colour0;};
  181.             case(_thirst < 1) : {_colourThirst =  _colourDead;};
  182.         };
  183.        
  184.         //Temperature
  185.         _colourTemp = _colourDefault;
  186.         //if(_bodyTemp >= 37) then{_colourTemp = _colour100;};
  187.         if((_bodyTemp >= 32) && (_bodyTemp < 33)) then {_colourTemp =  _colour101;};       
  188.         if((_bodyTemp >= 33) && (_bodyTemp < 34)) then {_colourTemp =  _colour101;};
  189.         if((_bodyTemp >= 34) && (_bodyTemp < 35)) then {_colourTemp =  _colour101;};
  190.         if((_bodyTemp >= 35) && (_bodyTemp < 36)) then {_colourTemp =  _colour103;};
  191.         if((_bodyTemp >= 36) && (_bodyTemp < 37)) then {_colourTemp =  _colour104;};
  192.         if((_bodyTemp >= 37) && (_bodyTemp < 38)) then {_colourTemp =  _colour100;};
  193.         if((_bodyTemp >= 38) && (_bodyTemp < 39)) then {_colourTemp =  _colour20;};
  194.         if((_bodyTemp >= 39) && (_bodyTemp < 40)) then {_colourTemp =  _colour20;};
  195.         if((_bodyTemp >= 40) && (_bodyTemp < 41)) then {_colourTemp =  _colour10;};
  196.         if((_bodyTemp >= 41) && (_bodyTemp < 42)) then {_colourTemp =  _colour10;};
  197.         if((_bodyTemp >= 42) && (_bodyTemp < 43)) then {_colourTemp =  _colour0;};
  198.         if(_bodyTemp < 30) then{_colourTemp =  _colourDead;};
  199.        
  200.        
  201.        
  202.         //Energy
  203.         _colourEnergy = _colourDefault;
  204.         if(_energyPercent >= 100) then{_colourEnergy = _colour100;};
  205.         if((_energyPercent >= 90) && (_energyPercent < 100)) then {_colourEnergy =  _colour90;};
  206.         if((_energyPercent >= 80) && (_energyPercent < 90)) then {_colourEnergy =  _colour80;};
  207.         if((_energyPercent >= 70) && (_energyPercent < 80)) then {_colourEnergy =  _colour70;};
  208.         if((_energyPercent >= 60) && (_energyPercent < 70)) then {_colourEnergy =  _colour60;};
  209.         if((_energyPercent >= 50) && (_energyPercent < 60)) then {_colourEnergy =  _colour50;};
  210.         if((_energyPercent >= 40) && (_energyPercent < 50)) then {_colourEnergy =  _colour40;};
  211.         if((_energyPercent >= 30) && (_energyPercent < 40)) then {_colourEnergy =  _colour30;};
  212.         if((_energyPercent >= 20) && (_energyPercent < 30)) then {_colourEnergy =  _colour20;};
  213.         if((_energyPercent >= 10) && (_energyPercent < 20)) then {_colourEnergy =  _colour10;};
  214.         if((_energyPercent >= 1) && (_energyPercent < 10)) then {_colourEnergy =  _colour0;};
  215.         if(_energyPercent < 1) then{_colourEnergy =  _colour0;};
  216.        
  217.        
  218.         //Stamina
  219.         _colourStamina = _colourDefault;
  220.        
  221.         //display the information
  222.         ((uiNamespace getVariable "osefStatusBarAdmin")displayCtrl 55554)ctrlSetStructuredText parseText
  223.             format["<img align='left' size='2.5' shadow='0' image='custom\statusBar\icons\serverlogo.paa' />           
  224.             <t shadow='1' shadowColor='#000000' color='%10'> ExileYorkshire.co.uk </t>
  225.             <t shadow='1' shadowColor='#000000' color='%11'><img size='1.0'  shadowColor='#000000' image='custom\statusBar\icons\health.paa' color='%11'/> %3%1</t>
  226.             <t shadow='1' shadowColor='#000000' color='%21'><img size='1.6'  shadowColor='#000000' image='custom\statusBar\icons\thermostat.paa' color='%23'/> %22</t>
  227.             <t shadow='1' shadowColor='#000000' color='%21'><img size='1.6'  shadowColor='#000000' image='custom\statusBar\icons\snowflake.paa' color='%11'/> %24</t>          
  228.             <t shadow='1' shadowColor='#000000' color='%12'><img size='1.6'  shadowColor='#000000' image='custom\statusBar\icons\hunger.paa' color='%12'/> %5%1</t>
  229.             <t shadow='1' shadowColor='#000000' color='%13'><img size='1.6'  shadowColor='#000000' image='custom\statusBar\icons\thirst.paa' color='%13'/> %6%1</t>
  230.             <t shadow='1' shadowColor='#000000' color='%21'><img size='1.5'  shadowColor='#000000' image='custom\statusBar\icons\radiation.paa' color='%21'/> %20%1</t>            
  231.             <t shadow='1' shadowColor='#000000' color='%10'><img size='1.0'  shadowColor='#000000' image='custom\statusBar\icons\poptab_ca.paa' color='%10'/> %4</t>
  232.             <t shadow='1' shadowColor='#000000' color='%15'><img size='1.0'  shadowColor='#000000' image='custom\statusBar\icons\exile.paa' color='%10'/> %9</t>           
  233.             <t shadow='1' shadowColor='#000000' color='%15'><img size='1.0'  shadowColor='#000000' image='custom\statusBar\icons\compass.paa' color='%10'/> %16</t>
  234.             <t shadow='1' shadowColor='#000000' color='%10'><img size='1.6'  shadowColor='#000000' image='custom\statusBar\icons\players.paa' color='%10'/> %2</t>
  235.             <t shadow='1' shadowColor='#000000' color='%10'><img size='1.6'  shadowColor='#000000' image='custom\statusBar\icons\restart.paa' color='%10'/>Restart in: %18h%19m</t>",
  236.            
  237.                     "%",
  238.                     _players,
  239.                     _damage,
  240.                     _wallet,
  241.                     _hunger,
  242.                     _thirst,
  243.                     _serverFPS,
  244.                     _energyPercent,
  245.                     _stamina,
  246.                     _colourDefault,
  247.                     _colourDamage,
  248.                     _colourHunger,
  249.                     _colourThirst,
  250.                     _colourEnergy,
  251.                     _colourStamina,
  252.                     format["%1/%2",_xx,_yy],
  253.                     _dir,
  254.                     _hours,
  255.                     _minutes,
  256.                     _statusRadiation,
  257.                     _colourRadiation,
  258.                     _bodyTemp,
  259.                     _colourTemp,
  260.                     _ambientTemp
  261.                 ];
  262.        
  263.         };
  264. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement