Jump to content

[HOWTO] Adding a player statusBar


piX

Recommended Posts

  On 1/27/2015 at 1:21 AM, techfreaktwo said:

Yes! :) How did you do it?

((uiNamespace getVariable "osefStatusBar")displayCtrl 1000)ctrlSetText format["HEALTH: %1%2 | GRID-REF: %3 | KRYPTO: %4 | THIRST: %5%2 | HUNGER: %6%2 | ENERGY: %7", _health, "%", mapGridPosition player, EPOCH_playerCrypto, _thirst, _hunger, EPOCH_playerEnergy];
Link to comment
Share on other sites

  On 1/27/2015 at 1:22 AM, sparrow8332 said:
((uiNamespace getVariable "osefStatusBar")displayCtrl 1000)ctrlSetText format["HEALTH: %1%2 | GRID-REF: %3 | KRYPTO: %4 | THIRST: %5%2 | HUNGER: %6%2 | ENERGY: %7", _health, "%", mapGridPosition player, EPOCH_playerCrypto, _thirst, _hunger, EPOCH_playerEnergy];

So my code should look this then?

((uiNamespace getVariable "osefStatusBar")displayCtrl 1000) ctrlSetText format["FPS: %1 | PLAYERS: %2 | HEALTH: %3 | KRYPTO: %4 | HUNGER: %5%2 | THIRST: %6%2 | GRIDREF: %7 | RESTART IN: %8:%9", round diag_fps, count playableUnits, ((damage player - 1) * -100), "%", EPOCH_playerCrypto, (EPOCH_playerHunger / 5000), (EPOCH_playerThirst / 2500), mapGridPosition player, _hours, _minutes, _counter];
Link to comment
Share on other sites

No - ive corrected yours for you :-) 

((uiNamespace getVariable "osefStatusBar")displayCtrl 1000) ctrlSetText format["FPS: %1 | PLAYERS: %2 | HEALTH: %3%4 | KRYPTO: %5 | HUNGER: %6 | THIRST: %7 | GRIDREF: %8 | RESTART IN: %9:%10", round diag_fps, count playableUnits, ((damage player - 1) * -100), "%", EPOCH_playerCrypto, (EPOCH_playerHunger / 5000), (EPOCH_playerThirst / 2500), mapGridPosition player, _hours, _minutes, _counter];
Link to comment
Share on other sites

aLuWaOm.png

 

 

if you want your hunger and thirst to show correct % then add 

		_hunger = ((EPOCH_playerHunger / 5000) * 100);
		_thirst = ((EPOCH_playerThirst / 2500) * 100);

below 

		_counter = _counter - 1;
		_time = (round(180-(serverTime)/60));  //edit the '240' (60*4=240) to change the countdown timer if your server restarts are shorter or longer than 4 hour intervals
		_hours = (floor(_time/60));
		_minutes = (_time - (_hours * 60)); 

then correct your ctrlSetText so its this

((uiNamespace getVariable "osefStatusBar")displayCtrl 1000) ctrlSetText format["FPS: %1 | PLAYERS: %2 | HEALTH: %3%4 | KRYPTO: %5 | HUNGER: %6%4 | THIRST: %7%4 | GRIDREF: %8 | RESTART IN: %9:%10", round diag_fps, count playableUnits, ((damage player - 1) * -100), "%", EPOCH_playerCrypto, _hunger, _thirst, mapGridPosition player, _hours, _minutes, _counter];
Link to comment
Share on other sites

  On 1/27/2015 at 1:39 AM, sparrow8332 said:

 

No - ive corrected yours for you :-) 

((uiNamespace getVariable "osefStatusBar")displayCtrl 1000) ctrlSetText format["FPS: %1 | PLAYERS: %2 | HEALTH: %3%4 | KRYPTO: %5 | HUNGER: %6 | THIRST: %7 | GRIDREF: %8 | RESTART IN: %9:%10", round diag_fps, count playableUnits, ((damage player - 1) * -100), "%", EPOCH_playerCrypto, (EPOCH_playerHunger / 5000), (EPOCH_playerThirst / 2500), mapGridPosition player, _hours, _minutes, _counter];

 

