Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Server */
- Players <- []
- function onScriptLoad()
- {
- NewTimer("RunFPS", 500, 0 );
- }
- function onPlayerJoin( player )
- {
- Players.push( player.ID );
- }
- function onPlayerPart( player, reason )
- {
- if( Players.find( player.ID ) >= 0 ) Players.remove( Players.find( player.ID ) );
- }
- function RunFPS()
- {
- foreach( kiki in Players )
- {
- local player = FindPlayer( kiki );
- if( player )
- {
- local st = Stream();
- st.StartWrite();
- st.WriteInt( 1 );
- st.WriteString( "[#ffffff]FPS: " + FPSColor( player.FPS ) + " [#ffffff]PING: " + PingColor( player.Ping ) );
- st.SendStream( player );
- }
- }
- }
- function FPSColor( fps )
- {
- local s = "";
- if( fps < 21 ) s = "[#cc0000]" + fps;
- else if( fps > 20 && fps < 41 ) s = "[#e68a00]" + fps;
- else if( fps > 40 ) s = "[#009933]" + fps;
- return s;
- }
- function PingColor( ping )
- {
- local s = "";
- if( ping < 100 ) s = "[#009933]" + ping;
- else if( ping > 100 && ping < 300 ) s = "[#e68a00]" + ping;
- else if( ping > 300 ) s = "[#cc0000]" + ping;
- return s;
- }
- /* Client */
- PingLabel <- GUIMemobox()
- function Script::ScriptLoad()
- {
- PingLabel.Pos = VectorScreen( 0.0219*GUI.GetScreenSize().X, 0.9244*GUI.GetScreenSize().Y );
- PingLabel.Size = VectorScreen( 300, 30 );
- PingLabel.RemoveFlags( GUI_FLAG_BACKGROUND | GUI_FLAG_BORDER );
- PingLabel.FontFlags = GUI_FFLAG_BOLD;
- PingLabel.AddFlags(GUI_FLAG_TEXT_TAGS);
- PingLabel.FontSize = 15;
- PingLabel.AddLine("[#ffffff]FPS: null PING: null ");
- Console.Print( GUI.GetScreenSize().X + " " + GUI.GetScreenSize().Y );
- }
- function Server::ServerData(stream)
- {
- local type = stream.ReadInt(), string = stream.ReadString();
- if( type == 1 ) PingLabel.AddLine( string );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement