Vice City: Multiplayer

Server Development => Scripting and Server Management => Client Scripting => Topic started by: AroliS^ on May 20th, 2019, 10:53 PM

Title: Real Time
Post by: AroliS^ on May 20th, 2019, 10:53 PM
it is working great!
Code: [Select]
   
function Script::ScriptProcess()
{     
local time = System.GetDate( System.GetTimestamp( ), 'r' );
::time[ "date" ].Text = time.hour +" : "+ time.min;
}

in somewhere in your clientside's script!
Code: [Select]
function labelcreator( pos, colour, resizable )
{
local ui = GUILabel( pos, colour, resizable );
return  ui;
}

::time <-
{
date = labelcreator( VectorScreen( sX * 0.671, sY * 0.115 ), Colour( 255, 255, 255 ), true )
}

::timer[ "date" ].FontSize = sX * 0.025;


(https://3.bp.blogspot.com/-ZcE8p26iBfk/XOMfwwzWnmI/AAAAAAAAA20/cwVwbtpz9BoTC_irY523i8nqHtJII-_qQCLcBGAs/s320/unknown.png)

pastebin - https://pastebin.com/YUZPZkxz
Title: Re: Real Time
Post by: dracc on May 21st, 2019, 09:01 AM
Well, you run System.GetDate and update the GUILabel on every single processed frame - no wonder it's slow.
Title: Re: Real Time
Post by: . on May 21st, 2019, 10:01 PM
Quote from dracc on May 21st, 09:01 AM
Well, you run System.GetDate and update the GUILabel on every single processed frame - no wonder it's slow.
Updating a GUI already happens at every frame.

His problem is that he is changing the font size at every frame. Which means the font atlas must be re-built on every frame. And that will actually kill your performance.

Basically it all boils down to this line:
Code: [Select]
::timer[ "date" ].FontSize = sX * 0.025;

This is a known issue. Pick a set of fonts and sizes and stick with them. Otherwise use a pre-generated image with the text and scale that.
Title: Re: Real Time
Post by: AroliS^ on May 22nd, 2019, 02:54 AM
Updated it thank u :)
Title: Re: Real Time
Post by: =RK=MarineForce on May 27th, 2019, 12:57 AM
You are genius bro ;X

i don't know when i made my own server with helpless...