lol
do it michaelback. do it for the community egostroking.
public Action:Hiscores(Client)
{
new Handle:hTop = CreateMenu(HiscoresHandle);
SetMenuTitle(hTop, "Hiscores:");
AddMenuItem(hTop, "1", "[Wealthiest Players]");
AddMenuItem(hTop, "2", "[Most Wanted]");
AddMenuItem(hTop, "3", "[Overall Top 10]");
AddMenuItem(hTop, "-1", "[Back to Bank]");
SetMenuPagination(hTop, 7);
DisplayMenu(hTop, Client, 30);
}
public HiscoresHandle(Handle:hTop, MenuAction:action, Client, param2)
{
decl String:sData[32];
GetMenuItem(hTop, param2, sData, sizeof(sData));
new iData = StringToInt(sData);
if(action == MenuAction_Select)
{
switch(iData)
{
case 1: //Wealthiest
{
decl String:sQuery[128];
Format(sQuery, sizeof(sQuery), "SELECT steam_id, bank, cash FROM `sapphire_players` ORDER BY bank + cash DESC LIMIT 25;");
new iUser = GetClientUserId(Client);
SQL_TQuery(g_hDB, SQL_RichestPlayers, sQuery, iUser);
}
case 2: //Most Wanted
{
decl String:sQuery[128];
Format(sQuery, sizeof(sQuery), "SELECT steam_id, crime FROM `sapphire_players` ORDER BY crime DESC LIMIT 25;");
new iUser = GetClientUserId(Client);
SQL_TQuery(g_hDB, SQL_MostWanted, sQuery, iUser);
}
case 3: //Overall
{
decl String:sQuery[128];
Format(sQuery, sizeof(sQuery), "SELECT steam_id, bank, cash, crime, income FROM `sapphire_players` ORDER BY bank + cash + crime + income DESC LIMIT 10;");
new iUser = GetClientUserId(Client);
SQL_TQuery(g_hDB, SQL_Overall, sQuery, iUser);
}
}
}
else if(action == MenuAction_End)
{
CloseHandle(hTop);
}
return;
}
public Action:Bank(Client)
{
new iPromotion = RoundToCeil(Pow(float(g_iIncome[Client]), 3.0)) - g_iMinutes[Client];
new Handle:hBank = CreateMenu(BankHandle);
SetMenuTitle(hBank, "Cash: $%i\nBank Account: $%i\nIncome: $%i\nNext Promotion: %i minutes", g_iCash[Client], g_iBank[Client], g_iIncome[Client], iPromotion);
AddMenuItem(hBank, "1", "[Withdraw]");
AddMenuItem(hBank, "2", "[Deposit]");
AddMenuItem(hBank, "3", "[Hiscores]");
SetMenuPagination(hBank, 7);
DisplayMenu(hBank, Client, 20);
}
public BankHandle(Handle:hBank, MenuAction:action, Client, param2)
{
if(action == MenuAction_Select)
{
new String:sData[64];
GetMenuItem(hBank, param2, sData, sizeof(sData));
new iData = StringToInt(sData);
switch(iData)
{
case 1:
{
WithdrawHandle(Client);
}
case 2:
{
DepositHandle(Client);
}
case 3:
{
Hiscores(Client);
}
}
}
else if(action == MenuAction_End)
{
CloseHandle(hBank);
}
return;
}
public SQL_RichestPlayers(Handle:hOwner, Handle:hHndl, const String:sError[], any:data)
{
new Client = GetClientOfUserId(data);
if(Client == 0)
{
return;
}
if (hHndl == INVALID_HANDLE)
{
LogError("[Project Sapphire] SQL_RichestPlayers: Query failed! %s", sError);
}
else
{
decl String:FormatMessage[1024], iCash[25], iBank[25], String:sSteamID[25][32];
new len = 0;
new i = 0;
len += Format(FormatMessage[len], sizeof(FormatMessage)-len, " Richest Players:\n\n");
while(SQL_FetchRow(hHndl))
{
SQL_FetchString(hHndl, 0, sSteamID[i], sizeof(sSteamID[]));
iCash[i] = SQL_FetchInt(hHndl, 1);
iBank[i] = SQL_FetchInt(hHndl, 2);
len += Format(FormatMessage[len], sizeof(FormatMessage)-len, "%i %s (%i)\n", i+1, sSteamID[i], iBank[i] + iCash[i]);
i++;
}
PrintEscapeText(Client, FormatMessage);
}
}
public SQL_MostWanted(Handle:hOwner, Handle:hHndl, const String:sError[], any:data)
{
new Client = GetClientOfUserId(data);
if(Client == 0)
{
return;
}
if (hHndl == INVALID_HANDLE)
{
LogError("[Project Sapphire] SQL_MostWanted: Query failed! %s", sError);
}
else
{
decl String:FormatMessage[2048], iCrime[25], String:sSteamID[25][32];
new len = 0;
new i = 1;
len += Format(FormatMessage[len], sizeof(FormatMessage)-len, " Most Wanted Players:\n\n");
while(SQL_FetchRow(hHndl))
{
SQL_FetchString(hHndl, 0, sSteamID[i], sizeof(sSteamID[]));
iCrime[i] = SQL_FetchInt(hHndl, 1);
if(iCrime[i] > 0)
{
len += Format(FormatMessage[len], sizeof(FormatMessage)-len, "%i %s (%i)\n", i, sSteamID[i], iCrime[i]);
}
i++;
}
PrintEscapeText(Client, FormatMessage);
}
}
public SQL_Overall(Handle:hOwner, Handle:hHndl, const String:sError[], any:data)
{
new Client = GetClientOfUserId(data);
if(Client == 0)
{
return;
}
if (hHndl == INVALID_HANDLE)
{
LogError("[Project Sapphire] SQL_Overall: Query failed! %s", sError);
}
else
{
decl String:FormatMessage[2048], String:sSteamID[25][32], iBank[25], iCash[25], iCrime[25], iIncome[25];
new len = 0;
new i = 1;
len += Format(FormatMessage[len], sizeof(FormatMessage)-len, " Overall Top Players:\n\n");
while(SQL_FetchRow(hHndl))
{
SQL_FetchString(hHndl, 0, sSteamID[i], sizeof(sSteamID[]));
iBank[i] = SQL_FetchInt(hHndl, 1);
iCash[i] = SQL_FetchInt(hHndl, 2);
iCrime[i] = SQL_FetchInt(hHndl, 3);
iIncome[i] = SQL_FetchInt(hHndl, 4);
new iTotal = iBank[i] + iCash[i] + iCrime[i] + iIncome[i];
if(iCrime[i] > 0)
{
len += Format(FormatMessage[len], sizeof(FormatMessage)-len, "%i %s (%i)\n", i, sSteamID[i], iTotal);
}
i++;
}
PrintEscapeText(Client, FormatMessage);
}
}