So let me get this straight the number corresponds with the second part of the list with the %.... So if i moved the "%" to the end after _couter the variable i would use would be %10  Right?

 

Thanks for the help by the way just trying to learn :)

Link to comment
Share on other sites

  On 1/27/2015 at 1:51 AM, techfreaktwo said:

So let me get this straight the number corresponds with the second part of the list with the %.... So if i moved the "%" to the end after _couter the variable i would use would be %10  Right?

 

Thanks for the help by the way just trying to learn :)

 

no it breaks lol dont ask me why :-p just leave it where it is - it works so why move it :-)

Link to comment
Share on other sites

nah i was just using that as an example to figure it out lol

 

But yeah thanks for the help i appreciate it 

 

 

I also moved the math for damage player up as well so I have 

sleep 1;
		_counter = _counter - 1;
		_time = (round(240-(serverTime)/60));  //edit the '240' (60*4=240) to change the countdown timer if your server restarts are shorter or longer than 4 hour intervals
		_hours = (floor(_time/60));
		_minutes = (_time - (_hours * 60));
		_hunger = ((EPOCH_playerHunger / 5000) * 100);
		_thirst = ((EPOCH_playerThirst / 2500) * 100);
		_damageP = ((damage player - 1) * -100);

and 

((uiNamespace getVariable "osefStatusBar")displayCtrl 1000) ctrlSetText format["FPS: %1 | PLAYERS: %2 | HEALTH: %3%4 | KRYPTO: %5 | HUNGER: %6%4 | THIRST: %7%4 | GRIDREF: %8 | RESTART IN: %9:%10", round diag_fps, count playableUnits, _damageP, "%", EPOCH_playerCrypto, _hunger, _thirst, mapGridPosition player, _hours, _minutes, _counter];

I will test when i get home just coding on the windows tablet until i get home lol

Link to comment
Share on other sites

2:59:49 NetServer::finishDestroyPlayer(993557967): DESTROY immediately after CREATE, both cancelled

Getting this message in rpt after implementing status bar. Server not starting. Anyone have an idea? Thx in advance

Init

[] execVM "SEM.sqf";

if (isServer) then

{

fn_getBuildingstospawnLoot = compile preProcessFileLineNumbers "fn_LSgetBuildingstospawnLoot.sqf";

LSdeleter = compile preProcessFileLineNumbers "LSdeleter.sqf";

execVM "Lootspawner.sqf";

};

[] execVM "scripts\fn_statusBar.sqf";

-----------------------------------------------------------------------------------------

Decription

author = "Epoch Mod Team";

class Header

{

gameType = Sandbox;

minPlayers = 1;

maxPlayers = 100;

};

respawn = "BASE";

respawnDelay = 600;

respawnDialog = 0;

onLoadMission= "Epoch";

OnLoadIntro = "Welcome to Epoch Mod";

loadScreen = "\x\addons\a3_epoch_assets\pictures\loadScreen_ca.paa";

OnLoadIntroTime = False;

OnLoadMissionTime = False;

onLoadName = "Epoch Mod";

disabledAI = true;

scriptedPlayer = 1;

disableChannels[]={0,2,6};

enableItemsDropping = 0;

briefing = 0;

debriefing = 0;

enableDebugConsole = 0;

joinUnassigned = 0;

respawnOnStart = 0;

forceRotorLibSimulation = 2;

corpseManagerMode = 1;

corpseLimit = 10;

corpseRemovalMinTime = 1200;

corpseRemovalMaxTime = 3600;

wreckManagerMode = 1;

wreckLimit = 6;

wreckRemovalMinTime = 60;

wreckRemovalMaxTime = 360;

class CfgRemoteExecCommands {};

class RscTitles

{

#include "dialog\statusBar.hpp"

};

-------------------------------------------------------------------------------------------------------

