Jump to content
dlegion

[SOLVED] display client and server FPS

Recommended Posts

hi guys!
following the suggestions of great teachers around here, i did my best to search google, this forum and other forums,
and got pretty far for a noob like me. now sadly i'm at a dead end, and really dont understand where point my next step....here's the details:

i'm trying to get an FPS display on screen, so everyone can know in every moment if its the server or theyr PC slowing down (or if everything is fine!)
dont want to use hint space, already needed for mission infos.
reverse-engineered an old work of Xeno (he edited a domination for me some time ago, and allowed me to edit it, sadly now are months that i dont see him online), and got useful infos here and there in topics like this one:

...i think to be at more than 50%, having it work for client FPS, but i cant understand how a  " _this "   in the original script could have worked, since it should be local to script, and at what it was referring to! (anyway was working on original mission).
here is all the thing i have put togheter:
a script named Dfps.sqf
 

Spoiler

 while {true} do {

uiSleep 3;
disableSerialization;
private _disp = uiNamespace getVariable "d_fpsresource";
if (isNil "_disp" || {isNull _disp}) then {
	"d_fpsresource" cutRsc ["d_fpsresource", "PLAIN"];
	_disp = uiNamespace getVariable "d_fpsresource";
};
(_disp displayCtrl 50) ctrlSetText str (round _this);
(_disp displayCtrl 51) ctrlSetText str (round diag_fps);

};


 

Spoiler

 

 

a file named   Define.hpp

Spoiler

#define FontHTML			"RobotoCondensed"
#define FontM				"RobotoCondensed"
#define Dlg_ROWS			36
#define Dlg_COLS			90
#define Dlg_CONTROLHGT		((100/Dlg_ROWS)/100)
#define Dlg_COLWIDTH		((100/Dlg_COLS)/100)
#define Dlg_TEXTHGT_MOD		0.9
#define Dlg_ROWSPACING_MOD	1.3
#define Dlg_ROWHGT			(Dlg_CONTROLHGT*Dlg_ROWSPACING_MOD)
#define Dlg_TEXTHGT			(Dlg_CONTROLHGT*Dlg_TEXTHGT_MOD)
#define UILEFT				0
#define UICOMBO				4
#define DEFAULTFONT			"RobotoCondensed"

#define __GUI_BCG_RGB {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.3843])", "(profilenamespace getvariable ['GUI_BCG_RGB_G',0.7019])", "(profilenamespace getvariable ['GUI_BCG_RGB_B',0.8862])", "(profilenamespace getvariable ['GUI_BCG_RGB_A',0.7])"}
#define __GUI_TXT_RGB {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.3843])", "(profilenamespace getvariable ['GUI_BCG_RGB_G',0.7019])", "(profilenamespace getvariable ['GUI_BCG_RGB_B',0.8862])", 1}
#define __GUI_1_RGB {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.69])","(profilenamespace getvariable ['GUI_BCG_RGB_G',0.75])","(profilenamespace getvariable ['GUI_BCG_RGB_B',0.5])",1}

#define __DOM_NVER_STR__ "Domination! 3"

class RscText2 {
	type = CT_STATIC;
	idc = -1;
	x = 0;
	y = 0;
	h = 0.037;
	w = 0.3;
	style = 0;
	shadow = 1;
	colorShadow[] = {0,0,0,0.5};
	font = DEFAULTFONT;
	SizeEx = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1)";
	colorText[] = {1,1,1,1.0};
	colorBackground[] = {0,0,0,0};
	linespacing = 1;
	text = "";
};


