Advertisement
whiplk

[PEDIDO] - PacketLoss

Jul 8th, 2013
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.25 KB | None | 0 0
  1. /*
  2. Pedido by: Shinjuku, fórum sa-mp.
  3. Coded by: Willian_Luigi.
  4.  
  5. --------------
  6.  
  7. função: Pegar o PacketLoss do player e exibi-lo em um textdraw.
  8. */
  9. #include <a_samp>
  10. main() print("Initialization.");
  11.  
  12. new Text: Draw[MAX_PLAYERS];
  13.  
  14. stock Float:GetPlayerPacketLoss(playerid)
  15. {
  16.     new stats[401], stringstats[70];
  17.     GetPlayerNetworkStats(playerid, stats, sizeof(stats));
  18.     new len = strfind(stats, "Packetloss: ");
  19.     new Float:packetloss = 0.0;
  20.     if(len != -1)
  21.     {
  22.         strmid(stringstats, stats, len, strlen(stats));
  23.         new len2 = strfind(stringstats, "%");
  24.         if(len != -1)
  25.         {
  26.             strdel(stats, 0, strlen(stats));
  27.             strmid(stats, stringstats, len2-3, len2);
  28.             packetloss = floatstr(stats);
  29.         }
  30.     }
  31.     return packetloss;
  32. }
  33.  
  34. public OnGameModeInit()
  35. {
  36.     for (new i = 0, j = GetMaxPlayers(); i < j; ++i)
  37.     Draw[i] = TextDrawCreate(250, 30, "packet loss loading...");
  38.  
  39.     return 1;
  40. }
  41.  
  42. public OnPlayerConnect(playerid)
  43. {
  44.     TogglePlayerClock(playerid, 1);
  45.     TextDrawShowForPlayer(playerid, Draw[playerid]);
  46. }
  47.  
  48. public OnPlayerUpdate(playerid)
  49. {
  50.     new
  51.         sStr[10],
  52.         Float:sPacketLoss[MAX_PLAYERS];
  53.        
  54.     sPacketLoss[playerid] = GetPlayerPacketLoss(playerid);
  55.     format(sStr, 10, "%0.1f", sPacketLoss[playerid]);
  56.     TextDrawSetString(Draw[playerid], sStr);
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement