Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <sscanf2>
- #include <zcmd>
- #undef MAX_PLAYERS
- #define MAX_PLAYERS 500 //Change it if you want. Not necesarry but reccomended.
- #define COLOR_WHITE 0xFFFFFFAA
- #define COLOR_GREEN 0x00FF00AA
- #define COLOR_YELLOW 0xFFFF00AA
- #define COLOR_GRAY 0xAFAFAFAA
- new Text:Top5ScoreTD,
- Top5[5][2], bool:pSeeList[MAX_PLAYERS]
- ;
- public OnFilterScriptInit()
- {
- Top5ScoreTD = TextDrawCreate(205.000000, 116.000000, "~r~Unknown");
- TextDrawBackgroundColor(Top5ScoreTD, 255);
- TextDrawFont(Top5ScoreTD, 1);
- TextDrawLetterSize(Top5ScoreTD, 0.740000, 2.000000);
- TextDrawColor(Top5ScoreTD, -1);
- TextDrawSetOutline(Top5ScoreTD, 1);
- TextDrawSetProportional(Top5ScoreTD, 1);
- TextDrawUseBox(Top5ScoreTD, 1);
- TextDrawBoxColor(Top5ScoreTD, 255);
- TextDrawTextSize(Top5ScoreTD, 563.000000, 9.000000);
- return 1;
- }
- public OnFilterScriptExit()
- {
- TextDrawHideForAll(Top5ScoreTD); //Does it make sense? - No, it probably doesn't.
- TextDrawDestroy(Top5ScoreTD);
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- if(pSeeList[playerid]){
- TextDrawShowForPlayer(playerid, Top5ScoreTD);
- SendClientMessage(playerid, COLOR_WHITE, "NOTE: Press with the FIRE_KEY to disable the box");
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- pSeeList[playerid] = false;
- TextDrawHideForPlayer(playerid, Top5ScoreTD); //Probably not needed :')
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if((newkeys & KEY_FIRE) && pSeeList[playerid])
- HideList(playerid);
- return 1;
- }
- stock PlayerName(playerid)
- {
- static pName[MAX_PLAYER_NAME];
- GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
- return pName;
- }
- stock GetP1()
- {
- new HighestScore = cellmin, LastHighest = INVALID_PLAYER_ID;
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(!IsPlayerConnected(i)) continue;
- if(GetPlayerScore(i) > HighestScore){
- HighestScore = GetPlayerScore(i);
- LastHighest = i;
- }
- }
- return Top5[0][0] = LastHighest, Top5[0][1] = HighestScore;
- }
- stock GetP2()
- {
- new HighestScore = cellmin, LastHighest = INVALID_PLAYER_ID;
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(!IsPlayerConnected(i)) continue;
- if((GetPlayerScore(i) > HighestScore) && (GetPlayerScore(i) < Top5[0][1])){
- HighestScore = GetPlayerScore(i);
- LastHighest = i;
- }
- }
- return Top5[1][0] = LastHighest, Top5[1][1] = HighestScore;
- }
- stock GetP3()
- {
- new HighestScore = cellmin, LastHighest = INVALID_PLAYER_ID;
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(!IsPlayerConnected(i)) continue;
- if((GetPlayerScore(i) > HighestScore) && (GetPlayerScore(i) < Top5[1][1])){
- HighestScore = GetPlayerScore(i);
- LastHighest = i;
- }
- }
- return Top5[2][0] = LastHighest, Top5[2][1] = HighestScore;
- }
- stock GetP4()
- {
- new HighestScore = cellmin, LastHighest = INVALID_PLAYER_ID;
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(!IsPlayerConnected(i)) continue;
- if((GetPlayerScore(i) > HighestScore) && (GetPlayerScore(i) < Top5[2][1])){
- HighestScore = GetPlayerScore(i);
- LastHighest = i;
- }
- }
- return Top5[3][0] = LastHighest, Top5[3][1] = HighestScore;
- }
- stock GetP5()
- {
- new HighestScore = cellmin, LastHighest = INVALID_PLAYER_ID;
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(!IsPlayerConnected(i)) continue;
- if((GetPlayerScore(i) > HighestScore) && (GetPlayerScore(i) < Top5[3][1])){
- HighestScore = GetPlayerScore(i);
- LastHighest = i;
- }
- }
- return Top5[4][0] = LastHighest, Top5[4][1] = HighestScore;
- }
- stock GetScores()
- {
- GetP1();
- GetP2();
- GetP3();
- GetP4();
- GetP5();
- return 1;
- }
- stock ShowList(playerid)
- {
- pSeeList[playerid] = true;
- TextDrawShowForPlayer(playerid, Top5ScoreTD);
- return 1;
- }
- stock HideList(playerid)
- {
- pSeeList[playerid] = false;
- TextDrawHideForPlayer(playerid, Top5ScoreTD);
- return 1;
- }
- stock ShowAllList()
- for(new i = 0; i < MAX_PLAYERS; i++) ShowList(i);
- stock HideAllList()
- for(new i = 0; i < MAX_PLAYERS; i++) ShowList(i);
- CMD:kt5help(playerid, params[])
- {
- if(!IsPlayerAdmin(playerid)) return 0;
- SendClientMessage(playerid, COLOR_YELLOW, "[----- Top5 Players - By Kwarde -----]");
- SendClientMessage(playerid, COLOR_WHITE, "** Update status: /kt5update || ** Show top5 list to all: /kt5show");
- SendClientMessage(playerid, COLOR_WHITE, "** Show top5 list to one person: /kt5show [playerid]");
- SendClientMessage(playerid, COLOR_WHITE, "** To hide for all or playerid: /kt5hide ([playerid])");
- SendClientMessage(playerid, COLOR_YELLOW, "[------ END ------]");
- return 1;
- }
- CMD:kt5update(playerid, params[])
- {
- new str[230];
- if(!IsPlayerAdmin(playerid)) return 0;
- GetScores();
- format(str, 230, "~b~Top 5 player scores:~w~~n~~n~%s: %d~n~%s: %d~n~%s: %d~n~%s: %d~n~%s: %d~n~", PlayerName(Top5[0][0]), Top5[0][1], PlayerName(Top5[1][0]), Top5[1][1], PlayerName(Top5[2][0]), Top5[2][1], PlayerName(Top5[3][0]), Top5[3][1], PlayerName(Top5[4][0]), Top5[4][1]);
- TextDrawSetString(Top5ScoreTD, str);
- SendClientMessage(playerid, COLOR_GREEN, "** List has been updated!");
- return 1;
- }
- CMD:kt5show(playerid, params[])
- {
- new bool:All, ID;
- if(!IsPlayerAdmin(playerid)) return 0;
- if(sscanf(params, "d", ID)){
- All = false;
- SendClientMessage(playerid, COLOR_WHITE, "NOTE: You can also use /kt5show [playerid]");
- }
- else All = true;
- if(All){
- ShowAllList();
- SendClientMessageToAll(COLOR_GREEN, "* A RCON administrator has just showed the top 5 score list");
- SendClientMessageToAll(COLOR_WHITE, "NOTE: Press with the FIRE_KEY to disable the box");
- }
- else{
- if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_GRAY, "** Player is not connected!");
- ShowList(ID);
- SendClientMessage(playerid, COLOR_GREEN, "* Player does now see the top 5 score list");
- SendClientMessage(ID, COLOR_GREEN, "* A RCON administrator has shown you the top 5 players");
- SendClientMessage(ID, COLOR_WHITE, "NOTE: Press with the FIRE_KEY to disable the box");
- }
- return 1;
- }
- CMD:kt5hide(playerid, params[])
- {
- new bool:All, ID;
- if(!IsPlayerAdmin(playerid)) return 0;
- if(sscanf(params, "d", ID)){
- All = false;
- SendClientMessage(playerid, COLOR_WHITE, "NOTE: You can also use /kt5hide [playerid]");
- }
- else All = true;
- if(All){
- HideAllList();
- SendClientMessageToAll(COLOR_GREEN, "* A RCON administrator has just hidden the top 5 score list");
- }
- else{
- if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_GRAY, "** Player is not connected!");
- HideList(ID);
- SendClientMessage(playerid, COLOR_GREEN, "* Player does not see anymore the top 5 score list");
- SendClientMessage(ID, COLOR_GREEN, "* A RCON administrator has hide the top 5 players for you");
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement