AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Models Menu enum (https://forums.alliedmods.net/showthread.php?t=339310)

yagami 08-31-2022 12:00

Models Menu enum
 
Once again I am here to try to solve my problem
what I'm trying to do is pull the models by "Name", "Time", "Gender".

Exemple:
CT
Male Models - Male Menu
Female Models - Female Menu

TR
Male Models - Male Menu
Female Models - Male Menu

So when the player type /MODELS it will appear menu there will be two options
Male and Female then from there you choose which type of skin you want remembering to "szTeam

I tried to do this yesterday and I was almost 3 hours and could not please someone help me

I tried to use switch(item)
case 1, 2 and I couldn't and now I'm trying to use switch(iTeam)


PHP Code:

#include <amxmodx>
#include <cromchat>
#include <cstrike>
#include <hamsandwich>
#include <cs_player_models_api>

#if !defined MAX_PLAYERS
const MAX_PLAYERS 32
#endif

new g_iUserGender[MAX_PLAYERS 1];

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][szModelName])
}

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

    static 
iTeam
    iTeam 
get_user_team(id);

    new 
szMenu[62]

    
formatex(szMenucharsmax(szMenu), "Selecione Sua skin111")

    new 
iMenu menu_create(szMenu"VipSkin_Handler")

    switch(
iTeam)
    {
        case 
CS_TEAM_T:
        {


        }

        case 
CS_TEAM_CT
        {
         
        }
    }
   

    
menu_setprop(iMenuMPROP_EXITNAME"Sair")
    
menu_display(idiMenu)

    return 
PLUGIN_HANDLED 
}

public 
VipSkin_Handler(idiMenuitem)
{
    static 
iTeam
    iTeam 
get_user_team(id)


    switch(
iTeam)
    {
       case 
CS_TEAM_T:
       {

       }
       case 
CS_TEAM_CT:
       {

       }
    }
}

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)



lexzor 08-31-2022 12:15

Re: Models Menu enum
 
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

yagami 08-31-2022 15:57

Re: Models Menu enum
 
Quote:

Originally Posted by lexzor (Post 2787845)
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



lexzor 09-01-2022 08:40

Re: Models Menu enum
 
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"), szItem[64];

    for(new 
iszItemIndex[2]; sizeof(g_eModels); i++)
    {
        if(
g_eModels[i][szTeam] == csTeam)
        {
            
num_to_str(iszItemIndexcharsmax(szItemIndex));
            
formatex(szItemcharsmax(szItem), "%s \d-\r [%s]"g_eModels[i][szModelName], g_eModels[i][iGender] == Male "MALE" "FEMALE");
            
menu_additem(iMenuszItemszItemIndex);
        }
    }
   
    
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)


don t have enough time for this


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

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