Thread: [Solved] menu_additem flag
View Single Post
bigdaddy424
Senior Member
Join Date: Oct 2021
Location: Jupiter
Old 03-18-2023 , 16:30   Re: menu_additem flag
Reply With Quote #8

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 
isizeof(g_eModels); i++)
        
precache_generic(g_eModels[i][RUTA])
}

public 
client_putinserver(id)
    
my_model[id] = 0

public HookSpawn(id)
    
cs_set_user_model(idg_eModels[my_model[id]][NameModel])

public 
ModelMenu(id)
{
    new 
iMenu menu_create("Models Menu""ModelsHandler")
    
    for(new 
isizeof(g_eModels); i++)
        
menu_additem(iMenug_eModels[i][Name])
    
menu_display(idiMenu0)
    
    return 
PLUGIN_HANDLED
}

public 
ModelsHandler(idiMenuiItem){
    if (
iItem MENU_MORE){
        if (
access(idg_eModels[iItem][FlagAdmin])){
            
my_model[id] = iItem
            cs_set_user_model
(idg_eModels[my_model[id]][NameModel])
            
client_print(idprint_chat"Selected Model: %s"g_eModels[my_model[id]][Name])
            
        }
        
        else
            
client_print(idprint_chat"You don't have permission")
    }

    
menu_destroy(iMenu)

__________________

Last edited by bigdaddy424; 03-18-2023 at 18:01.
bigdaddy424 is offline