Advertisement
Guest User

TextDraw Ping System

a guest
Oct 23rd, 2013
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.86 KB | None | 0 0
  1. FilterScript criado a pedido do SkYpE...
  2.  
  3. Créditos: Focaximubh(EU '-')
  4.  
  5.           Cantiliano_ = duduzinho (Me ajudou a testar o projeto e me deu idéia pra arruma uns errinhos O.o
  6.           mlk tu é dms e ainda arrumo minha conexão pra usar o sa-mp sem hamachi :D)
  7.  
  8.           Zamaroht's (Pelo editor de TextDraws)
  9.          
  10.           SA-MP WiKi Pela explicação das funções:
  11.          
  12.           http://wiki.sa-mp.com/wiki/GetPlayerTargetPlayer
  13.           http://wiki.sa-mp.com/wiki/GetPlayerPing
  14.           http://wiki.sa-mp.com/wiki/CreatePlayerTextDraw
  15.          
  16.           ZeeX (Pelo ZCMD)
  17.  
  18. Objetivo do FilterScript: Após mirar em algum player, o seu PING será imprimido
  19. na TextDraw aparecendo de forma totalmente dinâmica
  20.  
  21. EX: Ping Alvo: 120
  22.    Ping Alvo: 123
  23.    Ping Alvo: 133
  24.    Ou de acordo com o ping do player(os ping acima foi só exemplo nunca vi ping
  25.    abaixo de 200 mais hje em dia suhausahs)
  26.    
  27.    Obrigado pela atenção de todos, peço desculpas por erros de lógica ou até
  28.    falta de organização do código, estou disposto a receber críticas e dicas
  29.    para a melhoria de projetos, apesar de extremamente simples.
  30. */
  31.  
  32. #include <a_samp>
  33. #include <a_players>
  34. #include <zcmd>
  35. #include <sscanf2>
  36.  
  37. new PlayerText:PlayerPingText[MAX_PLAYERS];
  38.  
  39.  
  40. public OnGameModeInit()
  41. {
  42.     return 1;
  43. }
  44. main()
  45. {
  46.     print("\n----------------------------------");
  47.     print(" PlayerPingTextDraw by: Focaximubh");
  48.     print("----------------------------------\n");
  49. }
  50. public OnGameModeExit()
  51. {
  52.     return 1;
  53. }
  54.  
  55. public OnPlayerConnect(playerid)
  56. {
  57.     PlayerPingText[playerid] = CreatePlayerTextDraw(playerid, 7.000000, 322.000000, "Nenhum Alvo");
  58.     PlayerTextDrawBackgroundColor(playerid, PlayerPingText[playerid], 255);
  59.     PlayerTextDrawFont(playerid, PlayerPingText[playerid], 1);
  60.     PlayerTextDrawLetterSize(playerid, PlayerPingText[playerid], 0.430000, 1.500000);
  61.     PlayerTextDrawColor(playerid, PlayerPingText[playerid], -16776961);
  62.     PlayerTextDrawSetOutline(playerid, PlayerPingText[playerid], 1);
  63.     PlayerTextDrawSetProportional(playerid, PlayerPingText[playerid], 1);
  64.     PlayerTextDrawUseBox(playerid, PlayerPingText[playerid], 1);
  65.     PlayerTextDrawBoxColor(playerid, PlayerPingText[playerid], 0x90948DFF);
  66.     PlayerTextDrawTextSize(playerid, PlayerPingText[playerid], 132.000000, -135.000000);
  67.     return 1;
  68. }
  69.  
  70. public OnPlayerDisconnect(playerid, reason)
  71. {
  72.     PlayerTextDrawDestroy(playerid, PlayerPingText[playerid]);
  73.     return 1;
  74. }
  75.  
  76. public OnPlayerSpawn(playerid)
  77. {
  78.     PlayerTextDrawShow(playerid, PlayerPingText[playerid]);
  79.     return 1;
  80. }
  81.  
  82. public OnPlayerDeath(playerid, killerid, reason)
  83. {
  84.     PlayerTextDrawHide(playerid, PlayerPingText[playerid]);
  85.     return 1;
  86. }
  87. public OnPlayerUpdate(playerid)
  88. {
  89.     new OutroPlayer = GetPlayerTargetPlayer(playerid);
  90.     new OutroPplayer;
  91.     new PlayerPingString[20];
  92.     if(GetPlayerTeam(OutroPlayer) == GetPlayerTeam(playerid) && OutroPlayer != INVALID_PLAYER_ID)//Função retirada do SA-MP Wiki
  93.     {
  94.  
  95.         format(PlayerPingString, sizeof(PlayerPingString), "~r~Ping Alvo: ~w~%i", GetPlayerPing(OutroPplayer));
  96.         PlayerTextDrawSetString(playerid, PlayerPingText[playerid], PlayerPingString);
  97.     }
  98.     else
  99.     {
  100.  
  101.         PlayerTextDrawSetString(playerid, PlayerPingText[playerid], "~r~Nenhum Alvo");
  102.     }
  103.     return 1;
  104. }
  105.  
  106. CMD:meuping(playerid, params[])
  107. {
  108.     new seuping[24];
  109.     format(seuping, sizeof(seuping), "Seu ping agora é: %i", GetPlayerPing(playerid));
  110.     SendClientMessage(playerid, -1, seuping);
  111.     return 1;
  112. }
  113. CMD:pingdele(playerid, params[])
  114. {
  115.     new id;
  116.     if(sscanf(params,"i", id)) return SendClientMessage(playerid , -1, " Uso /pingdele [ID do player] ");
  117.     if(IsPlayerConnected(id))
  118.     {
  119.  
  120.         new PingDele = GetPlayerPing(id);
  121.         new PingdoCara[24];
  122.         format(PingdoCara, sizeof(PingdoCara), "O ping dele agora é: %i", PingDele);
  123.         SendClientMessage(playerid, -1, PingdoCara);
  124.     }
  125.     else
  126.     {
  127.  
  128.         SendClientMessage(playerid, -1, "Este Player Não está online no momento");
  129.     }
  130.     return 1;
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement