AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help with skin menu (https://forums.alliedmods.net/showthread.php?t=337925)

yagami 05-26-2022 22:38

Help with skin menu
 
I'm trying to make a menu to show Male and Female example

PHP Code:

CT
MALE 
{
SKINM1
SKINM2
SKINM3
}

Female {
SKINF1
SKINF2
SKINF3


PHP Code:

TR
MALE 
{
SKINM1
SKINM2
SKINM3
}

Female {
SKINF1
SKINF2
SKINF3


Can someone help me ?


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")

    static 
iCsTeams:iTeamszNum[5],szMenu[62];
    
iTeam cs_get_user_team(id);

    for(
0sizeof g_eModelsi++)
    {
        
//Team
        
if(g_eModels[i][Team] != iTeam)
            continue;
            
        
formatex(szMenucharsmax(szMenu), "%s \y[%s]"g_eModels[i][Name], g_eModels[i][Sex] != Female "Male" "Female");

        
num_to_str(iszNumcharsmax(szNum));
        
menu_additem(iMenuszMenuszNum);

    }

    
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)



lexzor 05-28-2022 15:17

Re: Help with skin menu
 
PHP Code:

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_CTFemale"models/player/Special_CT2/Special_CT2.mdl" },
    { 
"Special_T",   CS_TEAM_TFemale"models/player/Special_T/Special_T.mdl" },
    { 
"Special_T2",  CS_TEAM_TMale"models/player/Special_T2/Special_T2.mdl" }
}

new 
g_iUserGender[MAX_PLAYERS 1];

public 
plugin_precache()
{
    for(new 
isizeof(g_eModels); i++)
    {
        if(
file_exists(g_eModels[i][szModelPath]))
        {
            
precache_model(g_eModels[i][szModelPath]);
        } else 
log_amx("Error! Model ^"%s^" does not exists!"g_eModels[i][szModelPath]);
    }
}

public 
client_putinserver(id)
{
    
g_iUserGender[id] == Male//


and this is how you set model:
PHP Code:

public set_model(id)
{
    for(new 
ii<sizeof(g_eModels); i++)
    {
        if(
g_eModels[id][szTeam] == cs_get_user_team(id) && g_eModels[id][iGender] == g_iUserGender[id])
        {
            
cs_set_user_model(idg_eModels[id][szModelPath]);
            
client_print(idprint_chat"Your %s model has been set"g_eModels[id][szModelName]);
            break;
        }
    }



yagami 06-02-2022 16:35

Re: Help with skin menu
 
PHP Code:

public client_putinserver(id)
{
    
g_iUserGender[id] == Male//


This here gave an error


WARNING [42]: expression has no effect

@edit Another thing I don't know how to assemble this codes by myself yet

lexzor 06-02-2022 18:03

Re: Help with skin menu
 
replace with
PHP Code:

g_iUserGender[id] = Male

Try to and post your code here, me or someone will help you explaining what to do. If this is a request, post in in the right section of forum.

yagami 06-03-2022 00:32

Re: Help with skin menu
 
Quote:

Originally Posted by lexzor (Post 2780351)
PHP Code:

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_CTFemale"models/player/Special_CT2/Special_CT2.mdl" },
    { 
"Special_T",   CS_TEAM_TFemale"models/player/Special_T/Special_T.mdl" },
    { 
"Special_T2",  CS_TEAM_TMale"models/player/Special_T2/Special_T2.mdl" }
}

new 
g_iUserGender[MAX_PLAYERS 1];

public 
plugin_precache()
{
    for(new 
isizeof(g_eModels); i++)
    {
        if(
file_exists(g_eModels[i][szModelPath]))
        {
            
precache_model(g_eModels[i][szModelPath]);
        } else 
log_amx("Error! Model ^"%s^" does not exists!"g_eModels[i][szModelPath]);
    }
}

public 
client_putinserver(id)
{
    
g_iUserGender[id] == Male//


and this is how you set model:
PHP Code:

public set_model(id)
{
    for(new 
ii<sizeof(g_eModels); i++)
    {
        if(
g_eModels[id][szTeam] == cs_get_user_team(id) && g_eModels[id][iGender] == g_iUserGender[id])
        {
            
cs_set_user_model(idg_eModels[id][szModelPath]);
            
client_print(idprint_chat"Your %s model has been set"g_eModels[id][szModelName]);
            break;
        }
    }



What I don't understand, is to make new code using just what you posted here or do I have to put this in my code


All times are GMT -4. The time now is 21:18.

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