I want to randomize some constants but i'm having trouble with it.
Code:
new const constants[][] =
{
"constant1",
"constant2",
"constant3",
"constant4",
"constant5",
"constan6"
}
so i wanna generate the menu to be displayed randomly, i took a look over here:
https://forums.alliedmods.net/showth...=74666?t=74666 but it's a little bit tricky.
Code:
public menu_display(id)
{
new menu = menu_create("Constantss", "handler_constants");
/* for (new i = 0; i <sizeof(constants); i++)
{
menu_additem(menu, constants[i], "", 0); // case 0
} */
//Here it should be randomized to additem randomly according to what's in the constantans list
menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
menu_display(id, menu, 0);
return PLUGIN_HANDLED;
}
Code:
public handler_constants(id, menu, item)
{
if(item == MENU_EXIT)
{
menu_cancel(id);
return PLUGIN_HANDLED;
}
//client_print(id, print_chat, "You have selected %s", constants[item])
//Here the randomized list generated above should be called corectly.
menu_destroy(menu);
return PLUGIN_HANDLED;
}
Any ideas how to do that ? I'm thinking pushing them into the arrays, but i don't know how to corectly use them in the handler....