Guest User

Pingbar

a guest
Aug 12th, 2012
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.69 KB | None | 0 0
  1. //Simple PingBar by xVectoliife
  2.  
  3. #include <a_samp>
  4.  
  5. #define FILTERSCRIPT
  6.  
  7. new Text:Ping[MAX_PLAYERS];
  8. new Text:Ping2[MAX_PLAYERS];
  9. new Text:Ping3[MAX_PLAYERS];
  10. new Text:Ping4[MAX_PLAYERS];
  11. new Text:ScrittaPing[MAX_PLAYERS];
  12. forward PingUpdate(playerid);
  13.  
  14. #if defined FILTERSCRIPT
  15.  
  16. public OnFilterScriptInit()
  17. {
  18.     print("\n--------------------------------------");
  19.     print(" PingBar by xVectoliife                 ");
  20.     print("--------------------------------------\n");
  21.     return 1;
  22. }
  23.  
  24. public OnFilterScriptExit()
  25. {
  26.     return 1;
  27. }
  28.  
  29. #endif
  30.  
  31. public OnPlayerConnect(playerid)
  32. {
  33.     Ping[playerid] = TextDrawCreate(536.000000, 112.000000, "~g~l");
  34.     TextDrawBackgroundColor(Ping[playerid], 255);
  35.     TextDrawFont(Ping[playerid], 1);
  36.     TextDrawLetterSize(Ping[playerid], 0.500000, 1.000000);
  37.     TextDrawColor(Ping[playerid], -1);
  38.     TextDrawSetOutline(Ping[playerid], 1);
  39.     TextDrawSetProportional(Ping[playerid], 1);
  40.  
  41.     Ping2[playerid] = TextDrawCreate(542.000000, 109.000000, "~g~l");
  42.     TextDrawBackgroundColor(Ping2[playerid], 255);
  43.     TextDrawFont(Ping2[playerid], 1);
  44.     TextDrawLetterSize(Ping2[playerid], 0.500000, 1.399999);
  45.     TextDrawColor(Ping2[playerid], -1);
  46.     TextDrawSetOutline(Ping2[playerid], 1);
  47.     TextDrawSetProportional(Ping2[playerid], 1);
  48.  
  49.     Ping3[playerid] = TextDrawCreate(548.000000, 105.000000, "~g~l");
  50.     TextDrawBackgroundColor(Ping3[playerid], 255);
  51.     TextDrawFont(Ping3[playerid], 1);
  52.     TextDrawLetterSize(Ping3[playerid], 0.500000, 1.899999);
  53.     TextDrawColor(Ping3[playerid], -1);
  54.     TextDrawSetOutline(Ping3[playerid], 1);
  55.     TextDrawSetProportional(Ping3[playerid], 1);
  56.  
  57.     Ping4[playerid] = TextDrawCreate(554.000000, 101.000000, "~g~l");
  58.     TextDrawBackgroundColor(Ping4[playerid], 255);
  59.     TextDrawFont(Ping4[playerid], 1);
  60.     TextDrawLetterSize(Ping4[playerid], 0.500000, 2.399998);
  61.     TextDrawColor(Ping4[playerid], -1);
  62.     TextDrawSetOutline(Ping4[playerid], 1);
  63.     TextDrawSetProportional(Ping4[playerid], 1);
  64.  
  65.     ScrittaPing[playerid] = TextDrawCreate(530.000000, 121.000000, "Ping");
  66.     TextDrawBackgroundColor(ScrittaPing[playerid], 255);
  67.     TextDrawFont(ScrittaPing[playerid], 1);
  68.     TextDrawLetterSize(ScrittaPing[playerid], 0.500000, 1.000000);
  69.     TextDrawColor(ScrittaPing[playerid], -1);
  70.     TextDrawSetOutline(ScrittaPing[playerid], 1);
  71.     TextDrawSetProportional(ScrittaPing[playerid], 1);
  72.  
  73.  
  74.     TextDrawShowForPlayer(playerid, ScrittaPing[playerid]);
  75.     TextDrawShowForPlayer(playerid, Ping[playerid]);
  76.     TextDrawShowForPlayer(playerid, Ping2[playerid]);
  77.     TextDrawShowForPlayer(playerid, Ping3[playerid]);
  78.     TextDrawShowForPlayer(playerid, Ping4[playerid]);
  79.     SetTimerEx("PingUpdate", 150, false, "i", playerid); //Preferisco usare un timer che l'OnPlayerUpdate.
  80.     return 1;
  81. }
  82.  
  83. public OnPlayerDisconnect(playerid, reason)
  84. {
  85.     return 1;
  86. }
  87.  
  88. public PingUpdate(playerid)
  89. {
  90.     new string[48];
  91.     if(GetPlayerPing(playerid) > 50 && GetPlayerPing(playerid) < 100) //3 tacche
  92.     {
  93.         TextDrawHideForPlayer(playerid, Ping4[playerid]);
  94.     }
  95.     else if(GetPlayerPing(playerid) > 100 && GetPlayerPing(playerid) < 200) //2 tacche
  96.     {
  97.         TextDrawHideForPlayer(playerid, Ping4[playerid]);
  98.         TextDrawHideForPlayer(playerid, Ping3[playerid]);
  99.         //Questo codice qui sotto serve per rendere le tacche gialle.
  100.         format(string, sizeof(string), "~y~l");
  101.         TextDrawSetString(Ping2[playerid],string);
  102.         format(string, sizeof(string), "~y~l");
  103.         TextDrawSetString(Ping[playerid],string);
  104.     }
  105.     else if(GetPlayerPing(playerid) > 200) //1 tacca
  106.     {
  107.         TextDrawHideForPlayer(playerid, Ping4[playerid]);
  108.         TextDrawHideForPlayer(playerid, Ping3[playerid]);
  109.         TextDrawHideForPlayer(playerid, Ping2[playerid]);
  110.         format(string, sizeof(string), "~r~l");
  111.         TextDrawSetString(Ping[playerid],string);
  112.     }
  113. }
Advertisement
Add Comment
Please, Sign In to add comment