Added to @CrazY code, after cost you can add Team and check for specified team, not precache multiple times, i think this is better
something like this
Code:
#include <amxmodx>
#include <fun>
#define TEAM_T 1
#define TEAM_CT 2
enum _:ModelData
{
NAME[32],
MODEL[32],
COST,
TEAM
}
new const Models[][ModelData] = {
{"Name to show in menu here", "folder name inside cstrike/models/player", 2000, TEAM_T},
{"Another model", "folder name inside cstrike/models/player", 3000, TEAM_CT},
{"Another model", "folder name inside cstrike/models/player", 4000, TEAM_CT|TEAM_T}
// add more models
}
public plugin_init()
{
register_plugin("Plugin", "Version", "Author")
register_clcmd("say /models", "CommandSayModels")
}
public plugin_precache()
{
for (new i = 0, buf[128]; i < sizeof Models; i++)
{
formatex(buf, charsmax(buf), "models/player/%s/%s.mdl", Models[i][MODEL], Models[i][MODEL])
precache_model(buf)
}
}
public CommandSayModels(index)
{
ShowModelsMenu(index)
return PLUGIN_HANDLED
}
ShowModelsMenu(index, page=0)
{
new menu = menu_create("Models Menu", "HandleModelsMenu")
for (new i = 0, buf[56], len, info[3]; i < sizeof Models; i++)
{
len = copy(buf, charsmax(buf), Models[i][NAME])
// if the player doesn't have that skin, add the cost
if (has_skin == false)
len += formatex(buf[len], charsmax(buf) - len, " \y%d$", Models[i][COST])
num_to_str(i, info, charsmax(info))
menu_additem(menu, buf, info)
}
menu_display(index, menu, clamp(page, 0, menu_pages(menu) - 1))
}
public HandleModelsMenu(index, menu, item)
{
if (item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}
new info[3]
menu_item_getinfo(menu, item, _, info, charsmax(info))
menu_destroy(menu)
new model_index = str_to_num(info)
if(Models[item][TEAM] != get_user_team(index)) return 1;
// do something with model_index
return PLUGIN_HANDLED
}
__________________