Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Pasek Informacyjny w TXD
- *
- * author: Lukasbank (edited by AXV)
- * version: 1.0.1
- *
- * All rights reserved.
- * ----------------------------------- */
- #include <a_samp>
- // makrodefinicje
- #if MAX_PLAYERS == 500
- #undef MAX_PLAYERS
- #define MAX_PLAYERS (500) // ilosc slotow
- #endif
- #define FS_NAME "Update stats"
- #define FS_VERSION "1.0.1"
- #define UPDATE_STATS_INTERVAL (1000)
- #define MAX_TD (12)
- #define foreach(%1) for (new %1 = 0; %1 <= handlePlayers; %1++) if (IsPlayerConnected(%1))
- // zmienne
- enum (+= 1) {
- Text:TD_BOX = 0,
- Text:TD_ONLINEPLAYERS1,
- Text:TD_ONLINEPLAYERS2,
- Text:TD_NICKWITHID1,
- Text:TD_NICKWITHID2,
- Text:TD_PING1,
- Text:TD_PING2,
- Text:TD_TIMEGAME1,
- Text:TD_TIMEGAME2,
- Text:TD_SCORE1,
- Text:TD_SCORE2
- };
- new
- Text:pTXD[MAX_PLAYERS][MAX_TD],
- playerSession[MAX_PLAYERS],
- tickCountPlayers,
- handlePlayers
- ;
- // funkcje publiczne
- public OnFilterScriptInit() {
- printf("%s, %s by Lukasbank edited by AXV loaded", FS_NAME, FS_VERSION);
- for (new i = 0; i < MAX_PLAYERS; i++) {
- pTXD[i][TD_ONLINEPLAYERS1] = TextDrawCreate(526.000000, 415.000000, "~b~~h~Graczy");
- TextDrawBackgroundColor(pTXD[i][TD_ONLINEPLAYERS1], 16);
- TextDrawFont(pTXD[i][TD_ONLINEPLAYERS1], 1);
- TextDrawLetterSize(pTXD[i][TD_ONLINEPLAYERS1], 0.319999, 1.000000);
- TextDrawColor(pTXD[i][TD_ONLINEPLAYERS1], -1);
- TextDrawSetOutline(pTXD[i][TD_ONLINEPLAYERS1], 1);
- TextDrawSetProportional(pTXD[i][TD_ONLINEPLAYERS1], 1);
- pTXD[i][TD_NICKWITHID1]= TextDrawCreate(149.000000, 415.000000, "~b~~y~Nick");
- TextDrawBackgroundColor(pTXD[i][TD_NICKWITHID1], 16);
- TextDrawFont(pTXD[i][TD_NICKWITHID1], 1);
- TextDrawLetterSize(pTXD[i][TD_NICKWITHID1], 0.319999, 1.000000);
- TextDrawColor(pTXD[i][TD_NICKWITHID1], -1);
- TextDrawSetOutline(pTXD[i][TD_NICKWITHID1], 1);
- TextDrawSetProportional(pTXD[i][TD_NICKWITHID1], 1);
- pTXD[i][TD_PING1] = TextDrawCreate(275.000000, 415.000000, "~b~~h~Ping");
- TextDrawBackgroundColor(pTXD[i][TD_PING1], 16);
- TextDrawFont(pTXD[i][TD_PING1], 1);
- TextDrawLetterSize(pTXD[i][TD_PING1], 0.319999, 1.000000);
- TextDrawColor(pTXD[i][TD_PING1], -1);
- TextDrawSetOutline(pTXD[i][TD_PING1], 1);
- TextDrawSetProportional(pTXD[i][TD_PING1], 1);
- pTXD[i][TD_TIMEGAME1] = TextDrawCreate(340.000000, 415.000000, "~b~~h~Czas gry");
- TextDrawBackgroundColor(pTXD[i][TD_TIMEGAME1], 16);
- TextDrawFont(pTXD[i][TD_TIMEGAME1], 1);
- TextDrawLetterSize(pTXD[i][TD_TIMEGAME1], 0.319999, 1.000000);
- TextDrawColor(pTXD[i][TD_TIMEGAME1], -1);
- TextDrawSetOutline(pTXD[i][TD_TIMEGAME1], 1);
- TextDrawSetProportional(pTXD[i][TD_TIMEGAME1], 1);
- pTXD[i][TD_SCORE1] = TextDrawCreate(428.000000, 415.000000, "~b~~h~Drift points");
- TextDrawBackgroundColor(pTXD[i][TD_SCORE1], 16);
- TextDrawFont(pTXD[i][TD_SCORE1], 1);
- TextDrawLetterSize(pTXD[i][TD_SCORE1], 0.319999, 1.000000);
- TextDrawColor(pTXD[i][TD_SCORE1], -1);
- TextDrawSetOutline(pTXD[i][TD_SCORE1], 1);
- TextDrawSetProportional(pTXD[i][TD_SCORE1], 1);
- pTXD[i][TD_BOX] = TextDrawCreate(78.000000, 332.000000, "-");
- TextDrawBackgroundColor(pTXD[i][TD_BOX], 37);
- TextDrawFont(pTXD[i][TD_BOX], 1);
- TextDrawLetterSize(pTXD[i][TD_BOX], 40.899971, 17.900001);
- TextDrawColor(pTXD[i][TD_BOX], 21);
- TextDrawSetOutline(pTXD[i][TD_BOX], 0);
- TextDrawSetProportional(pTXD[i][TD_BOX], 1);
- TextDrawSetShadow(pTXD[i][TD_BOX], 1);
- pTXD[i][TD_NICKWITHID2] = TextDrawCreate(150.000000, 430.000000, "_");
- TextDrawBackgroundColor(pTXD[i][TD_NICKWITHID2], 16);
- TextDrawFont(pTXD[i][TD_NICKWITHID2], 1);
- TextDrawLetterSize(pTXD[i][TD_NICKWITHID2], 0.300000, 1.200000);
- TextDrawColor(pTXD[i][TD_NICKWITHID2], -1);
- TextDrawSetOutline(pTXD[i][TD_NICKWITHID2], 1);
- TextDrawSetProportional(pTXD[i][TD_NICKWITHID2], 1);
- pTXD[i][TD_PING2] = TextDrawCreate(290.000000, 430.000000, "_");
- TextDrawBackgroundColor(pTXD[i][TD_PING2], 16);
- TextDrawFont(pTXD[i][TD_PING2], 1);
- TextDrawLetterSize(pTXD[i][TD_PING2], 0.300000, 1.200000);
- TextDrawColor(pTXD[i][TD_PING2], -1);
- TextDrawSetOutline(pTXD[i][TD_PING2], 1);
- TextDrawSetProportional(pTXD[i][TD_PING2], 1);
- pTXD[i][TD_TIMEGAME2] = TextDrawCreate(350.000000, 430.000000, "_");
- TextDrawBackgroundColor(pTXD[i][TD_TIMEGAME2], 16);
- TextDrawFont(pTXD[i][TD_TIMEGAME2], 1);
- TextDrawLetterSize(pTXD[i][TD_TIMEGAME2], 0.300000, 1.200000);
- TextDrawColor(pTXD[i][TD_TIMEGAME2], -1);
- TextDrawSetOutline(pTXD[i][TD_TIMEGAME2], 1);
- TextDrawSetProportional(pTXD[i][TD_TIMEGAME2], 1);
- pTXD[i][TD_SCORE2] = TextDrawCreate(448.000000, 430.000000, "_");
- TextDrawBackgroundColor(pTXD[i][TD_SCORE2], 16);
- TextDrawFont(pTXD[i][TD_SCORE2], 1);
- TextDrawLetterSize(pTXD[i][TD_SCORE2], 0.300000, 1.200000);
- TextDrawColor(pTXD[i][TD_SCORE2], -1);
- TextDrawSetOutline(pTXD[i][TD_SCORE2], 1);
- TextDrawSetProportional(pTXD[i][TD_SCORE2], 1);
- pTXD[i][TD_ONLINEPLAYERS2] = TextDrawCreate(531.000000, 430.000000, "_");
- TextDrawBackgroundColor(pTXD[i][TD_ONLINEPLAYERS2], 16);
- TextDrawFont(pTXD[i][TD_ONLINEPLAYERS2], 1);
- TextDrawLetterSize(pTXD[i][TD_ONLINEPLAYERS2], 0.300000, 1.200000);
- TextDrawColor(pTXD[i][TD_ONLINEPLAYERS2], -1);
- TextDrawSetOutline(pTXD[i][TD_ONLINEPLAYERS2], 1);
- TextDrawSetProportional(pTXD[i][TD_ONLINEPLAYERS2], 1);
- }
- SetTimer("updatePlayerStats", UPDATE_STATS_INTERVAL, true);
- return 1;
- }
- public OnFilterScriptExit() {
- foreach(playerid)
- for (new i = 0; i < MAX_TD; i++)
- TextDrawHideForPlayer(playerid, pTXD[playerid][i]);
- printf("%s, %s by Lukasbank edited by AXV unloaded", FS_NAME, FS_VERSION);
- return 1;
- }
- public OnPlayerConnect(playerid) {
- playerSession[playerid] = GetTickCount();
- if (handlePlayers < playerid)
- handlePlayers = playerid;
- }
- public OnPlayerDisconnect(playerid, reason) {
- for (new i = handlePlayers; i >= 0; i--) {
- if ((IsPlayerConnected(i) && i != playerid) || (i == 0)) {
- handlePlayers = i;
- break;
- }
- }
- }
- public OnPlayerSpawn(playerid) {
- for (new i = 0; i < MAX_TD; i++)
- TextDrawShowForPlayer(playerid, pTXD[playerid][i]);
- }
- public OnPlayerDeath(playerid, killerid, reason) {
- for (new i = 0; i < MAX_TD; i++)
- TextDrawHideForPlayer(playerid, pTXD[playerid][i]);
- }
- forward updateStats();
- public updateStats() {
- new sec = GetTickCount()/ 1000;
- if ((sec - tickCountPlayers) >= 8) { // zeby dane liczace graczy nie wywolywaly sie zbyt szybko
- new buffer[10];
- format(buffer, sizeof(buffer), "%i~y~|~w~%i", countPlayers(), GetMaxPlayers());
- foreach(i) {
- TextDrawSetString(pTXD[i][TD_ONLINEPLAYERS2], buffer);
- }
- printf("wykonano");
- tickCountPlayers = sec;
- }
- }
- forward updatePlayerStats();
- public updatePlayerStats() {
- static
- buffer[64],
- psession = 0
- ;
- foreach(i) {
- psession = 0, buffer[0] = 0;
- format(buffer, sizeof(buffer), "~b~~h~~h~%s~w~ (~y~%i~w~)", getPlayerName(i), i);
- TextDrawSetString(pTXD[i][TD_NICKWITHID2], buffer);
- psession = ((GetTickCount() - playerSession[i])/ 1000)/ 60;
- format(buffer, 15, "%02ih%02im", psession/ 60, psession% 60);
- TextDrawSetString(pTXD[i][TD_TIMEGAME2],buffer);
- format(buffer, sizeof(buffer), "%ims", GetPlayerPing(i));
- TextDrawSetString(pTXD[i][TD_PING2], buffer);
- format(buffer, sizeof(buffer), "%i", GetPlayerScore(i));
- TextDrawSetString(pTXD[i][TD_SCORE2], buffer);
- }
- updateStats();
- }
- countPlayers() {
- new players = 0;
- for (new i = 0; i <= handlePlayers; i++)
- if (IsPlayerConnected(i))
- players++;
- return players;
- }
- getPlayerName(playerid) {
- static
- _@Name[MAX_PLAYER_NAME]
- ;
- _@Name[0] = 0; // dla bezpieczenstwa
- GetPlayerName(playerid, _@Name, MAX_PLAYER_NAME);
- return _@Name;
- }
Advertisement
Add Comment
Please, Sign In to add comment