Raised This Month: $ Target: $400
 0% 

Models Menu enum


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
yagami
Senior Member
Join Date: Jan 2021
Old 08-31-2022 , 15:57   Re: Models Menu enum
Reply With Quote #3

Quote:
Originally Posted by lexzor View Post
PHP Code:
#include <amxmodx>
#include <cromchat>
#include <cstrike>
#include <hamsandwich>
#include <cs_player_models_api>

#if !defined MAX_PLAYERS
    
const MAX_PLAYERS 32
#endif

enum _:ModelInfo
{
    
szModelName[64],
    
CsTeams:szTeam,
    
iGender,
    
szModelPath[64]

}

enum {
    
Male 1,
    
Female 2


new const 
g_eModels[][ModelInfo] =
{
    
    { 
"Special_CT",  CS_TEAM_CTMale"models/player/Special_CT/Special_CT.mdl" },
    { 
"Special_CT2"CS_TEAM_CTMale"models/player/Special_CT2/Special_CT2.mdl" },

    
// CT Female
    
"Perfect"CS_TEAM_CTFemale"models/player/Perfect/Perfect.mdl" },
    { 
"Pirate"CS_TEAM_CTFemale"models/player/pirate/pirate.mdl" },


    
// TR Male
    
"Trey"CS_TEAM_TMale"models/player/trey/trey.mdl" },
    { 
"Fast"CS_TEAM_TMale"models/player/fast/fast.mdl" },

    
// TR Female
    
"Ashley"CS_TEAM_TFemale"models/player/ashley/ashley.mdl" },
    { 
"Nyjon"CS_TEAM_TFemale"models/player/Nyjon/Nyjon.mdl" },
}

const 
INVALID_SKIN = -1
const MENU_ACCESS_FLAG ADMIN_LEVEL_H
const Float:CONNECT_MSG_DELAY 5.0

new g_iModel[MAX_PLAYERS 1][CsTeams]

public 
plugin_init()
{
    
register_plugin("Models Menu""1.0""OciXCrom")
    
RegisterHam(Ham_Spawn"player""OnPlayerSpawn"1)

    
register_clcmd("say /vip""Cmd_VipSkin")
    
register_clcmd("say_team /vip""Cmd_VipSkin")

    
CC_SetPrefix("&x04[Prefix]")
}

public 
plugin_precache()
{
    for(new 
isizeof(g_eModels); i++)
    {
        
precache_player_model(g_eModels[i][szModelName])
    }
}

public 
client_putinserver(id)
{
    for(new 
CsTeams:iTeam CS_TEAM_UNASSIGNEDiTeam <= CS_TEAM_SPECTATORiTeam++)
    {
        
g_iModel[id][iTeam] = INVALID_SKIN
    
}

    
set_task(CONNECT_MSG_DELAY"DisplayMessage"id)
}

public 
DisplayMessage(id)
{
    if(
is_user_connected(id) && has_menu_access(id))
    {
        
CC_SendMessage(id"Type &x03/vipskin &x01to open the &x04VIP Skin Menu")
    }
}

public 
OnPlayerSpawn(id)
{
    if(!
is_user_alive(id))
    {
        return
    }

    new 
iModel g_iModel[id][cs_get_user_team(id)]

    if(
iModel == INVALID_SKIN)
    {
        return
    }

    
cs_set_user_model(idg_eModels[iModel][szModelPath])
}

public 
Cmd_VipSkin(id)
{
    if(!
has_menu_access(id))
    {
        
CC_SendMessage(id"Only vips can open this menu, sorry!")
        return 
PLUGIN_HANDLED
    
}

    new 
CsTeams:csTeam cs_get_user_team(id);

    new 
iMenu menu_create("Selecione Sua skin111""VipSkin_Handler")

    for(new 
iszItemIndex[2]; sizeof(g_eModels); i++)
    {
        if(
g_eModels[i][szTeam] == csTeam)
        {
            
num_to_str(iszItemIndexcharsmax(szItemIndex));
            
menu_additem(iMenug_eModels[i][szModelName], szItemIndex);
        }
    }
   
    
menu_setprop(iMenuMPROP_EXITNAME"Sair")
    
menu_display(idiMenu)

    return 
PLUGIN_HANDLED 
}

public 
VipSkin_Handler(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }

    new 
szItemIndex[2];
    
menu_item_getinfo(menuitem_szItemIndexcharsmax(szItemIndex), ___);

    
g_iModel[id][cs_get_user_team(id)] = str_to_num(szItemIndex);

    return 
PLUGIN_CONTINUE;
}

bool:has_menu_access(id)
{
    return (
get_user_flags(id) & MENU_ACCESS_FLAG) != 0
}

precache_player_model(const szModel[], &id 0)
{
    new 
model[128]
    
formatex(modelcharsmax(model), "models/player/%s/%sT.mdl"szModelszModel)

    if(
file_exists(model))
        
id precache_generic(model)

    static const 
extension[] = "T.mdl"
    
#pragma unused extension

    
copy(model[strlen(model) - charsmax(extension)], charsmax(model), ".mdl")
    return 
precache_model(model)

and use this api for setting player models https://forums.alliedmods.net/showthread.php?t=319819 or reapi https://amxx-bg.info/api/reapi_gamed...set_user_model
Exemple:

PHP Code:
Menu() 
{
CT
Male Models 
Male Menu
Female Models 
Female Menu

PHP Code:
Menu()
{
TR
Male Models 
Male Menu
Female Models 
Male Menu


Last edited by yagami; 08-31-2022 at 15:57.
yagami is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:35.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode