#include #include "W3SIncs/War3Source_Interface" new bool:bRankCached[MAXPLAYERSCUSTOM]; new iRank[MAXPLAYERSCUSTOM]; new iTotalPlayersDB[MAXPLAYERSCUSTOM]; // this is also cached per client, eg one player might see 1/20 when another sees 2/21 new iTopCount; // there might not be 100 in the array. new String:Top100Name[101][64]; new String:Top100Steamid[101][64]; new Top100totallevel[101]; new Top100totalxp[101]; public Plugin:myinfo= { name="W3S Engine Database top100", author="Ownz (DarkEnergy)", description="War3Source Core Plugins", version="1.0", url="http://war3source.com/" }; public OnPluginStart() { } public OnMapStart(){ War3Source_UpdateStats(); } public OnWar3Event(W3EVENT:event,client){ if(event==DoShowWar3Rank){ GetRank(client); } if(event==DoShowWar3Stats){ War3Source_Stats(client); } if(event==DoShowWar3Top){ new num=W3GetVar(EventArg1); War3Source_War3Top(client,num); } } War3Source_UpdateStats() { new Handle:hDB=W3GetVar(hDatabase); if(hDB) { for(new x=0;x<=MaxClients;x++) { bRankCached[x]=false; } //for(new x=0;x0) { bRankCached[client]=true; War3_ChatMessage(client,"%T","Ranked {amount} of {amount}",client,iRank[client],iTotalPlayersDB[client]); } } } // Stats War3Source_Stats(client) { new Handle:statsMenu=CreateMenu(War3Source_Stats_Selected); SetMenuExitButton(statsMenu,true); SetMenuTitle(statsMenu,"%T","[War3Source] Select a player to view stats",client); decl String:playername[64]; decl String:war3playerbuf[4]; for(new x=1;x<=MaxClients;x++) { if(ValidPlayer(x,false)) { Format(war3playerbuf,sizeof(war3playerbuf),"%d",x); GetClientName(x,playername,sizeof(playername)); AddMenuItem(statsMenu,war3playerbuf,playername); } } DisplayMenu(statsMenu,client,20); } public War3Source_Stats_Selected(Handle:menu,MenuAction:action,client,selection) { if(action==MenuAction_Select) { decl String:SelectionInfo[4]; decl String:SelectionDispText[256]; new SelectionStyle; GetMenuItem(menu,selection,SelectionInfo,sizeof(SelectionInfo),SelectionStyle, SelectionDispText,sizeof(SelectionDispText)); new target=StringToInt(SelectionInfo); if(ValidPlayer(target)) War3Source_Stats_Player(client,target); else { War3_ChatMessage(client,"%T","The player you selected has left the server",client); War3Source_Stats(client); } } if(action==MenuAction_End) { CloseHandle(menu); } } public War3Source_Stats_Player(client,target) { if(ValidPlayer(target,false)) { new Handle:playerInfo=CreateMenu(War3Source_Stats_Player_Select); SetMenuExitButton(playerInfo,true); decl String:playername[64]; GetClientName(target,playername,sizeof(playername)); new RacesLoaded = War3_GetRacesLoaded(); for(new x=1;x<=RacesLoaded;x++) { decl String:race_name[64]; War3_GetRaceName(x,race_name,sizeof(race_name)); new String:data_str[16]; Format(data_str,sizeof(data_str),"%d.%d",target,x); AddMenuItem(playerInfo,data_str,race_name); } decl String:race_name[64]; War3_GetRaceName(War3_GetRace(target),race_name,sizeof(race_name)); new gold=War3_GetGold(target); SetMenuTitle(playerInfo,"%T\n","[War3Source] Info for {player}. Current Race: {racename} gold: {amount}",client,playername,race_name,gold); DisplayMenu(playerInfo,client,20); } else { War3_ChatMessage(client,"%T","The player has disconnected from the server",client); War3Source_Stats(client); } } public War3Source_Stats_Player_Select(Handle:menu,MenuAction:action,client,selection) { if(action==MenuAction_Select) { decl String:SelectionInfo[16]; decl String:SelectionDispText[256]; new SelectionStyle; GetMenuItem(menu,selection,SelectionInfo,sizeof(SelectionInfo),SelectionStyle, SelectionDispText,sizeof(SelectionDispText)); new String:buffer_out[2][8]; ExplodeString(SelectionInfo,".",buffer_out,2,8); new index=StringToInt(buffer_out[0]); new race_num=StringToInt(buffer_out[1]); if(index>0 && race_num>=0) { War3Source_Stats_Player_Race(client,index,race_num); } } else if(action==MenuAction_Cancel) { if(selection==MenuCancel_Exit) { War3Source_Stats(client); } } if(action==MenuAction_End) { CloseHandle(menu); } } public War3Source_Stats_Player_Race(client,target,race_num) { if(ValidPlayer(target)) { new Handle:playerInfo=CreateMenu(War3Source_Stats_PRS); SetMenuExitButton(playerInfo,true); decl String:playername[64]; GetClientName(target,playername,sizeof(playername)); new String:longbuf[1000]; decl String:race_name[64]; War3_GetRaceName(race_num,race_name,sizeof(race_name)); new level=War3_GetLevel(target,race_num); new xp=War3_GetXP(target,race_num); Format(longbuf,sizeof(longbuf),"%T\n","[War3Source] {racename} info for {player}. Level: {amount} XP: {amount}",client,race_name,playername,level,xp); new SkillCount = War3_GetRaceSkillCount(race_num); for(new i=1;i<=SkillCount;i++){ new String:skillname[64]; W3GetRaceSkillName(race_num,i,skillname,sizeof(skillname)); new skilllevel=War3_GetSkillLevelINTERNAL(target,race_num,i); Format(longbuf,sizeof(longbuf),"%s%T\n",longbuf,"{skillname} - Level {amount}",client,skillname,skilllevel); } new String:menuback[32]; Format(menuback,sizeof(menuback),"%T","Back",client); SetMenuTitle(playerInfo,"%s\n \n",longbuf); decl String:target_str[8]; Format(target_str,sizeof(target_str),"%d",target); AddMenuItem(playerInfo,target_str,menuback); DisplayMenu(playerInfo,client,20); } else { War3_ChatMessage(client,"%T","The player has disconnected from the server",client); War3Source_Stats(client); } } public War3Source_Stats_PRS(Handle:menu,MenuAction:action,client,selection) { if(action==MenuAction_Select) { decl String:SelectionInfo[4]; decl String:SelectionDispText[256]; new SelectionStyle; GetMenuItem(menu,selection,SelectionInfo,sizeof(SelectionInfo),SelectionStyle, SelectionDispText,sizeof(SelectionDispText)); new target=StringToInt(SelectionInfo); if(ValidPlayer(target)) War3Source_Stats_Player(client,target); else { War3_ChatMessage(client,"%T","The player you selected has left the server",client); War3Source_Stats(client); } } if(action==MenuAction_End) { CloseHandle(menu); } } War3Source_War3Top(client,top_num,cur_place=0) { new Handle:topMenu=CreateMenu(War3Source_War3Top_Selected); SetMenuExitButton(topMenu,false); if(cur_place<0) cur_place=0; new total_display=cur_place+10; if(total_display>iTopCount) total_display=iTopCount; if(total_display>top_num) total_display=top_num; if(top_num>iTopCount) top_num=iTopCount; new String:menuText[512]; Format(menuText,sizeof(menuText),"%T\n","[War3Source] Top {amount} ({amount}-{amount})",client,top_num,cur_place+1,total_display); for(new x=cur_place;x0) AddMenuItem(topMenu,data_str,menuprevious); // PrintToServer("2"); DisplayMenu(topMenu,client,20); } public War3Source_War3Top_Selected(Handle:menu,MenuAction:action,client,selection) { if(action==MenuAction_Select) { decl String:SelectionInfo[18]; decl String:SelectionDispText[256]; new SelectionStyle; GetMenuItem(menu,selection,SelectionInfo,sizeof(SelectionInfo),SelectionStyle, SelectionDispText,sizeof(SelectionDispText)); new String:buffer_out[3][8]; ExplodeString(SelectionInfo,".",buffer_out,3,8); new top_num=StringToInt(buffer_out[1]); new cur_place=StringToInt(buffer_out[2]); if(buffer_out[0][0]=='n') { // next War3Source_War3Top(client,top_num,cur_place+10); } else if(buffer_out[0][0]=='p') { War3Source_War3Top(client,top_num,cur_place-10); } } if(action==MenuAction_End) { CloseHandle(menu); } }