waitUntil {!(isNull (findDisplay 46))};

disableSerialization;

/*

File: fn_statusBar.sqf

Author: Osef (Ported to EpochMod by piX)

Edited by: [piX]

Description: Puts a small bar in the bottom centre of screen to display in-game information

PLEASE KEEP CREDITS - THEY ARE DUE TO THOSE WHO PUT IN THE EFFORT!

*/

_rscLayer = "osefStatusBar" call BIS_fnc_rscLayer;

_rscLayer cutRsc["osefStatusBar","PLAIN"];

systemChat format["statusBar Loading player info...", _rscLayer];

[] spawn {

sleep 5;

_counter = 180;

_timeSinceLastUpdate = 0;

while {true} do

{

sleep 1;

_counter = _counter - 1;

_time = (round(240-(serverTime)/60)); //edit the '240' (60*4=240) to change the countdown timer if your server restarts are shorter or longer than 4 hour intervals

_hours = (floor(_time/60));

_minutes = (_time - (_hours * 60));

_hunger = ((EPOCH_playerHunger / 5000) * 100);

_thirst = ((EPOCH_playerThirst / 2500) * 100);

switch(_minutes) do

{

case 9: {_minutes = "09"};

case 8: {_minutes = "08"};

case 7: {_minutes = "07"};

case 6: {_minutes = "06"};

case 5: {_minutes = "05"};

case 4: {_minutes = "04"};

case 3: {_minutes = "03"};

case 2: {_minutes = "02"};

case 1: {_minutes = "01"};

case 0: {_minutes = "00"};

};

((uiNamespace getVariable "osefStatusBar")displayCtrl 1000) ctrlSetText format["FPS: %1 | PLAYERS: %2 | HEALTH: %3%4 | KRYPTO: %5 | HUNGER: %6%4 | THIRST: %7%4 | GRIDREF: %8 | RESTART IN: %9:%10", round diag_fps, count playableUnits, ((damage player - 1) * -100), "%", EPOCH_playerCrypto, _hunger, _thirst, mapGridPosition player, _hours, _minutes, _counter];

};

};

Also added the Status bar hpp to my folder. Dont know why de server isnt starting and shows me this meessage 2:59:49 NetServer::finishDestroyPlayer(993557967): DESTROY immediately after CREATE, both cancelled

Link to comment
Share on other sites

Here is mine - I have the status bar located under my Dedicated portion:

  Reveal hidden contents

Link to comment
Share on other sites

I added this to the server thats running wastelands just to see if it would run and it did but im getting kicked script restricton #7

7 showCommandingMenu
7 assignAs
7 playableunits !"{getplayeruid _x == _ownerVar} count playableunits" !="lbSetData[21500, _index, netId _x];\n} forEach(playableUnits - [player]); !="FPS: %1 | PLAYERS: %2 | DAMAGE: %3 | KRYPTO: %4 | HUNGER: %5 | THIRST: %6 | SOILED: %7 | GRIDREF: %8", round diag_fps, count playableUnits, damage player, EPOCH_playerCrypto, EPOCH_playerHunger, EPOCH_playerThirst, EPOCH_playerSoiled, mapGridPosition player, _counter""
7 allowDamage !="player allowDamage true;vehicle player allowDamage true;"
7 exec !="<execute expression=" !"RscDebugConsole_execute" !"execFSM" !"_executeStackedEventHandler" !"fn_execVM" !"fn_moduleExecute" !"fn_execRemote" !"fn_MPexec" !"bis_fnc_moduleExecute_activate" !"fn_tridentExecute" !"randomize_civ1" !"executed from" !"EPOCH_DebugGUI_exec" !"_handle = [_display] execVM _script;" !"execVM \"\A3\Structures_F\scripts" !="execVM \"\A3\Structures_F_EPC\Civ\PlayGround\scripts\Carousel_spin.sqf\" !="execVM \"\MPMissions\a3wasteland_v1.1.altis\addons\scripts\fn_statusBar.sqf\""
Link to comment
Share on other sites

  On 1/27/2015 at 1:22 AM, sparrow8332 said:

((uiNamespace getVariable "osefStatusBar")displayCtrl 1000)ctrlSetText format["HEALTH: %1%2 | GRID-REF: %3 | KRYPTO: %4 | THIRST: %5%2 | HUNGER: %6%2 | ENERGY: %7", _health, "%", mapGridPosition player, EPOCH_playerCrypto, _thirst, _hunger, EPOCH_playerEnergy];

Hey Sparrow thanks for your help with the other guys it got mine working...however... For hunger, health etc is says:

Health Any% | Hunger Any%

How did I manage to get that?

Link to comment
Share on other sites

  On 1/14/2015 at 1:51 PM, Ghostrider-DbD- said:

The script works very well.

 

I have had one minor issue.

 

Periodically the status bar disappears. This is solved by logging out and rejoining the server.

 

Anyone else had this problem ? Has anyone found a solution ?

 

Anyone find a fix for this issue yet?

Link to comment
Share on other sites

Wont work for me, please take a look. Thank you!

 

two first spoilers are what i have in my scripts.txt:

 

  Reveal hidden contents

7 exec !="execVM \"semClient.sqf\"" !="(_this select 0) execVM "\A3\Soft_F_Bootcamp\Offroad_01\scripts\randomize_colors.sqf"" !="<execute expression=" !"RscDebugConsole_execute" !"execFSM" !"_executeStackedEventHandler" !"fn_execVM" !"fn_moduleExecute" !"fn_execRemote" !"fn_MPexec" !"bis_fnc_moduleExecute_activate" !"fn_tridentExecute" !"randomize_civ1" !"executed from" !"EPOCH_DebugGUI_exec" !"_handle = [_display] execVM _script;" !"execVM \"\A3\Structures_F\scripts" !="execVM \"\A3\Structures_F_EPC\Civ\PlayGround\scripts\Carousel_spin.sqf\"" !="execVM \"\MPMissions\epoch.Altis\scripts\fn_statusBar.sqf\""

 

  Reveal hidden contents

7 playableunits !"{getplayeruid _x == _ownerVar} count playableunits" !="lbSetData[21500, _index, netId _x];\n} forEach(playableUnits - [player]); !="FPS: %1 | PLAYERS: %2 | DAMAGE: %3 | KRYPTO: %4 | HUNGER: %5 | THIRST: %6 | STAMINA: %7 | GRIDREF: %8 | RESTART IN: %9:%10", round diag_fps, count playableUnits, damage player, EPOCH_playerCrypto, EPOCH_playerHunger, EPOCH_playerThirst, EPOCH_playerStamina, mapGridPosition player, _hours, _minutes, _counter""

 

Last few lines in my init.sqf:

statusbar line is correct, isnt it?

 

  Reveal hidden contents
if(toLower worldName in ["chernarus","chernarus_summer"])then{
([4654.62,9593.63,0] nearestObject 145259) setDamage 1;
([4654.62,9593.63,0] nearestObject 145260) setDamage 1;
}; //Fix for something, find out ;)
 
if(hasInterface)then{execVM "semClient.sqf"};
 
[] execVM "scripts\fn_statusBar.sqf";

 

description.ext:

 

  Reveal hidden contents
class CfgRemoteExecCommands {};
class RscTitles
{
#define ST_RIGHT 0x01
 
class osefStatusBar {
idd = -1;
onLoad = "uiNamespace setVariable ['osefStatusBar', _this select 0]";
onUnload = "uiNamespace setVariable ['osefStatusBar', objNull]";
onDestroy = "uiNamespace setVariable ['osefStatusBar', objNull]";
fadein = 0;
fadeout = 0;
duration = 10e10;
movingEnable = 0;
controlsBackground[] = {};
objects[] = {};
class controls {
class statusBarText {
idc = 1000;
x = safezoneX + safezoneW - 1.75;
y = safezoneY + safezoneH - 0.04;
w = 1;
h = 0.04;
shadow = 2;
colorBackground[] = { 1, 0.3, 0, 0.0 };  // uncomment and increase 4th number to have a background
font = "PuristaSemibold";
size = 0.03;
type = 13;
style = 2;
text="Loading statusBar...";
class Attributes {
align="right";
color = "#F00000";
};
};
};
};
};

 

My fn_statusbar.sqf:

 

  Reveal hidden contents
waitUntil {!(isNull (findDisplay 46))};
disableSerialization;
/*
File: fn_statusBar.sqf
Author: Osef (Ported to EpochMod by piX)
Edited by: [piX]
Description: Puts a small bar in the bottom centre of screen to display in-game information
 
PLEASE KEEP CREDITS - THEY ARE DUE TO THOSE WHO PUT IN THE EFFORT!
 
*/
_rscLayer = "osefStatusBar" call BIS_fnc_rscLayer;
_rscLayer cutRsc["osefStatusBar","PLAIN"];
systemChat format["statusBar Loading player info...", _rscLayer];
 
[] spawn {
sleep 5;
_counter = 180;
_timeSinceLastUpdate = 0;
while {true} do
{
sleep 1;
_counter = _counter - 1;
_time = (round(240-(serverTime)/60));  //edit the '240' (60*4=240) to change the countdown timer if your server restarts are shorter or longer than 4 hour intervals
_hours = (floor(_time/60));
_minutes = (_time - (_hours * 60));
 
switch(_minutes) do
{
case 9: {_minutes = "09"};
case 8: {_minutes = "08"};
case 7: {_minutes = "07"};
case 6: {_minutes = "06"};
case 5: {_minutes = "05"};
case 4: {_minutes = "04"};
case 3: {_minutes = "03"};
case 2: {_minutes = "02"};
case 1: {_minutes = "01"};
case 0: {_minutes = "00"};
};
 
((uiNamespace getVariable "osefStatusBar")displayCtrl 1000)ctrlSetText format["FPS: %1 | PLAYERS: %2 | DAMAGE: %3 | KRYPTO: %4 | HUNGER: %5 | THIRST: %6 | STAMINA: %7 | GRIDREF: %8 | RESTART IN: %9:%10", round diag_fps, count playableUnits, damage player, EPOCH_playerCrypto, EPOCH_playerHunger, EPOCH_playerThirst, mapGridPosition player, _hours, _minutes, _counter];
}; 
};

 
What the heck am i doing wrong? I had it working before, but i had to do a clean wipe on the server for other reasons.

Cheers!
-Moody

 

 

Link to comment
Share on other sites

  On 2/4/2015 at 12:35 PM, Xeygwyn said:

Mind posting your entire fn_statusBar?

 

As requested:

 

  Reveal hidden contents
waitUntil {!(isNull (findDisplay 46))};
disableSerialization;
/*
File: fn_statusBar.sqf
Author: Osef (Ported to EpochMod by piX)
Edited by: [piX]
Description: Puts a small bar in the bottom centre of screen to display in-game information
 
PLEASE KEEP CREDITS - THEY ARE DUE TO THOSE WHO PUT IN THE EFFORT!
 
*/
_rscLayer = "osefStatusBar" call BIS_fnc_rscLayer;
_rscLayer cutRsc["osefStatusBar","PLAIN"];
systemChat format["statusBar Loading player info...", _rscLayer];
 
