Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- /$$$$$$$
- | $$__ $$
- | $$ \ $$ /$$$$$$ /$$$$$$ /$$$$$$$ /$$$$$$ /$$ /$$
- | $$$$$$$ |____ $$ /$$__ $$| $$__ $$ /$$__ $$| $$ | $$
- | $$__ $$ /$$$$$$$| $$ \__/| $$ \ $$| $$$$$$$$| $$ | $$
- | $$ \ $$ /$$__ $$| $$ | $$ | $$| $$_____/| $$ | $$
- | $$$$$$$/| $$$$$$$| $$ | $$ | $$| $$$$$$$| $$$$$$$
- |_______/ \_______/|__/ |__/ |__/ \_______/ \____ $$
- /$$ | $$
- | $$$$$$/
- \______/
- Live Scores
- (Created by Barney)
- */
- #define FILTERSCRIPT
- #include <a_samp>
- #include <a_http>
- #define FOREACH_NO_BOTS
- #define FOREACH_NO_ACTORS
- #define FOREACH_NO_VEHICLES
- #define _YSI_PLUGINS_FIXES_2
- #define _YSI_PLUGINS_STREAMER
- #define _YSI_NO_VERSION_CHECK
- #define YSI_NO_MASTER
- #define MAX_COMMANDS (1)
- #include <YSI\y_timers>
- #include <YSI\y_commands>
- new
- Text:g_txdScores[2],
- g_iToggle[MAX_PLAYERS],
- g_iTxtVisible[MAX_PLAYERS];
- stock lsALS_TextDrawShowForPlayer(playerid, Text:text)
- {
- g_iTxtVisible[playerid] = 1;
- return TextDrawShowForPlayer(playerid, Text:text);
- }
- #if defined _ALS_TextDrawShowForPlayer
- #undef TextDrawShowForPlayer
- #else
- #define _ALS_TextDrawShowForPlayer
- #endif
- #define TextDrawShowForPlayer lsALS_TextDrawShowForPlayer
- stock lsALS_TextDrawHideForPlayer(playerid, Text:text)
- {
- g_iTxtVisible[playerid] = 0;
- return TextDrawHideForPlayer(playerid, Text:text);
- }
- #if defined _ALS_TextDrawHideForPlayer
- #undef TextDrawHideForPlayer
- #else
- #define _ALS_TextDrawHideForPlayer
- #endif
- #define TextDrawHideForPlayer lsALS_TextDrawHideForPlayer
- stock lsALS_TextDrawHideForAll(Text:text)
- {
- new iTotalPlayers = GetPlayerPoolSize();
- for(new i = 0; i <= iTotalPlayers; i++) {
- if(IsPlayerConnected(i)) {
- g_iTxtVisible[i] = 0;
- }
- }
- return TextDrawHideForAll(Text:text);
- }
- #if defined _ALS_TextDrawHideForAll
- #undef TextDrawHideForAll
- #else
- #define _ALS_TextDrawHideForAll
- #endif
- #define TextDrawHideForAll lsALS_TextDrawHideForAll
- stock lsALS_TextDrawShowForAll(Text:text)
- {
- new iTotalPlayers = GetPlayerPoolSize();
- for(new i = 0; i <= iTotalPlayers; i++) {
- if(IsPlayerConnected(i)) {
- g_iTxtVisible[i] = 1;
- }
- }
- return TextDrawShowForAll(Text:text);
- }
- #if defined _ALS_TextDrawShowForAll
- #undef TextDrawShowForAll
- #else
- #define _ALS_TextDrawShowForAll
- #endif
- #define TextDrawShowForAll lsALS_TextDrawShowForAll
- public OnFilterScriptInit()
- {
- g_txdScores[0] = TextDrawCreate(636.267456, 398.154205, "Euro 2016");
- TextDrawLetterSize(g_txdScores[0], 0.241600, 1.217541);
- TextDrawAlignment(g_txdScores[0], 3);
- TextDrawColor(g_txdScores[0], -1);
- TextDrawSetShadow(g_txdScores[0], 0);
- TextDrawSetOutline(g_txdScores[0], 0);
- TextDrawBackgroundColor(g_txdScores[0], 255);
- TextDrawFont(g_txdScores[0], 1);
- TextDrawSetProportional(g_txdScores[0], 1);
- TextDrawSetShadow(g_txdScores[0], 0);
- g_txdScores[1] = TextDrawCreate(478.199768, 357.595550, "");
- TextDrawLetterSize(g_txdScores[1], 0.000000, 0.000000);
- TextDrawTextSize(g_txdScores[1], 172.000000, 93.000000);
- TextDrawAlignment(g_txdScores[1], 1);
- TextDrawColor(g_txdScores[1], -1);
- TextDrawSetShadow(g_txdScores[1], 0);
- TextDrawSetOutline(g_txdScores[1], 0);
- TextDrawBackgroundColor(g_txdScores[1], 0);
- TextDrawFont(g_txdScores[1], 5);
- TextDrawSetProportional(g_txdScores[1], 0);
- TextDrawSetShadow(g_txdScores[1], 0);
- TextDrawSetPreviewModel(g_txdScores[1], 19740);
- TextDrawSetPreviewRot(g_txdScores[1], 90.000000, 0.000000, 0.000000, 1.000000);
- TextDrawShowForAll(g_txdScores[0]);
- TextDrawShowForAll(g_txdScores[1]);
- return 1;
- }
- main()
- {
- print("----------------------------------");
- print("Lawless Roleplay - Live Scores by Barney");
- print("----------------------------------");
- }
- public OnPlayerConnect(playerid)
- {
- g_iToggle[playerid] = 0;
- TextDrawShowForPlayer(playerid, g_txdScores[0]);
- TextDrawShowForPlayer(playerid, g_txdScores[1]);
- return 1;
- }
- public OnFilterScriptExit()
- {
- TextDrawHideForAll(g_txdScores[0]);
- TextDrawHideForAll(g_txdScores[1]);
- TextDrawDestroy(g_txdScores[0]);
- TextDrawDestroy(g_txdScores[1]);
- return 1;
- }
- task LiveScoreUpdate[3000]()
- {
- HTTP(420, HTTP_GET, "lawlessrp.com/scores.php", "", "HTTP_LiveScore");
- return 1;
- }
- forward HTTP_LiveScore(index, response_code, data[]);
- public HTTP_LiveScore(index, response_code, data[])
- {
- if(response_code == 200) {
- if(strcmp(data, "Euro 2016", true) == 0){
- TextDrawHideForAll(g_txdScores[0]);
- TextDrawHideForAll(g_txdScores[1]);
- } else {
- TextDrawSetString(g_txdScores[0], data);
- new iTotalPlayers = GetPlayerPoolSize();
- for(new i = 0; i <= iTotalPlayers; i++) {
- if(IsPlayerConnected(i)) {
- if(g_iToggle[i] == 0 && g_iTxtVisible[i] == 0){
- TextDrawShowForPlayer(i, g_txdScores[0]);
- TextDrawShowForPlayer(i, g_txdScores[1]);
- }
- }
- }
- }
- } else
- printf("ERROR: The request failed! The response code was: %d", response_code);
- }
- YCMD:togscores(playerid, params[], help)
- {
- if(g_iToggle[playerid] == 0) {
- g_iToggle[playerid] = 1;
- SendClientMessage(playerid, -1, "You have toggled the live scores off.");
- TextDrawHideForPlayer(playerid, g_txdScores[0]);
- TextDrawHideForPlayer(playerid, g_txdScores[1]);
- } else {
- g_iToggle[playerid] = 0;
- SendClientMessage(playerid, -1, "You have toggled the live scores on.");
- TextDrawShowForPlayer(playerid, g_txdScores[0]);
- TextDrawShowForPlayer(playerid, g_txdScores[1]);
- }
- return 1;
- }
Add Comment
Please, Sign In to add comment