Raised This Month: $ Target: $400
 0% 

Models Menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
yagami
Senior Member
Join Date: Jan 2021
Old 04-11-2022 , 16:10   Models Menu
Reply With Quote #1

I found this plugin here from OciXCrom's
I really liked the way this plugin was made

I have a request if I can, I would like the menu to be separate for each skins like

MALE MODELS

FEMALE MODELS

PHP Code:
#include <amxmodx>
#include <cromchat>
#include <cstrike>
#include <hamsandwich>

#if !defined MAX_PLAYERS
const MAX_PLAYERS 32
#endif

enum _:ModelInfo
{
    
Name[32],
    
CsTeams:Team,
    
Male,
    
Female,
}

new const 
g_eModels[][ModelInfo] =
{
    { 
"Special_CT",  CS_TEAM_CTMale },
    { 
"Special_CT2"CS_TEAM_CTMale },
    { 
"Special_T",   CS_TEAM_TFemale },
    { 
"Special_T2",  CS_TEAM_TFemale }
}

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 /vipskin""Cmd_VipSkin")
    
register_clcmd("say_team /vipskin""Cmd_VipSkin")

    
CC_SetPrefix("&x04[Prefix]")
}

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

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

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

    new 
iMenu menu_create("Select Your Skin""VipSkin_Handler")

    for(new 
CsTeams:iTeam cs_get_user_team(id), szNum[5], isizeof(g_eModels); i++)
    {
        if(
g_eModels[i][Team] == iTeam)
        {
            
num_to_str(iszNumcharsmax(szNum))
            
menu_additem(iMenug_eModels[i][Name], szNum)
        }
    }

    
menu_display(idiMenu)
    return 
PLUGIN_HANDLED
}

public 
VipSkin_Handler(idiMenuiItem)
{
    if(!
has_menu_access(id))
    {
        goto @
destroy
    
}

    static 
_unused[1]

    new 
szModelId[5
    
menu_item_getinfo(iMenuiItem_unused[0], szModelIdcharsmax(szModelId), _unusedcharsmax(_unused), _unused[0])

    new 
iModel str_to_num(szModelId)
    new 
CsTeams:iTeam cs_get_user_team(id)

    if(
g_eModels[iModel][Team] != iTeam)
    {
        goto @
destroy
    
}

    
g_iModel[id][iTeam] = iModel
    CC_SendMessage
(id"You have selected the skin &x04%s"g_eModels[iModel][Name])

    if(
is_user_alive(id))
    {
        
cs_set_user_model(idg_eModels[iModel][Name])
    }

    @
destroy:
    
menu_destroy(iMenu)
    return 
PLUGIN_HANDLED
}

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)


Last edited by yagami; 04-11-2022 at 16:23.
yagami is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-11-2022 , 23:37   Re: Models Menu
Reply With Quote #2

This should be fairly simple depending on how you want to set/determine the sex of the models that you want to show. You only needed to add one additional parameter to the ModelInfo enumeration instead of the two that you added:

PHP Code:
enum _:ModelInfo
{
    
Name[32],
    
CsTeams:Team,
    
Sex

Then, you need to define "Male" and "Female":

PHP Code:
enum {
    
Male,
    
Female

Then, you need to change the condition in the menu building function to also check for the sex of the model. Either in addition to the team check or you can change entirely to a sex check depending on how you want it to work.

I would probably just implement it with the sex check against a constant just to make sure that that part works as expected.

PHP Code:
g_eModels[i][Sex] == Female 
Then, you can add more complex functionality for determining how to know which sex to show.
__________________

Last edited by fysiks; 04-11-2022 at 23:41.
fysiks is offline
yagami
Senior Member
Join Date: Jan 2021
Old 04-12-2022 , 00:50   Re: Models Menu
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
This should be fairly simple depending on how you want to set/determine the sex of the models that you want to show. You only needed to add one additional parameter to the ModelInfo enumeration instead of the two that you added:

PHP Code:
enum _:ModelInfo
{
    
Name[32],
    
CsTeams:Team,
    
Sex

Then, you need to define "Male" and "Female":

PHP Code:
enum {
    
Male,
    
Female

Then, you need to change the condition in the menu building function to also check for the sex of the model. Either in addition to the team check or you can change entirely to a sex check depending on how you want it to work.

I would probably just implement it with the sex check against a constant just to make sure that that part works as expected.

PHP Code:
g_eModels[i][Sex] == Female 
Then, you can add more complex functionality for determining how to know which sex to show.
I still have a hard time doing this myself.
if it was a simple menu I can even make a menu easily but as the skins are within the const it is being difficult
could you give me some examples i'm still learning
yagami is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-12-2022 , 01:22   Re: Models Menu
Reply With Quote #4

I explained in detail what you need to do to get this menu with either only male or female models. It is easier than you might think. Go ahead and try it. Update the ModelInfo definition with mine and then add the Male/Femail enum below that. Then, replace:
Code:
g_eModels[i][Team] == iTeam
with
Code:
g_eModels[i][Sex] == Female
Now, with this code, it will show you only female options for models. Test this to make sure that it works. Then, we can update it to make it more complex to dynamically set whether you show male or female models.

Please post the new code with all your modifications completed the next time you post so that we can either help you fix it or help you move on to the next step (this is the Scripting Help section after all).

For us to help you with taking the next step, you're going to need to explain in detail how you want to decide if male or female models are shown to a player.
__________________
fysiks is offline
yagami
Senior Member
Join Date: Jan 2021
Old 04-12-2022 , 03:37   Re: Models Menu
Reply With Quote #5

PHP Code:
#include <amxmodx>
#include <cromchat>
#include <cstrike>
#include <hamsandwich>

#if !defined MAX_PLAYERS
const MAX_PLAYERS 32
#endif

enum _:ModelInfo
{
    
Name[32],
    
CsTeams:Team,
    
Sex
}

enum {
    
Male,
    
Female


new const 
g_eModels[][ModelInfo] =
{
    { 
"Special_CT",  CS_TEAM_CTMale },
    { 
"Special_CT2"CS_TEAM_CTFemale },
    { 
"Special_T",   CS_TEAM_TFemale },
    { 
"Special_T2",  CS_TEAM_TMale }
}

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

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

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

    new 
iMenu menu_create("Select Your Skin""VipSkin_Handler")

    for(new 
CsTeams:iTeam cs_get_user_team(id), szNum[5], isizeof(g_eModels); i++)
    {
        if(
g_eModels[i][Sex] == Female)
        {
            
num_to_str(iszNumcharsmax(szNum))
            
menu_additem(iMenug_eModels[i][Name], szNum)
        }
    }

    
menu_display(idiMenu)
    return 
PLUGIN_HANDLED
}

public 
VipSkin_Handler(idiMenuiItem)
{
    if(!
has_menu_access(id))
    {
        goto @
destroy
    
}

    static 
_unused[1]

    new 
szModelId[5
    
menu_item_getinfo(iMenuiItem_unused[0], szModelIdcharsmax(szModelId), _unusedcharsmax(_unused), _unused[0])

    new 
iModel str_to_num(szModelId)
    new 
CsTeams:iTeam cs_get_user_team(id)

    if(
g_eModels[iModel][Team] != iTeam)
    {
        goto @
destroy
    
}

    
g_iModel[id][iTeam] = iModel
    CC_SendMessage
(id"You have selected the skin &x04%s"g_eModels[iModel][Name])

    if(
is_user_alive(id))
    {
        
cs_set_user_model(idg_eModels[iModel][Name])
    }

    @
destroy:
    
menu_destroy(iMenu)
    return 
PLUGIN_HANDLED
}

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)

I don't know if I did it now, it's selected female skins, but it shows both ct and tr skins together
something else it is giving a small error

Code:
Success
Output: 

===== c:\Users\tks\Downloads\adminskins.sma =====
WARNING [100]: symbol is assigned a value that is never used: "iTeam"

Last edited by yagami; 04-12-2022 at 03:39.
yagami is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-12-2022 , 22:42   Re: Models Menu
Reply With Quote #6

Yep, that's what was supposed to happen with this code. It was just a test to make sure that the ability to show only male or female models. If you want to show only female models that are available for your team, add back the team check.

PHP Code:
g_eModels[i][Team] == iTeam && g_eModels[i][Sex] == Female 
You haven't described how you want to determine whether you show male or female models so we can't really help you any further than this.
__________________
fysiks is offline
yagami
Senior Member
Join Date: Jan 2021
Old 04-13-2022 , 02:42   Re: Models Menu
Reply With Quote #7

PHP Code:
#include <amxmodx>
#include <cromchat>
#include <cstrike>
#include <hamsandwich>

#if !defined MAX_PLAYERS
const MAX_PLAYERS 32
#endif

enum _:ModelInfo
{
    
Name[32],
    
CsTeams:Team,
    
Sex
}

enum {
    
Male,
    
Female


new const 
g_eModels[][ModelInfo] =
{
    { 
"Special_CT",  CS_TEAM_CTMale },
    { 
"Special_CT2"CS_TEAM_CTFemale },
    { 
"Special_T",   CS_TEAM_TFemale },
    { 
"Special_T2",  CS_TEAM_TMale }
}

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

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

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

