Advertisement
KingOfVC

[VC:MP] FPS PING LABEL

Nov 30th, 2016
1,023
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 1.71 KB | None | 0 0
  1. /* Server */
  2.  
  3. Players <- []
  4.  
  5. function onScriptLoad()
  6. {
  7.     NewTimer("RunFPS", 500, 0 );
  8. }
  9.  
  10. function onPlayerJoin( player )
  11. {
  12.     Players.push( player.ID );
  13. }
  14.  
  15. function onPlayerPart( player, reason )
  16. {
  17.     if( Players.find( player.ID ) >= 0 ) Players.remove( Players.find( player.ID ) );
  18. }
  19.  
  20. function RunFPS()
  21. {
  22.     foreach( kiki in Players )
  23.     {
  24.         local player = FindPlayer( kiki );
  25.         if( player )
  26.         {
  27.             local st = Stream();
  28.             st.StartWrite();
  29.             st.WriteInt( 1 );
  30.             st.WriteString( "[#ffffff]FPS: " + FPSColor( player.FPS ) + " [#ffffff]PING: " + PingColor( player.Ping ) );
  31.             st.SendStream( player );
  32.         }
  33.     }
  34. }
  35.  
  36. function FPSColor( fps )
  37. {
  38.     local s = "";
  39.     if( fps < 21 ) s = "[#cc0000]" + fps;
  40.     else if( fps > 20 && fps < 41 ) s = "[#e68a00]" + fps;
  41.     else if( fps > 40 ) s = "[#009933]" + fps;
  42.    
  43.     return s;
  44. }
  45.  
  46. function PingColor( ping )
  47. {
  48.     local s = "";
  49.     if( ping < 100 ) s = "[#009933]" + ping;
  50.     else if( ping > 100 && ping < 300 ) s = "[#e68a00]" + ping;
  51.     else if( ping > 300 ) s = "[#cc0000]" + ping;
  52.    
  53.     return s;
  54. }
  55.  
  56. /* Client */
  57. PingLabel <- GUIMemobox()
  58.  
  59. function Script::ScriptLoad()
  60. {
  61.     PingLabel.Pos = VectorScreen( 0.0219*GUI.GetScreenSize().X, 0.9244*GUI.GetScreenSize().Y  );
  62.     PingLabel.Size = VectorScreen( 300, 30 );
  63.     PingLabel.RemoveFlags( GUI_FLAG_BACKGROUND | GUI_FLAG_BORDER );
  64.     PingLabel.FontFlags =  GUI_FFLAG_BOLD;
  65.     PingLabel.AddFlags(GUI_FLAG_TEXT_TAGS);
  66.     PingLabel.FontSize = 15;
  67.     PingLabel.AddLine("[#ffffff]FPS: null PING: null ");
  68.     Console.Print( GUI.GetScreenSize().X + " " + GUI.GetScreenSize().Y );
  69. }
  70.  
  71. function Server::ServerData(stream)
  72. {
  73.     local type =  stream.ReadInt(), string = stream.ReadString();
  74.  
  75.     if( type == 1 ) PingLabel.AddLine( string );
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement