While I was cleaning your code to give you a good example I've notice you misuse the function rm.AddItem, AddItem doesn't support string formatting you have to use the function Format
References:
https://sm.alliedmods.net/new-api/menus/Menu/AddItem
https://sm.alliedmods.net/new-api/string/Format
PHP Code:
#pragma semicolon 1
#define DEBUG
#define PLUGIN_AUTHOR "SpirT"
#define PLUGIN_VERSION "1.0.0"
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#pragma newdecls required
public Plugin myinfo =
{
name = "Rules",
author = PLUGIN_AUTHOR,
description = "Description of 'sm_rules'",
version = PLUGIN_VERSION,
url = "https://sm.blcm.pt"
};
ConVar menuOptions[10];
public void OnPluginStart()
{
char title[128];
char description[128];
char convarName[128];
for (int i = 0; i < sizeof(menuOptions); i++) {
Format(convarName, sizeof(convarName), "sm_title_option%d", i+1);
Format(title, sizeof(title), "Title %d", i+1);
Format(description, sizeof(description), "Title of the option %d", i+1);
menuOptions[i] = CreateConVar(convarName, title, description);
}
}
public Menu RegrasMenu()
{
char optionNum[2];
char optionText[128];
Menu rm = new Menu(rm_handler, MENU_ACTIONS_ALL);
for (int i = 0; i < sizeof(menuOptions); i++) {
GetConVarString(menuOptions[i], optionText, sizeof(optionText));
// \0 is a empty character, if the first charater is empty strlen = 0
if (optionText[0] == '\0') continue;
IntToString(i, optionNum, sizeof(optionNum));
rm.AddItem(optionNum, optionText);
}
rm.ExitButton = true;
rm.ExitBackButton = false;
return rm;
}
public int rm_handler(Menu rm, MenuAction action, int client, int item)
{
}