Guest User

Live Scores (Lawless Roleplay)

a guest
Jun 16th, 2016
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.23 KB | None | 0 0
  1. /*
  2.                  /$$$$$$$
  3.                 | $$__  $$
  4.                 | $$  \ $$  /$$$$$$   /$$$$$$  /$$$$$$$   /$$$$$$  /$$   /$$
  5.                 | $$$$$$$  |____  $$ /$$__  $$| $$__  $$ /$$__  $$| $$  | $$
  6.                 | $$__  $$  /$$$$$$$| $$  \__/| $$  \ $$| $$$$$$$$| $$  | $$
  7.                 | $$  \ $$ /$$__  $$| $$      | $$  | $$| $$_____/| $$  | $$
  8.                 | $$$$$$$/|  $$$$$$$| $$      | $$  | $$|  $$$$$$$|  $$$$$$$
  9.                 |_______/  \_______/|__/      |__/  |__/ \_______/ \____  $$
  10.                                                                    /$$  | $$
  11.                                                                   |  $$$$$$/
  12.                                                                    \______/
  13.                                      Live Scores
  14.                                 (Created by Barney)
  15.  
  16. */
  17.  
  18. #define FILTERSCRIPT
  19. #include <a_samp>
  20. #include <a_http>
  21. #define FOREACH_NO_BOTS
  22. #define FOREACH_NO_ACTORS
  23. #define FOREACH_NO_VEHICLES
  24. #define _YSI_PLUGINS_FIXES_2
  25. #define _YSI_PLUGINS_STREAMER
  26. #define _YSI_NO_VERSION_CHECK
  27. #define YSI_NO_MASTER
  28. #define MAX_COMMANDS (1)
  29. #include <YSI\y_timers>
  30. #include <YSI\y_commands>
  31.  
  32. new
  33.     Text:g_txdScores[2],
  34.     g_iToggle[MAX_PLAYERS],
  35.     g_iTxtVisible[MAX_PLAYERS];
  36.  
  37. stock lsALS_TextDrawShowForPlayer(playerid, Text:text)
  38. {
  39.     g_iTxtVisible[playerid] = 1;
  40.     return TextDrawShowForPlayer(playerid, Text:text);
  41. }
  42. #if defined _ALS_TextDrawShowForPlayer
  43.     #undef TextDrawShowForPlayer
  44. #else
  45.     #define _ALS_TextDrawShowForPlayer
  46. #endif
  47.  
  48. #define TextDrawShowForPlayer lsALS_TextDrawShowForPlayer
  49.  
  50. stock lsALS_TextDrawHideForPlayer(playerid, Text:text)
  51. {
  52.     g_iTxtVisible[playerid] = 0;
  53.     return TextDrawHideForPlayer(playerid, Text:text);
  54. }
  55. #if defined _ALS_TextDrawHideForPlayer
  56.     #undef TextDrawHideForPlayer
  57. #else
  58.     #define _ALS_TextDrawHideForPlayer
  59. #endif
  60.  
  61. #define TextDrawHideForPlayer lsALS_TextDrawHideForPlayer
  62.  
  63. stock lsALS_TextDrawHideForAll(Text:text)
  64. {
  65.     new iTotalPlayers = GetPlayerPoolSize();
  66.     for(new i = 0; i <= iTotalPlayers; i++) {
  67.         if(IsPlayerConnected(i)) {
  68.             g_iTxtVisible[i] = 0;
  69.         }
  70.     }
  71.     return TextDrawHideForAll(Text:text);
  72. }
  73. #if defined _ALS_TextDrawHideForAll
  74.     #undef TextDrawHideForAll
  75. #else
  76.     #define _ALS_TextDrawHideForAll
  77. #endif
  78.  
  79. #define TextDrawHideForAll lsALS_TextDrawHideForAll
  80.  
  81. stock lsALS_TextDrawShowForAll(Text:text)
  82. {
  83.     new iTotalPlayers = GetPlayerPoolSize();
  84.     for(new i = 0; i <= iTotalPlayers; i++) {
  85.         if(IsPlayerConnected(i)) {
  86.             g_iTxtVisible[i] = 1;
  87.         }
  88.     }
  89.     return TextDrawShowForAll(Text:text);
  90. }
  91. #if defined _ALS_TextDrawShowForAll
  92.     #undef TextDrawShowForAll
  93. #else
  94.     #define _ALS_TextDrawShowForAll
  95. #endif
  96.  
  97. #define TextDrawShowForAll lsALS_TextDrawShowForAll
  98.  
  99. public OnFilterScriptInit()
  100. {
  101.     g_txdScores[0] = TextDrawCreate(636.267456, 398.154205, "Euro 2016");
  102.     TextDrawLetterSize(g_txdScores[0], 0.241600, 1.217541);
  103.     TextDrawAlignment(g_txdScores[0], 3);
  104.     TextDrawColor(g_txdScores[0], -1);
  105.     TextDrawSetShadow(g_txdScores[0], 0);
  106.     TextDrawSetOutline(g_txdScores[0], 0);
  107.     TextDrawBackgroundColor(g_txdScores[0], 255);
  108.     TextDrawFont(g_txdScores[0], 1);
  109.     TextDrawSetProportional(g_txdScores[0], 1);
  110.     TextDrawSetShadow(g_txdScores[0], 0);
  111.  
  112.     g_txdScores[1] = TextDrawCreate(478.199768, 357.595550, "");
  113.     TextDrawLetterSize(g_txdScores[1], 0.000000, 0.000000);
  114.     TextDrawTextSize(g_txdScores[1], 172.000000, 93.000000);
  115.     TextDrawAlignment(g_txdScores[1], 1);
  116.     TextDrawColor(g_txdScores[1], -1);
  117.     TextDrawSetShadow(g_txdScores[1], 0);
  118.     TextDrawSetOutline(g_txdScores[1], 0);
  119.     TextDrawBackgroundColor(g_txdScores[1], 0);
  120.     TextDrawFont(g_txdScores[1], 5);
  121.     TextDrawSetProportional(g_txdScores[1], 0);
  122.     TextDrawSetShadow(g_txdScores[1], 0);
  123.     TextDrawSetPreviewModel(g_txdScores[1], 19740);
  124.     TextDrawSetPreviewRot(g_txdScores[1], 90.000000, 0.000000, 0.000000, 1.000000);
  125.  
  126.     TextDrawShowForAll(g_txdScores[0]);
  127.     TextDrawShowForAll(g_txdScores[1]);
  128.     return 1;
  129. }
  130.  
  131. main()
  132. {
  133.     print("----------------------------------");
  134.     print("Lawless Roleplay - Live Scores by Barney");
  135.     print("----------------------------------");
  136. }
  137.  
  138. public OnPlayerConnect(playerid)
  139. {
  140.     g_iToggle[playerid] = 0;
  141.     TextDrawShowForPlayer(playerid, g_txdScores[0]);
  142.     TextDrawShowForPlayer(playerid, g_txdScores[1]);
  143.     return 1;
  144. }
  145.  
  146. public OnFilterScriptExit()
  147. {
  148.     TextDrawHideForAll(g_txdScores[0]);
  149.     TextDrawHideForAll(g_txdScores[1]);
  150.     TextDrawDestroy(g_txdScores[0]);
  151.     TextDrawDestroy(g_txdScores[1]);
  152.     return 1;
  153. }
  154.  
  155. task LiveScoreUpdate[3000]()
  156. {
  157.     HTTP(420, HTTP_GET, "lawlessrp.com/scores.php", "", "HTTP_LiveScore");
  158.     return 1;
  159. }
  160.  
  161. forward HTTP_LiveScore(index, response_code, data[]);
  162. public HTTP_LiveScore(index, response_code, data[])
  163. {
  164.     if(response_code == 200) {
  165.         if(strcmp(data, "Euro 2016", true) == 0){
  166.             TextDrawHideForAll(g_txdScores[0]);
  167.             TextDrawHideForAll(g_txdScores[1]);
  168.         } else {
  169.             TextDrawSetString(g_txdScores[0], data);
  170.             new iTotalPlayers = GetPlayerPoolSize();
  171.             for(new i = 0; i <= iTotalPlayers; i++) {
  172.                 if(IsPlayerConnected(i)) {
  173.                     if(g_iToggle[i] == 0 && g_iTxtVisible[i] == 0){
  174.                         TextDrawShowForPlayer(i, g_txdScores[0]);
  175.                         TextDrawShowForPlayer(i, g_txdScores[1]);
  176.                     }
  177.                 }
  178.             }
  179.         }
  180.     } else
  181.         printf("ERROR: The request failed! The response code was: %d", response_code);
  182. }
  183.  
  184. YCMD:togscores(playerid, params[], help)
  185. {
  186.     if(g_iToggle[playerid] == 0) {
  187.         g_iToggle[playerid] = 1;
  188.         SendClientMessage(playerid, -1, "You have toggled the live scores off.");
  189.         TextDrawHideForPlayer(playerid, g_txdScores[0]);
  190.         TextDrawHideForPlayer(playerid, g_txdScores[1]);
  191.     } else {
  192.         g_iToggle[playerid] = 0;
  193.         SendClientMessage(playerid, -1, "You have toggled the live scores on.");
  194.         TextDrawShowForPlayer(playerid, g_txdScores[0]);
  195.         TextDrawShowForPlayer(playerid, g_txdScores[1]);
  196.     }
  197.     return 1;
  198. }
Add Comment
Please, Sign In to add comment