[snippet] Fps Label

Started by DizzasTeR, Aug 13, 2016, 03:08 PM

Previous topic - Next topic

DizzasTeR

Just wanted to code something D:
/* Things you don't have to deal with */
sW <- GUI.GetScreenSize().X;
sH <- GUI.GetScreenSize().Y;
FPSLimit <- 37;
FPSMax <- 1;
FPSCalc <- 0;
FPSTime <- 0;
_Gui_FPS <- null;
/**************************************/
// -- \\
/* Things you can deal with */
FPS_Scale <- sH / 51;
FPS_Alpha <- 255;
FPS_Font <- "Tahoma"; /* Tohama, Lucida Console, Verdana */
FPS_TextColor <- Colour( 255, 255, 255 );
/**************************************/

function Script::ScriptLoad() {
if( !_Gui_FPS ) {
::FPSLimit = 255 / ::FPSLimit;
::_Gui_FPS = GUILabel( VectorScreen( ( sW * 0.95 ) - ( FPS_Scale ), sH * 0.95 ), Colour( 255, 255, 255, 255 ), "FPS: 0" );
::_Gui_FPS.FontSize = ::FPS_Scale;
::_Gui_FPS.FontName = ::FPS_Font;
::FPSCalc = 0;
::FPSTime = Script.GetTicks() + 1000;
}
}

function Script::ScriptProcess() {
if( ::_Gui_FPS ) {
if ( Script.GetTicks() < ::FPSTime ) {
::FPSCalc = FPSCalc + 1
}
else {
if ( ::FPSCalc > ::FPSMax ) {
::FPSLimit = 255 / ::FPSCalc;
::FPSMax = FPSCalc;
}

::_Gui_FPS.Text = "FPS: " + ::FPSCalc;
::_Gui_FPS.FontSize = ::FPS_Scale;
::_Gui_FPS.Alpha = ::FPS_Alpha;
::_Gui_FPS.TextColor = ::FPS_TextColor;
::FPSCalc = 0
::FPSTime = Script.GetTicks() + 1000
}
}
}

[Spoiler=Screenshot]
-> At the lower right
[/Spoiler]

:edit: Just wanted to mention that the position is totally relative along with relative font size, which means its gonna fit exactly the same on all resolutions and exactly the same sized on all resolution. The base resolution used was 1280x1024, it will work on lowest to highest

MatheuS

if( !sucess ) tryAgain();
Thanks to the VCMP community. It was the happiest period of my life.

Luis_Labarca

Thank you friend good job :)
My server RP
IP: 51.222.28.159:8194

Ankris

It's me or this snippet is taken from here?

Cool

Quote from: Ankris on Aug 14, 2016, 01:23 PMIt's me or this snippet is taken from here?
Dont be Mad Doom can never do this thing he has good skills why he will steal other thing you are such a ******

Mötley

It's actually almost the exact same script Hercules, I would like to know as of well, As well Hercules your statement is arrogant, Maybe Doom did not do so, If he did he should of added thanks to that script.

Cool

Quote from: Mötley on Aug 14, 2016, 03:18 PMIt's actually almost the exact same script Hercules, I would like to know as of well, As well Hercules your statement is arrogant, Maybe Doom did not do so, If he did he should of added thanks to that script.
Well sorry for my arrogant statment but i dont think Dhoom can do this without giving credits

DizzasTeR

I don't even know that snippet from LU, although the code looks alike because that's the math used to calculate FPS. Other than that I had also done something similar in MTA and I did a basic port from that one of mine to VCMP

Luis_Labarca

@Doom_Kill3R Hi bro I could you give an example of creating a text and delete it for example with the command /showtext and /deletetext bro you it would appreciate it if help me ;)
My server RP
IP: 51.222.28.159:8194