Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
170 changes: 85 additions & 85 deletions scripting/include/kento_rankme/cmds.inc
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public Action CMD_TopWeapon(int client, int args){
} else {
Menu menu = CreateMenu(MenuHandler_TopWeapon_Choose);
menu.SetTitle("Top Weapon:");
for(int i=0;i<42;i++){
for(int i=0;i<51;i++){
menu.AddItem(g_sWeaponsNamesGame[i],g_sWeaponsNamesFull[i]);
}
menu.Display(client,MENU_TIME_FOREVER);
Expand Down Expand Up @@ -335,72 +335,72 @@ void ShowTOP(int client, int at){
}

public void SQL_TopCallback(Handle owner, Handle hndl, const char[] error, any Datapack){
if(hndl == INVALID_HANDLE)
{
LogError("[RankMe] Query Fail: %s", error);
PrintToServer(error);
return;
}

ResetPack(Datapack);
int i;
int client = ReadPackCell(Datapack);
if(client == 0 || !IsClientInGame(client))
return;
int at = ReadPackCell(Datapack);
CloseHandle(Datapack);
if(!SQL_HasResultSet(hndl) || SQL_GetRowCount(hndl) ==0){
ShowTOP(client,g_TotalPlayers-9);
return;
}
char name[256];
char temp[500];

Menu menu = CreateMenuEx(GetMenuStyleHandle(MenuStyle_Radio),MenuHandler_Top);

float kdr;
Format(temp,sizeof(temp)," %T\n","Showing",client,at+1,at+10,g_TotalPlayers);
menu.SetTitle("");
char sBuffer[200];
while(SQL_HasResultSet(hndl) && SQL_FetchRow(hndl))
{

i++;

SQL_FetchString(hndl,2,name,sizeof(name));


int deaths;
if(SQL_FetchInt(hndl,6) == 0)
deaths = 1;
else
deaths=SQL_FetchInt(hndl,6);

kdr = SQL_FetchFloat(hndl,5)/deaths;
Format(sBuffer,sizeof(sBuffer),"%d - %s (%d) - KDR: %.2f\n",i+at,name,SQL_FetchInt(hndl,4),kdr);

if(strlen(temp)+strlen(sBuffer) < MAX_LENGTH_MENU){
Format(temp,sizeof(temp),"%s%s",temp,sBuffer);
sBuffer="\0";
}
}
Format(temp,sizeof(temp),"%s\n",temp);
menu.AddItem(temp,temp);


IntToString(at+i,temp,sizeof(temp));
char temp1[20];
Format(temp1,sizeof(temp1),"%T","Next",client);
if(i>9)
menu.AddItem(temp,temp1);
IntToString(at-i,temp,sizeof(temp));
Format(temp1,sizeof(temp1),"%T","Back",client);
if(at+i-1 >9)
menu.AddItem(temp,temp1);

menu.DisplayAt(client,at,MENU_TIME_FOREVER);
if(hndl == INVALID_HANDLE)
{
LogError("[RankMe] Query Fail: %s", error);
PrintToServer(error);
return;
}

ResetPack(Datapack);
int client = ReadPackCell(Datapack);
if(client == 0 || !IsClientInGame(client))
return;

int at = ReadPackCell(Datapack);
CloseHandle(Datapack);

if(!SQL_HasResultSet(hndl) || SQL_GetRowCount(hndl) == 0){
ShowTOP(client, g_TotalPlayers - 9);
return;
}

char name[256];
char temp[500];
Menu menu = CreateMenuEx(GetMenuStyleHandle(MenuStyle_Radio), MenuHandler_Top);
float kdr;
Format(temp, sizeof(temp), " %T\n", "Showing", client, at + 1, at + 5, g_TotalPlayers); // Show up to 5 players

char sBuffer[200];
int i = 0; // Initialize the counter here
while(SQL_HasResultSet(hndl) && SQL_FetchRow(hndl) && i < 5) // Limit to 5 players
{
i++;
SQL_FetchString(hndl, 2, name, sizeof(name));

int deaths = SQL_FetchInt(hndl, 6);
if(deaths == 0)
deaths = 1; // Avoid division by zero

kdr = SQL_FetchFloat(hndl, 5) / deaths;
Format(sBuffer, sizeof(sBuffer), "%d - %s (%d) - Kills: %d, Deaths: %d, Headshots: %d, KDR: %.2f\n",
i + at, name, SQL_FetchInt(hndl, 4), SQL_FetchInt(hndl, 5),
deaths, SQL_FetchInt(hndl, 12), kdr);

if(strlen(temp) + strlen(sBuffer) < MAX_LENGTH_MENU){
Format(temp, sizeof(temp), "%s%s", temp, sBuffer);
sBuffer[0] = '\0'; // Clear buffer
}
}

Format(temp, sizeof(temp), "%s\n", temp);
menu.AddItem(temp, temp);

// Only add next/back if applicable
IntToString(at + i, temp, sizeof(temp));
char temp1[20];
Format(temp1, sizeof(temp1), "%T", "Next", client);
if(i == 5) // Show next only if we have 5 players
menu.AddItem(temp, temp1);
IntToString(at - i, temp, sizeof(temp));
Format(temp1, sizeof(temp1), "%T", "Back", client);
if(at + i - 1 > 5) // Show back if we have more than 5 in the previous pages
menu.AddItem(temp, temp1);

menu.DisplayAt(client, at, MENU_TIME_FOREVER);
}


public int MenuHandler_Top(Menu menu, MenuAction action, int param1, int param2){

if (action == MenuAction_Select)
Expand Down Expand Up @@ -590,7 +590,7 @@ public void SQL_TopKillsCallback(Handle owner, Handle hndl, const char[] error,

Menu menu = CreateMenuEx(GetMenuStyleHandle(MenuStyle_Radio),MenuHandler_TopKills);

Format(temp,sizeof(temp)," %T\n","Showing",client,at+1,at+10,g_TotalPlayers);
Format(temp,sizeof(temp)," %T\n","Showing",client,at+1,at+5,g_TotalPlayers);
menu.SetTitle("");
char sBuffer[200];
while(SQL_HasResultSet(hndl) && SQL_FetchRow(hndl))
Expand Down Expand Up @@ -1489,7 +1489,7 @@ public void SQL_StatsMe2Callback(Handle owner, Handle hndl, const char[] error,
rounds = 1;
}

int idamage = SQL_FetchInt(hndl,76);
int idamage = SQL_FetchInt(hndl,85);
float damage = IntToFloat(idamage);

int hits = SQL_FetchInt(hndl,11);
Expand All @@ -1509,22 +1509,22 @@ public void SQL_StatsMe2Callback(Handle owner, Handle hndl, const char[] error,
StrCat(text,sizeof(text),temp);
Format(temp,sizeof(temp),"%T: %d %T: %.2f %T: %.2f\n","Damage", client, idamage,"KPR", client, kills/rounds, "DPR", client, damage/rounds);
StrCat(text,sizeof(text),temp);
Format(temp,sizeof(temp),"%T: %d \n","First Bloods", client, SQL_FetchInt(hndl, 80));
Format(temp,sizeof(temp),"%T: %d \n","First Bloods", client, SQL_FetchInt(hndl, 89));
StrCat(text,sizeof(text),temp);
Format(temp,sizeof(temp),"%T: %d %T: %d\n","Thru Smokes", client, SQL_FetchInt(hndl, 83), "Flashed Kills", client, SQL_FetchInt(hndl, 84));
Format(temp,sizeof(temp),"%T: %d %T: %d\n","Thru Smokes", client, SQL_FetchInt(hndl, 92), "Flashed Kills", client, SQL_FetchInt(hndl, 93));
StrCat(text,sizeof(text),temp);
Format(temp,sizeof(temp),"%T: %d\n","AssistFlashes", client, SQL_FetchInt(hndl, 85));
Format(temp,sizeof(temp),"%T: %d\n","AssistFlashes", client, SQL_FetchInt(hndl, 94));
StrCat(text,sizeof(text),temp);
Format(temp,sizeof(temp),"%T: %d\n","AssistTeamFlashes", client, SQL_FetchInt(hndl, 86));
Format(temp,sizeof(temp),"%T: %d\n","AssistTeamFlashes", client, SQL_FetchInt(hndl, 95));
StrCat(text,sizeof(text),temp);
Format(temp,sizeof(temp),"%T: %d\n","Wallbangs", client, SQL_FetchInt(hndl, 88));
Format(temp,sizeof(temp),"%T: %d\n","Wallbangs", client, SQL_FetchInt(hndl, 97));
StrCat(text,sizeof(text),temp);
panel.AddItem("",text);
text="";

Format(temp,sizeof(temp),"- %T\n","RoundStats",client);
StrCat(text,sizeof(text),temp);
Format(temp,sizeof(temp),"%T: %d/%d %T: %d/%d %T: %d\n%T: %d %T: %d %T: %d\n","TRWins",client,SQL_FetchInt(hndl,70),SQL_FetchInt(hndl,14),"CTWins",client,SQL_FetchInt(hndl,69),SQL_FetchInt(hndl,15),"MVPs",client,SQL_FetchInt(hndl,75), "MatchWins", client, SQL_FetchInt(hndl, 77), "MatchDraws", client, SQL_FetchInt(hndl, 78), "MatchLosses", client, SQL_FetchInt(hndl, 79));
Format(temp,sizeof(temp),"%T: %d/%d %T: %d/%d %T: %d\n%T: %d %T: %d %T: %d\n","TRWins",client,SQL_FetchInt(hndl,79),SQL_FetchInt(hndl,14),"CTWins",client,SQL_FetchInt(hndl,78),SQL_FetchInt(hndl,15),"MVPs",client,SQL_FetchInt(hndl,84), "MatchWins", client, SQL_FetchInt(hndl, 86), "MatchDraws", client, SQL_FetchInt(hndl, 87), "MatchLosses", client, SQL_FetchInt(hndl, 88));
StrCat(text,sizeof(text),temp);
panel.AddItem("",text);
text="";
Expand All @@ -1538,24 +1538,24 @@ public void SQL_StatsMe2Callback(Handle owner, Handle hndl, const char[] error,

Format(temp,sizeof(temp),"- %T\n","NoScopeStats",client);
StrCat(text,sizeof(text),temp);
Format(temp,sizeof(temp),"%T: %d %T: %.2fm \n","NoScopes",client,SQL_FetchInt(hndl,81), "Farthest", client, IntToFloat(SQL_FetchInt(hndl,82))/100 );
Format(temp,sizeof(temp),"%T: %d %T: %.2fm \n","NoScopes",client,SQL_FetchInt(hndl,90), "Farthest", client, IntToFloat(SQL_FetchInt(hndl,91))/100 );
StrCat(text,sizeof(text),temp);
panel.AddItem("",text);
text="";

Format(temp,sizeof(temp),"- %T\n","BombHostagesStats",client);
StrCat(text,sizeof(text),temp);
Format(temp,sizeof(temp),"%T: %d %T: %d %T: %d\n","PlantedBombs",client,SQL_FetchInt(hndl,66),"ExplodedBombs",client,SQL_FetchInt(hndl,67),"DefusedBombs",client,SQL_FetchInt(hndl,68));
Format(temp,sizeof(temp),"%T: %d %T: %d %T: %d\n","PlantedBombs",client,SQL_FetchInt(hndl,75),"ExplodedBombs",client,SQL_FetchInt(hndl,76),"DefusedBombs",client,SQL_FetchInt(hndl,77));
StrCat(text,sizeof(text),temp);
Format(temp,sizeof(temp),"%T: %d\n","RescuedHostages",client,SQL_FetchInt(hndl,71));
Format(temp,sizeof(temp),"%T: %d\n","RescuedHostages",client,SQL_FetchInt(hndl,80));
StrCat(text,sizeof(text),temp);
panel.AddItem("",text);
text="";

if(g_bVipEnabled){
Format(temp,sizeof(temp),"- %T\n","VIPStats",client);
StrCat(text,sizeof(text),temp);
Format(temp,sizeof(temp),"%T: %d/%d %T: %d\n","VIPEscapes",client,SQL_FetchInt(hndl,73),SQL_FetchInt(hndl,74),"VIPsKilled",client,SQL_FetchInt(hndl,72));
Format(temp,sizeof(temp),"%T: %d/%d %T: %d\n","VIPEscapes",client,SQL_FetchInt(hndl,82),SQL_FetchInt(hndl,83),"VIPsKilled",client,SQL_FetchInt(hndl,81));
StrCat(text,sizeof(text),temp);
panel.AddItem("",text);
text="";
Expand Down Expand Up @@ -2423,7 +2423,7 @@ public void SQL_TopMVPCallback(Handle owner, Handle hndl, const char[] error, an



Format(sBuffer,sizeof(sBuffer),"%d - %s (%d) - %t: %d\n",i+at,name,SQL_FetchInt(hndl,4),"MVPs",SQL_FetchInt(hndl,75));
Format(sBuffer,sizeof(sBuffer),"%d - %s (%d) - %t: %d\n",i+at,name,SQL_FetchInt(hndl,4),"MVPs",SQL_FetchInt(hndl,84));

if(strlen(temp)+strlen(sBuffer) < MAX_LENGTH_MENU){
Format(temp,sizeof(temp),"%s%s",temp,sBuffer);
Expand Down Expand Up @@ -2537,7 +2537,7 @@ public void SQL_TopDamageCallback(Handle owner, Handle hndl, const char[] error,



Format(sBuffer,sizeof(sBuffer),"%d - %s (%d) - %t: %d\n",i+at,name,SQL_FetchInt(hndl,4),"Damage",SQL_FetchInt(hndl,74));
Format(sBuffer,sizeof(sBuffer),"%d - %s (%d) - %t: %d\n",i+at,name,SQL_FetchInt(hndl,4),"Damage",SQL_FetchInt(hndl,85));

if(strlen(temp)+strlen(sBuffer) < MAX_LENGTH_MENU){
Format(temp,sizeof(temp),"%s%s",temp,sBuffer);
Expand Down Expand Up @@ -2891,7 +2891,7 @@ public void SQL_TopFBCallback(Handle owner, Handle hndl, const char[] error, any
i++;
SQL_FetchString(hndl,2,name,sizeof(name));

Format(sBuffer,sizeof(sBuffer),"%d - %s (%d) : %d\n",i+at,name,SQL_FetchInt(hndl,4),SQL_FetchInt(hndl,80));
Format(sBuffer,sizeof(sBuffer),"%d - %s (%d) : %d\n",i+at,name,SQL_FetchInt(hndl,4),SQL_FetchInt(hndl,89));

if(strlen(temp)+strlen(sBuffer) < MAX_LENGTH_MENU){
Format(temp,sizeof(temp),"%s%s",temp,sBuffer);
Expand Down Expand Up @@ -3000,7 +3000,7 @@ public void SQL_TopNSCallback(Handle owner, Handle hndl, const char[] error, any
i++;
SQL_FetchString(hndl,2,name,sizeof(name));

Format(sBuffer,sizeof(sBuffer),"%d - %s (%d) : %d\n",i+at,name,SQL_FetchInt(hndl,4),SQL_FetchInt(hndl,81));
Format(sBuffer,sizeof(sBuffer),"%d - %s (%d) : %d\n",i+at,name,SQL_FetchInt(hndl,4),SQL_FetchInt(hndl,90));

if(strlen(temp)+strlen(sBuffer) < MAX_LENGTH_MENU){
Format(temp,sizeof(temp),"%s%s",temp,sBuffer);
Expand Down Expand Up @@ -3110,7 +3110,7 @@ public void SQL_TopNSDCallback(Handle owner, Handle hndl, const char[] error, an
SQL_FetchString(hndl,2,name,sizeof(name));


Format(sBuffer,sizeof(sBuffer),"%d - %s (%d) : %.2fm\n",i+at,name,SQL_FetchInt(hndl,4), IntToFloat(SQL_FetchInt(hndl,82))/100);
Format(sBuffer,sizeof(sBuffer),"%d - %s (%d) : %.2fm\n",i+at,name,SQL_FetchInt(hndl,4), IntToFloat(SQL_FetchInt(hndl,91))/100);

if(strlen(temp)+strlen(sBuffer) < MAX_LENGTH_MENU){
Format(temp,sizeof(temp),"%s%s",temp,sBuffer);
Expand Down Expand Up @@ -3219,7 +3219,7 @@ public void SQL_TopBlindCallback(Handle owner, Handle hndl, const char[] error,
i++;
SQL_FetchString(hndl,2,name,sizeof(name));

Format(sBuffer,sizeof(sBuffer),"%d - %s (%d) : %d\n",i+at,name,SQL_FetchInt(hndl,4),SQL_FetchInt(hndl,84));
Format(sBuffer,sizeof(sBuffer),"%d - %s (%d) : %d\n",i+at,name,SQL_FetchInt(hndl,4),SQL_FetchInt(hndl,93));

if(strlen(temp)+strlen(sBuffer) < MAX_LENGTH_MENU){
Format(temp,sizeof(temp),"%s%s",temp,sBuffer);
Expand Down Expand Up @@ -3328,7 +3328,7 @@ public void SQL_TopSmokeCallback(Handle owner, Handle hndl, const char[] error,
i++;
SQL_FetchString(hndl,2,name,sizeof(name));

Format(sBuffer,sizeof(sBuffer),"%d - %s (%d) : %d\n",i+at,name,SQL_FetchInt(hndl,4),SQL_FetchInt(hndl,83));
Format(sBuffer,sizeof(sBuffer),"%d - %s (%d) : %d\n",i+at,name,SQL_FetchInt(hndl,4),SQL_FetchInt(hndl,92));

if(strlen(temp)+strlen(sBuffer) < MAX_LENGTH_MENU){
Format(temp,sizeof(temp),"%s%s",temp,sBuffer);
Expand Down Expand Up @@ -3437,7 +3437,7 @@ public void SQL_TopWallCallback(Handle owner, Handle hndl, const char[] error, a
i++;
SQL_FetchString(hndl,2,name,sizeof(name));

Format(sBuffer,sizeof(sBuffer),"%d - %s (%d) : %d\n",i+at,name,SQL_FetchInt(hndl,4),SQL_FetchInt(hndl,88));
Format(sBuffer,sizeof(sBuffer),"%d - %s (%d) : %d\n",i+at,name,SQL_FetchInt(hndl,4),SQL_FetchInt(hndl,97));

if(strlen(temp)+strlen(sBuffer) < MAX_LENGTH_MENU){
Format(temp,sizeof(temp),"%s%s",temp,sBuffer);
Expand Down
4 changes: 2 additions & 2 deletions scripting/include/kento_rankme/natives.inc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
CreateNative("RankMe_GetHitbox", Native_GetHitbox);
CreateNative("RankMe_IsPlayerLoaded", Native_IsPlayerLoaded);

RegPluginLibrary("rankme");
RegPluginLibrary("rankme_advanced");

return APLRes_Success;
}
Expand Down Expand Up @@ -218,4 +218,4 @@ public int Native_IsPlayerLoaded(Handle plugin, int numParams)
{
int client = GetNativeCell(1);
return OnDB[client];
}
}
Loading