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

VIP skin menu help


Post New Thread Reply   
 
Thread Tools Display Modes
iclassdon
AlliedModders Donor
Join Date: May 2006
Old 04-24-2020 , 14:56   Re: VIP skin menu help
Reply With Quote #21

Someone tried to help me out by integrating nvault but It didn't work. The model applies fine as usual but when I disconnect and return to the server it doesn't automatically apply my model selection. I confirmed that it's saving data into the ModelsMenu.vault but I see reference of "BOT" in the model name. Also as mentioned before by jonny1990 once the team specific skin is applied if I change teams it remains on. Can this be fixed so it picks the alternate skins menu number for the team that I switched to instead?

There is also the debug information I have shared below along with the edited code.

Nvault Saved Data:

PHP Code:
TLVn    •¡^ STEAM_0:1:196253790Special_T2•¡^ BOTSpecial_T2 
Debug Trace:

PHP Code:
L 04/23/2020 00:07:51: [AMXXDisplaying debug trace (plugin "skinmenu6.amxx"version "1.0")
L 04/23/2020 00:07:51: [AMXXRun time error 4index out of bounds
L 04
/23/2020 00:07:51: [AMXX]    [0skinmenu6.sma::LoadData (line 193)
L 04/23/2020 00:07:51: [AMXX]    [1skinmenu6.sma::client_putinserver (line 69
Edited Code

PHP Code:
#include <amxmodx>
#include <cromchat>
#include <cstrike>
#include <hamsandwich>
#include <nvault>
 
#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]
 
new 
szModelId[5];
new 
iModel;
 
new 
iVault
 
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]")
 
    
iVault nvault_open("ModelsMenu")
}
 
public 
plugin_end() {
      
nvault_close(iVault)
}
 
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
    
}
 
    
LoadData(id);
 
    
set_task(CONNECT_MSG_DELAY"DisplayMessage"id)
}
 
#if AMXX_VERSION_NUM < 183
public client_disconnect(id) {
#else
public client_disconnected(id) {
#endif
      
SaveData(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]
 
    
menu_item_getinfo(iMenuiItem_unused[0], szModelIdcharsmax(szModelId), _unusedcharsmax(_unused), _unused[0])
 
    
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)
}
 
LoadData(id) {
      new 
CsTeams:iTeam cs_get_user_team(id);
      new 
szAuth[35], szTemp[50], szModel[MAX_PLAYERS 1];
      
get_user_authid(idszAuthcharsmax(szAuth));
 
      
nvault_get(iVaultszAuthszTempcharsmax(szTemp));
 
      
parse(szTempszAuthcharsmax(szAuth), szModelcharsmax(szModel));
 
      
g_iModel[id][iTeam] = str_to_num(szModel);
}
 
SaveData(id) {
    new 
CsTeams:iTeam cs_get_user_team(id);
    new 
szTemp[50];
    new 
szAuth[35];
    
get_user_authid(idszAuthcharsmax(szAuth));
 
    
g_iModel[id][iTeam] = iModel
    formatex
(szTempcharsmax(szTemp), "%s"g_eModels[iModel][Name]);
 
    
nvault_set(iVaultszAuthszTemp);


Last edited by iclassdon; 05-01-2020 at 13:24.
iclassdon is offline
Send a message via MSN to iclassdon
sanimare
Senior Member
Join Date: Sep 2010
Old 05-13-2020 , 07:15   Re: VIP skin menu help
Reply With Quote #22

Server is crashing when i add standard models terror and gsg9 for example server won't start. I tried that way to put default models. Yet, it need's when you switch team to change to model from ct menu so you can be visible as ct not as tt model which is recognized by tt for example. Little improvement in this plugin and it will be good. Also save data.
sanimare 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 04:59.


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