I need help to adapt the snippet of code to the new syntax, but unfortunately I do not know much about it and I am trying to make updates to the plugin which is slightly modified
HTML Code:
public Action:CMD_RankRank(client,args){
if(!g_bEnabled || client == 0 || !IsClientInGame(client))
return Plugin_Handled;
new String:arg1[5];
GetCmdArg(1,arg1,sizeof(arg1));
if(!StrEqual(arg1,"") && StringToInt(arg1) != 0){
ShowTopRank(client,StringToInt(arg1));
} else {
ShowTopRank(client,0);
}
return Plugin_Handled;
}
ShowTopRank(client,at){
if(client == 0 || !IsClientInGame(client))
return;
new Handle:Datapack= CreateDataPack();
WritePackCell(Datapack,client);
if(at>0){
WritePackCell(Datapack,at-1);
} else {
WritePackCell(Datapack,0);
at = 1; // For not needing to build twice the query. (for at > 0 and at <= 0)
}
new String:query[2000];
MakeSelectQuery(query,sizeof(query));
Format(query,sizeof(query),"%s ORDER BY rank DESC, score DESC LIMIT %i, 10",query,at-1);
SQL_TQuery(g_hStatsDb,SQL_TopRankCallback,query,Datapack);
}
public SQL_TopRankCallback(Handle:owner, Handle:hndl, const String:error[], any:Datapack){
if(hndl == INVALID_HANDLE)
{
LogError("[RankMe] Query Fail: %s", error);
PrintToServer(error);
return;
}
ResetPack(Datapack);
new i;
new client = ReadPackCell(Datapack);
if(client == 0 || !IsClientInGame(client))
return;
new at = ReadPackCell(Datapack);
CloseHandle(Datapack);
if(!SQL_HasResultSet(hndl) || SQL_GetRowCount(hndl) ==0){
ShowTopRank(client,g_TotalPlayers-9);
return;
}
new String:name[256];
new String:temp[500];
new Handle:menu = CreateMenuEx(GetMenuStyleHandle(MenuStyle:MenuStyle_Radio),MenuHandler_Rank);
Format(temp,sizeof(temp)," %T\n","Showing",client,at+1,at+10,g_TotalPlayers);
SetMenuTitle(menu,"[#TOP] Nick - Ranga - Punkty");
new String:sBuffer[200];
while(SQL_HasResultSet(hndl) && SQL_FetchRow(hndl))
{
i++;
SQL_FetchString(hndl,2,name,sizeof(name));
Format(sBuffer,sizeof(sBuffer),"#%d - %s - %s - [%d]\n",i+at,name, g_sRanksNames[SQL_FetchInt(hndl,78)],SQL_FetchInt(hndl,4));
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);
AddMenuItem(menu,temp,temp);
IntToString(at+i,temp,sizeof(temp));
new String:temp1[20];
Format(temp1,sizeof(temp1),"%T","Next",client);
if(i>9)
AddMenuItem(menu,temp,temp1);
IntToString(at-i,temp,sizeof(temp));
Format(temp1,sizeof(temp1),"%T","Back",client);
if(at+i-1 >9)
AddMenuItem(menu,temp,temp1);
DisplayMenuAtItem(menu,client,at,MENU_TIME_FOREVER);
}
public Action:CMD_RankScore(client,args){
if(!g_bEnabled || client == 0 || !IsClientInGame(client))
return Plugin_Handled;
new String:arg1[5];
GetCmdArg(1,arg1,sizeof(arg1));
if(!StrEqual(arg1,"") && StringToInt(arg1) != 0){
ShowTopScore(client,StringToInt(arg1));
} else {
ShowTopScore(client,0);
}
return Plugin_Handled;
}
ShowTopScore(client,at){
if(client == 0 || !IsClientInGame(client))
return;
new Handle:Datapack= CreateDataPack();
WritePackCell(Datapack,client);
if(at>0){
WritePackCell(Datapack,at-1);
} else {
WritePackCell(Datapack,0);
at = 1; // For not needing to build twice the query. (for at > 0 and at <= 0)
}
new String:query[2000];
MakeSelectQuery(query,sizeof(query));
Format(query,sizeof(query),"%s ORDER BY score DESC LIMIT %i, 10",query,at-1);
SQL_TQuery(g_hStatsDb,SQL_TopScoreCallback,query,Datapack);
}
public SQL_TopScoreCallback(Handle:owner, Handle:hndl, const String:error[], any:Datapack){
if(hndl == INVALID_HANDLE)
{
LogError("[RankMe] Query Fail: %s", error);
PrintToServer(error);
return;
}
ResetPack(Datapack);
new i;
new client = ReadPackCell(Datapack);
if(client == 0 || !IsClientInGame(client))
return;
new at = ReadPackCell(Datapack);
CloseHandle(Datapack);
if(!SQL_HasResultSet(hndl) || SQL_GetRowCount(hndl) ==0){
ShowTopScore(client,g_TotalPlayers-9);
return;
}
new String:name[256];
new String:temp[500];
new Handle:menu = CreateMenuEx(GetMenuStyleHandle(MenuStyle:MenuStyle_Radio),MenuHandler_ScoreKills);
Format(temp,sizeof(temp)," %T\n","Showing",client,at+1,at+10,g_TotalPlayers);
SetMenuTitle(menu,"[#TOP] Nick - Ranga - Punkty");
new String:sBuffer[200];
while(SQL_HasResultSet(hndl) && SQL_FetchRow(hndl))
{
i++;
SQL_FetchString(hndl,2,name,sizeof(name));
Format(sBuffer,sizeof(sBuffer),"#%d - %s - %s - [%d]\n",i+at,name, g_sRanksNames[SQL_FetchInt(hndl,78)],SQL_FetchInt(hndl,4));
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);
AddMenuItem(menu,temp,temp);
IntToString(at+i,temp,sizeof(temp));
new String:temp1[20];
Format(temp1,sizeof(temp1),"%T","Next",client);
if(i>9)
AddMenuItem(menu,temp,temp1);
IntToString(at-i,temp,sizeof(temp));
Format(temp1,sizeof(temp1),"%T","Back",client);
if(at+i-1 >9)
AddMenuItem(menu,temp,temp1);
DisplayMenuAtItem(menu,client,at,MENU_TIME_FOREVER);
}