[] spawn {
sleep 5;
_counter = 180;
_timeSinceLastUpdate = 0;
while {true} do
{
sleep 1;
_counter = _counter - 1;
_time = (round(180-(serverTime)/60));  //edit the '240' (60*4=240) to change the countdown timer if your server restarts are shorter or longer than 4 hour intervals
_hours = (floor(_time/60));
_minutes = (_time - (_hours * 60));
 
switch(_minutes) do
{
case 9: {_minutes = "09"};
case 8: {_minutes = "08"};
case 7: {_minutes = "07"};
case 6: {_minutes = "06"};
case 5: {_minutes = "05"};
case 4: {_minutes = "04"};
case 3: {_minutes = "03"};
case 2: {_minutes = "02"};
case 1: {_minutes = "01"};
case 0: {_minutes = "00"};
};
 
((uiNamespace getVariable "osefStatusBar")displayCtrl 1000)ctrlSetText format["HEALTH: %1%2 | GRID-REF: %3 | KRYPTO: %4 | THIRST: %5%2 | HUNGER: %6%2 | ENERGY: %7", _health, "%", mapGridPosition player, EPOCH_playerCrypto, _thirst, _hunger, EPOCH_playerEnergy];
}; 
};

Link to comment
Share on other sites

I need serious help here, i've tried for DAYS with no luck. I have followed this installation process step by step, idk 10 times(?). Still no statusbar loading on my server.

 

I can join the server, no script restrictions at all, no errors what so ever. SEM Missions runs smoothly, but this statusbar is killing me.

 

fn_statusbar is located inside scripts  folder and statusbar.hpp in my dialog folder in my epoch.altis.pbo.

 

My files are uploaded

 

Thank you so much, i hope you are able to help me figuring this out! Its killing me, idk what to do anymore. I have tried everything i am capable of. My skills in this modding/scripting doesnt go any further, i need pro help.

 

Cheers!

 

 

fn_statusBar.txt

description.txt

init.txt

statusBar.txt

Link to comment
Share on other sites

  On 2/9/2015 at 6:30 PM, Moody said:

I need serious help here, i've tried for DAYS with no luck. I have followed this installation process step by step, idk 10 times(?). Still no statusbar loading on my server.

 

I can join the server, no script restrictions at all, no errors what so ever. SEM Missions runs smoothly, but this statusbar is killing me.

 

fn_statusbar is located inside scripts  folder and statusbar.hpp in my dialog folder in my epoch.altis.pbo.

 

My files are uploaded

 

Thank you so much, i hope you are able to help me figuring this out! Its killing me, idk what to do anymore. I have tried everything i am capable of. My skills in this modding/scripting doesnt go any further, i need pro help.

 

Cheers!

Not a pro, very much a noob sill, but...From first glance at your description.ext file, it's all wrong. Take a look at the very first post in this thread. Scroll down for what to add in that file. All I did was downloaded the .zip, unpacked, followed the instructions and it worked the first time.

Link to comment
Share on other sites

  On 2/9/2015 at 7:01 PM, cyncrwler said:

Not a pro, very much a noob sill, but...From first glance at your description.ext file, it's all wrong. Take a look at the very first post in this thread. Scroll down for what to add in that file. All I did was downloaded the .zip, unpacked, followed the instructions and it worked the first time.

Edited description to the same as it says in OP, still no bar=/

Link to comment
Share on other sites

Not sure what would be going on if you did everything exactly as stated in the instructions. Somehow I believe you must have missed something, as is evidenced in what was placed in the description.ext file.

 

Try placing this

[] execVM "scripts\fn_statusBar.sqf";

at the top of your init. All you need to do is make sure all the pieces are in the right places. Sometimes hammering away at something like this will give you blinders after a while, and you can't see the mistake anymore. Once you get to that point, you need to take a break, and walk away for a while, and then come back to it with fresh eyes.

Link to comment
Share on other sites

  On 2/9/2015 at 7:26 PM, cyncrwler said:

Not sure what would be going on if you did everything exactly as stated in the instructions. Somehow I believe you must have missed something, as is evidenced in what was placed in the description.ext file.

 

Try placing this

[] execVM "scripts\fn_statusBar.sqf";

at the top of your init. All you need to do is make sure all the pieces are in the right places. Sometimes hammering away at something like this will give you blinders after a while, and you can't see the mistake anymore. Once you get to that point, you need to take a break, and walk away for a while, and then come back to it with fresh eyes.

 

pasted that line under the one i have, its the same. Can u see anything else beeing wrong in my init file, that might make it not load?

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
×
×
  • Create New...