you need something like this but keep in mind that the folder name must match player model name.
for eg. elastigirl/elastigirl.mdl and not extra/elastigirl.mdl
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <hamsandwich>
enum _:Models
{
Name[20],
NameModel[20],
RUTA[126],
FlagAdmin
}
new const g_eModels[][Models] =
{
{ "hutao", "hutao", "models/player/hutao/hutao.mdl" , ADMIN_ALL},
{ "spiderman", "admin_spiderman", "models/player/donald/admin_spiderman.mdl", ADMIN_SLAY},
{ "woailuo", "flash_woailuo", "models/player/donald/flash_woailuo.mdl", ADMIN_LEVEL_B}
}
new my_model[MAX_PLAYERS + 1]
public plugin_init()
{
register_clcmd("say /test", "ModelMenu")
RegisterHam(Ham_Spawn, "player", "HookSpawn", 1)
}
public plugin_precache()
{
for(new i; i < sizeof(g_eModels); i++)
precache_generic(g_eModels[i][RUTA])
}
public client_putinserver(id)
my_model[id] = 0
public HookSpawn(id)
cs_set_user_model(id, g_eModels[my_model[id]][NameModel])
public ModelMenu(id)
{
new iMenu = menu_create("Models Menu", "ModelsHandler")
for(new i; i < sizeof(g_eModels); i++)
menu_additem(iMenu, g_eModels[i][Name])
menu_display(id, iMenu, 0)
return PLUGIN_HANDLED
}
public ModelsHandler(id, iMenu, iItem){
if (iItem > MENU_MORE){
if (access(id, g_eModels[iItem][FlagAdmin])){
my_model[id] = iItem
cs_set_user_model(id, g_eModels[my_model[id]][NameModel])
client_print(id, print_chat, "Selected Model: %s", g_eModels[my_model[id]][Name])
}
else
client_print(id, print_chat, "You don't have permission")
}
menu_destroy(iMenu)
}
__________________