Raised This Month: $51 Target: $400
 12% 

VIP skin menu help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
iclassdon
AlliedModders Donor
Join Date: May 2006
Old 04-19-2020 , 19:37   VIP skin menu help
Reply With Quote #1

I found this old code and wish to use it but, it's not working. The menu pops up but it's not applying the models after selecting it in menu. Can someone help me fix it? Also if we can add a print_chat message saying "Your new $? skin has been applied" after selecting model.

Thank you

PHP Code:
#include < amxmodx >  
#include < cstrike >  
#include < hamsandwich >
 
#define PLUGIN "Vip Skins Menu"  
#define VERSION "1.0"  
#define AUTHOR "Alicx"  
 
new bool:g_selected[33];
new 
g_modelt[33][256]
new 
g_modelct[33][256]
 
public 
plugin_precache()  
{  
    
precache_model("models/player/Special_CT/Special_CT.mdl");  
    
precache_model("models/player/Special_CT2/Special_CT2.mdl");  
    
precache_model("models/player/Special_T/Special_T.mdl");  
    
precache_model("models/player/Special_T2/Special_T2.mdl");  
}  
 
public 
plugin_init() {  
    
register_plugin(PLUGINVERSIONAUTHOR)  
 
    
register_clcmd"say /vipskin",  "Skins_Menu" );  
 
    
RegisterHam(Ham_Spawn"player""FwdHamPlayerSpawn"1)

 
public 
FwdHamPlayerSpawn(id) { 
    if(
g_selected[id])
    {
         if(
cs_get_user_team(id) == CS_TEAM_T)
         {
                
cs_set_user_model(idg_modelt[id])
         }
         else
         {
                
cs_set_user_model(idg_modelct[id])
         }
    }

 
public 
Skins_Menu(id) {   
    new 
menu menu_create("Select Your Skin""skin_menu"
    if(
cs_get_user_team(id) & CS_TEAM_CT) { 
        
menu_additemmenu"Special_CT""1"ADMIN_LEVEL_H );   
        
menu_additemmenu"Special_CT2""2"ADMIN_LEVEL_H ); 
    } 
    else if(
cs_get_user_team(id) & CS_TEAM_T) { 
        
menu_additemmenu"Special_T""3"ADMIN_LEVEL_H );   
        
menu_additemmenu"Special_T2""4"ADMIN_LEVEL_H ); 
    } 
 
    
menu_setpropmenuMPROP_EXITMEXIT_ALL );    
    
