Hello there guys.
I have developed my own csgo ranks plugin, it's based by points.
More points you have, then higher rank you get silver 1 to global elite.
Now i added a feature to loose points, but when client goes to 0 or less there is spamming error in console that array index out of bounds, that's reasonable, because i didin't secure that.
Anyway, i have administration panel written by myself that allows admin to take the points from players
Code:
public Action CreateMenu_AddRemovePoints(int admin, int client, int iSelect)
{
Menu next = new Menu(PointAct_MenuHandler);
char frm[128];
char pname[MAX_NAME_LENGTH + 1];
GetClientName(client, pname, sizeof pname);
Format(frm, sizeof frm, "Rangi - %s", pname);
next.SetTitle(frm);
next.AddItem("1", "1 point");
next.AddItem("5", "5 Points");
next.AddItem("10", "100 Points");
next.AddItem("20", "200 Points");
next.AddItem("50", "500 Points");
next.AddItem("100", "1000 Points");
next.AddItem("5000", "5000 Points");
char sInfo[12];
Format(sInfo, sizeof(sInfo), "%d", iSelect);
next.AddItem("-SELECT-", sInfo, ITEMDRAW_IGNORE);
Format(sInfo, sizeof(sInfo), "%d", client);
next.AddItem("-CLIENT-", sInfo, ITEMDRAW_IGNORE);
next.ExitButton = true;
next.Display(admin, 60);
}
How can i do when player have less points than first value in the menu for example 100, if player have less than 100 points so this specific item in menu will have tag [X] and ITEMDRAW_DISABLED?
I don't know how can i get the first values of the menu in very simple way.
For a current solution i did something like that, but still i want this 1st option to work
Code:
if (iSelect == 1)
g_iPoints[client] +=StringToInt(item);
else if (iSelect == 2)
if(g_iPoints[client] < StringToInt(item))
{
CPrintToChat(client, "{darkred}[✖] {yellow}You can't choose this option because client will have less than 0 points.", g_iPoints[client]);
}
else
{
g_iPoints[client] -= StringToInt(item);
}
CreateMenu_AddRemovePoints(param1, client, iSelect);
CheckRank(client);
Appreciate any tips and help.