#define __DDIALOG_BG(loc_str) \
	class BackGroundCaption: RscText2 { \
		x = 0; y = 0; \
		w = 1; h = 1 / 25; \
		colorBackground[] = __GUI_BCG_RGB; \
	}; \
	class MainCaption: RscText2 { \
		x = 0.02; y = 0; \
		w = 0.4; h = 0.04; \
		sizeEx = 0.04; \
		colorBackground[] = {1, 1, 1, 0}; \
		colorText[] = {1, 1, 1, 1}; \
		text = #loc_str; \
	}; \
	class BackGroundMain: RscText2 { \
		colorBackground[] = {0, 0, 0, 0.7}; \
		x = 0; \
		y = (1 / 25) + 0.005; \
		w = 1; \
		h = 1 - (2 / 25) - 0.01; \
	}; \
	class DomVer: RscText2 { \
		x = 0.02; y = 1 - 0.04; \
		w = 0.25; h = 0.04; \
		sizeEx = 0.04; \
		colorBackground[] = {1, 1, 1, 0}; \
		colorText[] = {1, 1, 1, 1}; \
		text = __DOM_NVER_STR__; \
	};

 



than i have a file called   RcsTitles.hpp 
 

Spoiler


class d_fpsresource {
	idd=-1;
	movingEnable=0;
	duration = 1e+011;
	fadein = 0;
	fadeout = 0;
	name="d_fpsresource";
	onLoad = "uiNamespace setVariable ['d_fpsresource', param [0]]";
	onUnLoad = "uiNamespace setVariable ['d_fpsresource', nil]";
	class controls {
		class server_cap: RscText2 {
			idc=-1;
			style="16+512";
			lineSpacing=0.95;
			text="Server FPS:";
			x = "SafeZoneX + 0.001";
			y = "SafeZoneY + SafeZoneH - 0.057";
			w=0.3;h=0.1;
			colorBackground[]={0,0,0,0};
			colorText[]={1,1,1,0.45};
			size=0.026;
			sizeEx = 0.026;
		};
		class client_cap: server_cap {
			text="Client FPS:";
			y = "SafeZoneY + SafeZoneH - 0.03";
		};
		class server_out: server_cap {
			idc = 50;
			text="";
			x = "SafeZoneX + 0.07";
		};
		class client_out: client_cap {
			idc = 51;
			text="";
			x = "SafeZoneX + 0.07";
		};
	};
};

 

as i saied, it works perfectly for client FPS, but returns an error about  Dfps.sqf  on line 10, about the " _this " not being recognized.
....in my very limited knowledge, is clear that "_this " is actually not referring to anything, but cant understand how it could have worked or with what i should replace it!
really thanks for any help!

EDIT:
forgot to say i added to description.ext

#include "define.hpp"
class RscTitles {
#include "RscTitles.hpp"
};

 

Share this post


Link to post
Share on other sites
34 minutes ago, dlegion said:

hi guys!
following the suggestions of great teachers around here, i did my best to search google, this forum and other forums

 

I typed your very thread title into google and got plenty of results that could be used as a starting point.

Especially the second result could be what you want.

 

To your question:

_this inside a function always refers to the input parameter.
 

_test = {hint str _this};

[] call _test; // -> "[]"

14 call _test; // -> "14"

Looking at your example the input is likely a scalar, if you find where the function is being called from you'll know for sure.

Could also be a locality issue with the variable passed into the dfps function not being defined on the machine it's being called.

Not enough info to know for sure.

 

Cheers

Share this post


Link to post
Share on other sites

thanks man ! i'll kook again that posts, and will search for what calls this function!
just to be sure, with function you mean the Dfps.sqf script giving the error, right?
or one of the other 2 files ?
thanks!
 

Share this post


Link to post
Share on other sites

oooook!
solved!
i added a script named   DserverFPS.sqf 
 

Spoiler

 while {true} do {
if(isDedicated) then {
//if(isServer) then {                                // seems to work to test MP editor local server
 test_broadcastServerFPS = true;
 waitUntil {
   // Send the current Server FPS to every client, stored in the variable "test_serverFPS".
   test_serverFPS = diag_fps;
   publicVariable "test_serverFPS";
   sleep 3;
 !test_broadcastServerFPS
 };
};
};

 

and changed that   " _this"   with the global variable " test_serverFPS" !
thanks guys!

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

×