    new 
iMenu menu_create("Select Your Skin""VipSkin_Handler")

    for(new 
CsTeams:iTeam cs_get_user_team(id), szNum[5], isizeof(g_eModels); i++)
    {
        if(
g_eModels[i][Team] == iTeam && g_eModels[i][Sex] == Female )
        {
            
num_to_str(iszNumcharsmax(szNum))
            
menu_additem(iMenug_eModels[i][Name], szNum)
        }
    }

    
menu_display(idiMenu)
    return 
PLUGIN_HANDLED
}

public 
VipSkin_Handler(idiMenuiItem)
{
    if(!
has_menu_access(id))
    {
        goto @
destroy
    
}

    static 
_unused[1]

    new 
szModelId[5
    
menu_item_getinfo(iMenuiItem_unused[0], szModelIdcharsmax(szModelId), _unusedcharsmax(_unused), _unused[0])

    new 
iModel str_to_num(szModelId)
    new 
CsTeams:iTeam cs_get_user_team(id)

    if(
g_eModels[iModel][Team] != iTeam)
    {
        goto @
destroy
    
}

    
g_iModel[id][iTeam] = iModel
    CC_SendMessage
(id"You have selected the skin &x04%s"g_eModels[iModel][Name])

    if(
is_user_alive(id))
    {
        
cs_set_user_model(idg_eModels[iModel][Name])
    }

    @
destroy:
    
menu_destroy(iMenu)
    return 
PLUGIN_HANDLED
}

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)

I just did this and it worked
yagami is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 04-13-2022 , 13:53   Re: Models Menu
Reply With Quote #8

What you did is a massive discrimination against male players, because only female skins will appear in the menu.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-13-2022 , 23:11   Re: Models Menu
Reply With Quote #9

Quote:
Originally Posted by OciXCrom View Post
What you did is a massive discrimination against male players
Umm, no . . .

Quote:
Originally Posted by OciXCrom View Post
only female skins will appear in the menu.
His original request talks about putting them in separate menus which I figured means that he'd want to conditionally show one or the other but he'd not given any indication as to how to choose between them.

Otherwise, he could have simply just used female models and not worry about editing the plugin to support both.
__________________

Last edited by fysiks; 04-13-2022 at 23:11.
fysiks is offline
yagami
Senior Member
Join Date: Jan 2021
Old 04-14-2022 , 07:46   Re: Models Menu
Reply With Quote #10

Quote:
Originally Posted by fysiks View Post
Umm, no . . .



His original request talks about putting them in separate menus which I figured means that he'd want to conditionally show one or the other but he'd not given any indication as to how to choose between them.

Otherwise, he could have simply just used female models and not worry about editing the plugin to support both.

So what I want to do is have a menu to support both menus
yagami is offline
Reply



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 21:20.


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