AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   custom teams help! (https://forums.alliedmods.net/showthread.php?t=155699)

SeriousSam 04-25-2011 14:26

custom teams help!
 
Hello, I want to force the player to be a spectator when he joins the server, and present him with a menu where he can choose from a custom team, class, gender and so on, and after he finishes his selection, to be moved to the corresponding team and set with a custom player model according to his selection. I started with looking at Exolent's team join management plugin, and so far I made the part where the player is forced to be a spectator, but it doesn't work quite right, the player is indeed switched to the spectator team after he closes the motd window, but the hud is different and still displays money and roundtime, and he can't move. I don't know why, can you help me?

PHP Code:

#include <amxmodx>

#define PLUGIN "Classes"
#define VERSION "1.0"
#define AUTHOR "SeriousSamBG"

enum
{
    
TEAM_NONE 0,
    
TEAM_T,
    
TEAM_CT,
    
TEAM_SPEC,
    
    
MAX_TEAMS
};

new const 
g_cTeamChars[MAX_TEAMS] =
{
    
'U',
    
'T',
    
'C',
    
'S'
};

// Old Style Menus
stock const FIRST_JOIN_MSG[] =        "#Team_Select";
stock const FIRST_JOIN_MSG_SPEC[] =    "#Team_Select_Spect";
stock const INGAME_JOIN_MSG[] =        "#IG_Team_Select";
stock const INGAME_JOIN_MSG_SPEC[] =    "#IG_Team_Select_Spect";
const 
iMaxLen sizeof(INGAME_JOIN_MSG_SPEC);

// New VGUI Menus
stock const VGUI_JOIN_TEAM_NUM =        2;

new 
g_iTeam[33];
new 
g_iPlayers[MAX_TEAMS];

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_event("TeamInfo""event_TeamInfo""a");
    
register_message(get_user_msgid("ShowMenu"), "message_ShowMenu");
    
register_message(get_user_msgid("VGUIMenu"), "message_VGUIMenu");
}

public 
event_TeamInfo()
{
    new 
id read_data(1);
    new 
sTeam[32], iTeam;
    
    
read_data(2sTeamsizeof(sTeam) - 1);
    
    for(new 
0MAX_TEAMSi++)
    {
        if(
g_cTeamChars[i] == sTeam[0])
        {
            
iTeam i;
            break;
        }
    }
    
    if(
g_iTeam[id] != iTeam)
    {
        
g_iPlayers[g_iTeam[id]]--;
        
g_iTeam[id] = iTeam;
        
g_iPlayers[iTeam]++;
    }
}

public 
message_ShowMenu(iMsgidiDestid)
{
    static 
sMenuCode[iMaxLen];
    
    
get_msg_arg_string(4sMenuCodesizeof(sMenuCode) - 1);
    
    if(
equal(sMenuCodeFIRST_JOIN_MSG) || equal(sMenuCodeFIRST_JOIN_MSG_SPEC))
    {
        if(
is_user_connected(id) && !(TEAM_NONE g_iTeam[id] < TEAM_SPEC))
        {
            
set_autojoin_task(idiMsgid);
            return 
PLUGIN_HANDLED;
        }
    }
    else if(
equal(sMenuCodeINGAME_JOIN_MSG) || equal(sMenuCodeINGAME_JOIN_MSG_SPEC))
    {
        return 
PLUGIN_HANDLED;
    }
    return 
PLUGIN_CONTINUE;
}

public 
message_VGUIMenu(iMsgidiDestid)
{
    if(
get_msg_arg_int(1) != VGUI_JOIN_TEAM_NUM)
    {
        return 
PLUGIN_CONTINUE;
    }
    
    if(
is_user_connected(id) && !(TEAM_NONE g_iTeam[id] < TEAM_SPEC))
    {
        
set_autojoin_task(idiMsgid);
        return 
PLUGIN_HANDLED;
    }
    else if(
TEAM_NONE g_iTeam[id] < TEAM_SPEC)
    {
        return 
PLUGIN_HANDLED;
    }
    return 
PLUGIN_CONTINUE;
}

stock set_autojoin_task(idiMsgid)
{
    new 
iMsgBlock get_msg_block(iMsgid);
    
set_msg_block(iMsgidBLOCK_SET);
    
    
engclient_cmd(id"jointeam""3");
    
    
set_msg_block(iMsgidiMsgBlock);



SonicSonedit 04-25-2011 14:34

Re: custom teams help!
 
http://forums.alliedmods.net/showthread.php?t=155608
I will let you know if I'll find a better way to do it.

SeriousSam 04-25-2011 15:27

Re: custom teams help!
 
I found the problem after a lot of debugging. It was a mistake in Exolent's code. He used "3" for the spectator team, but the spectator team in cs is "6". Now it works and automatically switches me to spec team when I enter :P Now time to start working on the menu :P

SonicSonedit 04-25-2011 17:02

Re: custom teams help!
 
SeriousSam
Spectator team value in CS is 3.
Spectator menu option in team select menu is 6.
These are absolutely different things.


All times are GMT -4. The time now is 19:45.

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