menu_displayidmenu);   
}   
public 
skin_menu(idmenuitem) {  
    if (
item == MENU_EXIT) {  
        
menu_destroy(menu)  
        return 
PLUGIN_HANDLED;  
    }  
 
    new 
data[6], szName[64]; 
    new 
accesscallback
    
menu_item_getinfo(menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback); 
    new 
key str_to_num(data); 
 
    if(!
is_user_alive(id)) 
        return 
PLUGIN_HANDLED 
 
    
switch(key) { 
        case 
1: {  
            
cs_set_user_model(id"Special_CT"); 
            
g_modelct[id] = "Special_CT"
        
}  
        case 
2: {  
            
cs_set_user_model(id"Special_CT2"); 
            
g_modelct[id] = "Special_CT2"
        
}  
        case 
3: {  
            
cs_set_user_model(id"Special_T");  
            
g_modelt[id] = "Special_T"
        
}  
        case 
4: {  
            
cs_set_user_model(id"Special_T2"); 
            
g_modelt[id] = "Special_T2"
        

    }  
    
g_selected[id] = true;
    return 
PLUGIN_CONTINUE;  

iclassdon is offline
Send a message via MSN to iclassdon
Old 04-19-2020, 20:07
+ARUKARI-
This message has been deleted by +ARUKARI-.
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 04-19-2020 , 22:28   Re: VIP skin menu help
Reply With Quote #2

Quote:
Originally Posted by iclassdon View Post
I found this old code and wish to use it but, it's not working. The menu pops up but it's not applying the models after selecting it in menu. Can someone help me fix it? Also if we can add a print_chat message saying "Your new $? skin has been applied" after selecting model.

Thank you
I fixed it + I added color chat and i tested it
Pic : https://i.ibb.co/2YmD6Jz/1.png

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

// PREFIX
new const PREFIX[] = { "VIP Model" };
 
#define PLUGIN "Vip Skins Menu"  
#define VERSION "2.0"  
#define AUTHOR "MrAbdoO"  
 
new bool:g_selected[33];
new 
g_modelt[33][256]
new 
g_modelct[33][256]
 
public 
plugin_precache()  
{  
    
precache_model("models/player/Special_CT/Special_CT.mdl");  
    
precache_model("models/player/Special_CT2/Special_CT2.mdl");  
    
precache_model("models/player/Special_T/Special_T.mdl");  
    
precache_model("models/player/Special_T2/Special_T2.mdl");  
}  
 
public 
plugin_init() {  
    
register_plugin(PLUGINVERSIONAUTHOR)  
 
    
register_clcmd"say /vipskin",  "Skins_Menu" );  
 
    
RegisterHam(Ham_Spawn"player""FwdHamPlayerSpawn"1)

 
public 
FwdHamPlayerSpawn(id) { 
    if(
g_selected[id])
    {
         if(
cs_get_user_team(id) == CS_TEAM_T)
         {
                
cs_set_user_model(idg_modelt[id])
         }
         else
         {
                
cs_set_user_model(idg_modelct[id])
         }
    }

 
public 
Skins_Menu(id) {   
    new 
menu menu_create("Select Your Skin""skin_menu"
    if(
cs_get_user_team(id) & CS_TEAM_CT) { 
        
menu_additemmenu"Special_CT""1"ADMIN_LEVEL_H );   
        
menu_additemmenu"Special_CT2""2"ADMIN_LEVEL_H ); 
    } 
    else if(
cs_get_user_team(id) & CS_TEAM_T) { 
        
menu_additemmenu"Special_T""3"ADMIN_LEVEL_H );   
        
menu_additemmenu"Special_T2""4"ADMIN_LEVEL_H ); 
    } 
 
    
menu_setpropmenuMPROP_EXITMEXIT_ALL );    
    
menu_displayidmenu);   
}   
public 
skin_menu(idmenuitem) {  
    if (
item == MENU_EXIT) {  
        
menu_destroy(menu)  
        return 
PLUGIN_HANDLED;  
    }  
 
    new 
data[6], szName[64]; 
    new 
accesscallback
    
menu_item_getinfo(menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback); 
    new 
key str_to_num(data); 
 
    if(!
is_user_alive(id)) 
        return 
PLUGIN_HANDLED 
 
    
switch(key) { 
        case 
1: {  
            
cs_set_user_model(id"Special_CT"); 
            
g_modelct[id] = "Special_CT"
        
        
ColorChat(0GREEN"^4[%s]^1 Your new ^4Special_CT^1 skin has been applied!"PREFIX);    
        } 
        case 
2: {  
            
cs_set_user_model(id"Special_CT2"); 
            
g_modelct[id] = "Special_CT2"
        
        
ColorChat(0GREEN"^4[%s]^1 Your new ^4Special_CT2^1 skin has been applied!"PREFIX);    
        }  
        case 
3: {  
            
cs_set_user_model(id"Special_T");  
            
g_modelt[id] = "Special_T"
        
        
ColorChat(0GREEN"^4[%s]^1 Your new ^4Special_T^1 skin has been applied!"PREFIX);    
        }  
        case 
4: {  
            
cs_set_user_model(id"Special_T2"); 
            
g_modelt[id] = "Special_T2"
        
        
ColorChat(0GREEN"^4[%s]^1 Your new ^4Special_T2^1 skin has been applied!"PREFIX);    
        } 
    }  
    
g_selected[id] = true;
    return 
PLUGIN_CONTINUE;  


Last edited by Supremache; 04-19-2020 at 22:36.
Supremache is offline
iclassdon
AlliedModders Donor
Join Date: May 2006
Old 04-20-2020 , 01:37   Re: VIP skin menu help
Reply With Quote #3

Thank you Supremache its working.

One small thing. The print chat when it displays everyone can see it. Can you please change it so only the person selecting the skin can see the message?
iclassdon is offline
Send a message via MSN to iclassdon
+ARUKARI-
AlliedModders Donor
Join Date: Jul 2004
Location: Japan
Old 04-20-2020 , 01:40   Re: VIP skin menu help
Reply With Quote #4

ColorChat 0 to id.
PHP Code:
ColorChat(0GREEN"^4[%s]^1 Your new ^4Special_CT2^1 skin has been applied!"PREFIX);    
ColorChat(idGREEN"^4[%s]^1 Your new ^4Special_CT2^1 skin has been applied!"PREFIX); 
__________________
GitHub
SteamWishlist

六四天安門事件
+ARUKARI- is offline
iclassdon
AlliedModders Donor
Join Date: May 2006
Old 04-20-2020 , 01:48   Re: VIP skin menu help
Reply With Quote #5

Also one last thing. When a person without the proper admin level uses the trigger /vipskin it will display the message below.

"[Prefix] Only vips can open this menu, sorry!"

Thanks again all!

Last edited by iclassdon; 04-20-2020 at 01:49.
iclassdon is offline
Send a message via MSN to iclassdon
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 04-20-2020 , 08:13   Re: VIP skin menu help
Reply With Quote #6

I took the time to rewrite this with much better code and easy settings.
You can now change your skin from the beginning of the code rather than editing it in 5 different places for each skin.

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,
}

new const 
g_eModels[][ModelInfo] =
{
    { 
"Special_CT",  CS_TEAM_CT },
    { 
"Special_CT2"CS_TEAM_CT },
    { 
"Special_T",   CS_TEAM_T },
    { 
"Special_T2",  CS_TEAM_T }
}

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 OciXCrom; 04-22-2020 at 07:37.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 04-20-2020 , 08:46   Re: VIP skin menu help
Reply With Quote #7

Quote:
Originally Posted by OciXCrom View Post
I took the time to rewrite this with much better code and easy settings.
You can now change your skin from the beginning of the code rather than editing it in 5 different places for each skin.

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,
}

new const 
g_eModels[][ModelInfo] =
{
    { 
"Special_CT",  CS_TEAM_CT },
    { 
"Special_CT2"CS_TEAM_CT },
    { 
"Special_T",   CS_TEAM_T },
    { 
"Special_T2",  CS_TEAM_T }
}

const 
INVALID_SKIN = -1
const MENU_ACCESS_FLAG ADMIN_LEVEL_H

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
    
}
}

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(!
check_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(!
check_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:check_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 did it like what he want But you are the best <3 and your plugin it better than me
Supremache is offline
iclassdon
AlliedModders Donor
Join Date: May 2006
Old 04-20-2020 , 12:02   Re: VIP skin menu help
Reply With Quote #8

Thank you OciXCrom and Supremache!

Can we also add a print_chat welcome message when joining team to user with ADMIN_LEVEL_H saying "[Prefix] Type /vipskin to open VIP Skin Menu"?

Also is it possible to save the users skin selection in nvault using steam id? So the next time they connect or when the map changes they don't have to select it again?

This would be awesome and my final request.

Last edited by iclassdon; 04-20-2020 at 12:23.
iclassdon is offline
Send a message via MSN to iclassdon
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 04-20-2020 , 19:19   Re: VIP skin menu help
Reply With Quote #9

Quote:
Originally Posted by iclassdon View Post
Thank you OciXCrom and Supremache!

Can we also add a print_chat welcome message when joining team to user with ADMIN_LEVEL_H saying "[Prefix] Type /vipskin to open VIP Skin Menu"?

Also is it possible to save the users skin selection in nvault using steam id? So the next time they connect or when the map changes they don't have to select it again?

This would be awesome and my final request.
Follow Codes

PHP Code:
new pcvar_message 
PHP Code:
pcvar_message=register_cvar("htbs_message_time""30"
    
set_task(get_pcvar_float(pcvar_message), "Message" "b"
PHP Code:
public Message() CC_SendMessage(0"type &x04/vipskin&x01 to open VIP Skin Menu "); 
I'm Sorry I cant do it, It's Hard For me
Quote:
possible to save the users skin selection in nvault using steam id
Supremache is offline
iclassdon
AlliedModders Donor
Join Date: May 2006
Old 04-21-2020 , 17:04   Re: VIP skin menu help
Reply With Quote #10

The skins isn't staying on after you die or when round ends. Needs to be reapplied on respawn. Anyway to fix this?

Last edited by iclassdon; 04-21-2020 at 17:16.
iclassdon is offline
Send a message via MSN to iclassdon
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 20:50.


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