Client: Updated VGUI menus so they can be called separately. Implement commands 'changeteam' and 'changeclass.
This commit is contained in:
parent
fe7ec00d31
commit
8b9fc69829
7 changed files with 211 additions and 283 deletions
|
@ -14,6 +14,8 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
void VGUI_ChooseClass(void);
|
||||
|
||||
int
|
||||
ClientGame_ConsoleCommand(void)
|
||||
{
|
||||
|
@ -24,6 +26,14 @@ ClientGame_ConsoleCommand(void)
|
|||
case "dismantle":
|
||||
sendevent("TFCDismantle", "i", stoi(argv(1)));
|
||||
break;
|
||||
case "chooseclass":
|
||||
case "changeclass":
|
||||
VGUI_ChooseClass();
|
||||
break;
|
||||
case "chooseteam":
|
||||
case "changeteam":
|
||||
VGUI_ChooseTeam();
|
||||
break;
|
||||
default:
|
||||
return (0);
|
||||
}
|
||||
|
|
|
@ -31,10 +31,10 @@ ClientGame_PreDraw(void)
|
|||
g_hud_color = TFC_HUD_TEAM_COLOR_RED;
|
||||
break;
|
||||
case 3:
|
||||
g_hud_color = TFC_HUD_TEAM_COLOR_YELLOW;
|
||||
g_hud_color = TFC_HUD_TEAM_COLOR_GREEN;
|
||||
break;
|
||||
case 4:
|
||||
g_hud_color = TFC_HUD_TEAM_COLOR_GREEN;
|
||||
g_hud_color = TFC_HUD_TEAM_COLOR_YELLOW;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -75,25 +75,25 @@ ClientGame_PostDraw(void)
|
|||
1.0f,
|
||||
DRAWFLAG_ADDITIVE
|
||||
);
|
||||
} else if (iGoalItemTeam == 3) { /* yellow */
|
||||
} else if (iGoalItemTeam == 3) { /* green */
|
||||
drawsubpic(
|
||||
vecGoalItemPos,
|
||||
[64,64],
|
||||
g_tfchud6_spr,
|
||||
[192/256, 62/256],
|
||||
[64/256, 136/256],
|
||||
TFC_HUD_TEAM_COLOR_YELLOW,
|
||||
TFC_HUD_TEAM_COLOR_GREEN,
|
||||
1.0f,
|
||||
DRAWFLAG_ADDITIVE
|
||||
);
|
||||
} else { /* green */
|
||||
} else { /* yellow */
|
||||
drawsubpic(
|
||||
vecGoalItemPos,
|
||||
[64,64],
|
||||
g_tfchud1_spr,
|
||||
[0/256,136/256],
|
||||
[64/256, 64/256],
|
||||
TFC_HUD_TEAM_COLOR_GREEN,
|
||||
TFC_HUD_TEAM_COLOR_YELLOW,
|
||||
1.0f,
|
||||
DRAWFLAG_ADDITIVE
|
||||
);
|
||||
|
|
|
@ -30,6 +30,10 @@ ClientGame_Init(float apilevel, string enginename, float engineversion)
|
|||
registercommand("-gren1");
|
||||
registercommand("+gren2");
|
||||
registercommand("-gren2");
|
||||
registercommand("chooseclass");
|
||||
registercommand("changeclass");
|
||||
registercommand("chooseteam");
|
||||
registercommand("changeteam");
|
||||
Obituary_Init();
|
||||
}
|
||||
|
||||
|
|
|
@ -43,5 +43,6 @@ hud_ammonotify.qc
|
|||
|
||||
../../../src/client/include.src
|
||||
vgui_chooseteam.qc
|
||||
vgui_changeclass.qc
|
||||
../../../src/shared/include.src
|
||||
#endlist
|
||||
|
|
92
src/client/vgui_changeclass.qc
Normal file
92
src/client/vgui_changeclass.qc
Normal file
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2020 Marco Cawthorne <marco@icculus.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
static CUIWindow winClassSelection;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
string str;
|
||||
void(void) ptr;
|
||||
} btnarr_t;
|
||||
|
||||
void
|
||||
VGUI_ClassJoin(float i)
|
||||
{
|
||||
sendevent("ClassJoin", "f", i);
|
||||
winClassSelection.Hide();
|
||||
}
|
||||
|
||||
void
|
||||
VGUI_TeamBack(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void VGUI_JoinScout (void) { VGUI_ClassJoin(1); }
|
||||
void VGUI_JoinSniper (void) { VGUI_ClassJoin(2); }
|
||||
void VGUI_JoinSoldier (void) { VGUI_ClassJoin(3); }
|
||||
void VGUI_JoinDemoman (void) { VGUI_ClassJoin(4); }
|
||||
void VGUI_JoinMedic (void) { VGUI_ClassJoin(5); }
|
||||
void VGUI_JoinHwguy (void) { VGUI_ClassJoin(6); }
|
||||
void VGUI_JoinPyro (void) { VGUI_ClassJoin(7); }
|
||||
void VGUI_JoinSpy (void) { VGUI_ClassJoin(8); }
|
||||
void VGUI_JoinEngineer (void) { VGUI_ClassJoin(9); }
|
||||
|
||||
btnarr_t g_tfc_vgui_classlist[] = {
|
||||
{"SCOUT", VGUI_JoinScout },
|
||||
{"SNIPER", VGUI_JoinSniper },
|
||||
{"SOLDIER", VGUI_JoinSoldier },
|
||||
{"DEMOMAN", VGUI_JoinDemoman },
|
||||
{"MEDIC", VGUI_JoinMedic },
|
||||
{"HWGUY", VGUI_JoinHwguy },
|
||||
{"PYRO", VGUI_JoinPyro },
|
||||
{"SPY", VGUI_JoinSpy },
|
||||
{"ENGINEER", VGUI_JoinEngineer },
|
||||
{__NULL__, __NULL__ },
|
||||
{"< Back", VGUI_TeamBack }
|
||||
};
|
||||
|
||||
void
|
||||
VGUI_ChooseClass(void)
|
||||
{
|
||||
static int initialized;
|
||||
static CUIButton *btns;
|
||||
|
||||
if (!initialized) {
|
||||
vector btnpos = [16,0];
|
||||
initialized = TRUE;
|
||||
winClassSelection = spawn(CUIWindow);
|
||||
winClassSelection.SetTitle("Choose Skin");
|
||||
winClassSelection.SetSize([420,320]);
|
||||
g_uiDesktop.Add(winClassSelection);
|
||||
|
||||
btns = memalloc(sizeof(btnarr_t) * g_tfc_vgui_classlist.length);
|
||||
for (int i = 0; i < g_tfc_vgui_classlist.length; i++) {
|
||||
btnpos[1] += 30;
|
||||
if (g_tfc_vgui_classlist[i].ptr == __NULL__) {
|
||||
continue;
|
||||
}
|
||||
btns[i] = spawn(CUIButton);
|
||||
btns[i].SetTitle(g_tfc_vgui_classlist[i].str);
|
||||
btns[i].SetPos(btnpos);
|
||||
btns[i].SetFunc(g_tfc_vgui_classlist[i].ptr);
|
||||
winClassSelection.Add(btns[i]);
|
||||
}
|
||||
}
|
||||
|
||||
winClassSelection.Show();
|
||||
winClassSelection.SetPos((video_res / 2) - (winClassSelection.GetSize() / 2));
|
||||
}
|
|
@ -15,298 +15,88 @@
|
|||
*/
|
||||
|
||||
static CUIWindow winChooseTeam;
|
||||
static CUIWindow winCTTeam;
|
||||
static CUIWindow winTTeam;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
string str;
|
||||
void(void) ptr;
|
||||
} btnarr_t;
|
||||
|
||||
void
|
||||
VGUI_TeamJoin(float i)
|
||||
VGUI_ChooseTeam_Blue(void)
|
||||
{
|
||||
sendevent("TeamJoin", "f", i);
|
||||
winCTTeam.Hide();
|
||||
}
|
||||
|
||||
void
|
||||
VGUI_TeamBack(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void VGUI_JoinScout_B (void) { VGUI_TeamJoin(1); }
|
||||
void VGUI_JoinSniper_B (void) { VGUI_TeamJoin(2); }
|
||||
void VGUI_JoinSoldier_B (void) { VGUI_TeamJoin(3); }
|
||||
void VGUI_JoinDemoman_B (void) { VGUI_TeamJoin(4); }
|
||||
void VGUI_JoinMedic_B (void) { VGUI_TeamJoin(5); }
|
||||
void VGUI_JoinHwguy_B (void) { VGUI_TeamJoin(6); }
|
||||
void VGUI_JoinPyro_B (void) { VGUI_TeamJoin(7); }
|
||||
void VGUI_JoinSpy_B (void) { VGUI_TeamJoin(8); }
|
||||
void VGUI_JoinEngineer_B (void) { VGUI_TeamJoin(9); }
|
||||
|
||||
void VGUI_JoinScout_R (void) { VGUI_TeamJoin(11); }
|
||||
void VGUI_JoinSniper_R (void) { VGUI_TeamJoin(12); }
|
||||
void VGUI_JoinSoldier_R (void) { VGUI_TeamJoin(13); }
|
||||
void VGUI_JoinDemoman_R (void) { VGUI_TeamJoin(14); }
|
||||
void VGUI_JoinMedic_R (void) { VGUI_TeamJoin(15); }
|
||||
void VGUI_JoinHwguy_R (void) { VGUI_TeamJoin(16); }
|
||||
void VGUI_JoinPyro_R (void) { VGUI_TeamJoin(17); }
|
||||
void VGUI_JoinSpy_R (void) { VGUI_TeamJoin(18); }
|
||||
void VGUI_JoinEngineer_R (void) { VGUI_TeamJoin(19); }
|
||||
|
||||
void VGUI_JoinScout_Y (void) { VGUI_TeamJoin(21); }
|
||||
void VGUI_JoinSniper_Y (void) { VGUI_TeamJoin(22); }
|
||||
void VGUI_JoinSoldier_Y (void) { VGUI_TeamJoin(23); }
|
||||
void VGUI_JoinDemoman_Y (void) { VGUI_TeamJoin(24); }
|
||||
void VGUI_JoinMedic_Y (void) { VGUI_TeamJoin(25); }
|
||||
void VGUI_JoinHwguy_Y (void) { VGUI_TeamJoin(26); }
|
||||
void VGUI_JoinPyro_Y (void) { VGUI_TeamJoin(27); }
|
||||
void VGUI_JoinSpy_Y (void) { VGUI_TeamJoin(28); }
|
||||
void VGUI_JoinEngineer_Y (void) { VGUI_TeamJoin(29); }
|
||||
|
||||
void VGUI_JoinScout_G (void) { VGUI_TeamJoin(31); }
|
||||
void VGUI_JoinSniper_G (void) { VGUI_TeamJoin(32); }
|
||||
void VGUI_JoinSoldier_G (void) { VGUI_TeamJoin(33); }
|
||||
void VGUI_JoinDemoman_G (void) { VGUI_TeamJoin(34); }
|
||||
void VGUI_JoinMedic_G (void) { VGUI_TeamJoin(35); }
|
||||
void VGUI_JoinHwguy_G (void) { VGUI_TeamJoin(36); }
|
||||
void VGUI_JoinPyro_G (void) { VGUI_TeamJoin(37); }
|
||||
void VGUI_JoinSpy_G (void) { VGUI_TeamJoin(38); }
|
||||
void VGUI_JoinEngineer_G (void) { VGUI_TeamJoin(39); }
|
||||
|
||||
btnarr_t red_team[] = {
|
||||
{"SCOUT", VGUI_JoinScout_R },
|
||||
{"SNIPER", VGUI_JoinSniper_R },
|
||||
{"SOLDIER", VGUI_JoinSoldier_R },
|
||||
{"DEMOMAN", VGUI_JoinDemoman_R },
|
||||
{"MEDIC", VGUI_JoinMedic_R },
|
||||
{"HWGUY", VGUI_JoinHwguy_R },
|
||||
{"PYRO", VGUI_JoinPyro_R },
|
||||
{"SPY", VGUI_JoinSpy_R },
|
||||
{"ENGINEER", VGUI_JoinEngineer_R },
|
||||
{__NULL__, __NULL__ },
|
||||
{"< Back", VGUI_TeamBack }
|
||||
};
|
||||
|
||||
btnarr_t blue_team[] = {
|
||||
{"SCOUT", VGUI_JoinScout_B },
|
||||
{"SNIPER", VGUI_JoinSniper_B },
|
||||
{"SOLDIER", VGUI_JoinSoldier_B },
|
||||
{"DEMOMAN", VGUI_JoinDemoman_B },
|
||||
{"MEDIC", VGUI_JoinMedic_B },
|
||||
{"HWGUY", VGUI_JoinHwguy_B },
|
||||
{"PYRO", VGUI_JoinPyro_B },
|
||||
{"SPY", VGUI_JoinSpy_B },
|
||||
{"ENGINEER", VGUI_JoinEngineer_B },
|
||||
{__NULL__, __NULL__ },
|
||||
{"< Back", VGUI_TeamBack }
|
||||
};
|
||||
|
||||
btnarr_t yellow_team[] = {
|
||||
{"SCOUT", VGUI_JoinScout_Y },
|
||||
{"SNIPER", VGUI_JoinSniper_Y },
|
||||
{"SOLDIER", VGUI_JoinSoldier_Y },
|
||||
{"DEMOMAN", VGUI_JoinDemoman_Y },
|
||||
{"MEDIC", VGUI_JoinMedic_Y },
|
||||
{"HWGUY", VGUI_JoinHwguy_Y },
|
||||
{"PYRO", VGUI_JoinPyro_Y },
|
||||
{"SPY", VGUI_JoinSpy_Y },
|
||||
{"ENGINEER", VGUI_JoinEngineer_Y },
|
||||
{__NULL__, __NULL__ },
|
||||
{"< Back", VGUI_TeamBack }
|
||||
};
|
||||
|
||||
btnarr_t green_team[] = {
|
||||
{"SCOUT", VGUI_JoinScout_G },
|
||||
{"SNIPER", VGUI_JoinSniper_G },
|
||||
{"SOLDIER", VGUI_JoinSoldier_G },
|
||||
{"DEMOMAN", VGUI_JoinDemoman_G },
|
||||
{"MEDIC", VGUI_JoinMedic_G },
|
||||
{"HWGUY", VGUI_JoinHwguy_G },
|
||||
{"PYRO", VGUI_JoinPyro_G },
|
||||
{"SPY", VGUI_JoinSpy_G },
|
||||
{"ENGINEER", VGUI_JoinEngineer_G },
|
||||
{__NULL__, __NULL__ },
|
||||
{"< Back", VGUI_TeamBack }
|
||||
};
|
||||
|
||||
void
|
||||
VGUI_GoSpectator(void)
|
||||
{
|
||||
VGUI_TeamJoin(0);
|
||||
localcmd("changeclass\n");
|
||||
sendevent("TeamJoin", "f", 1);
|
||||
winChooseTeam.Hide();
|
||||
}
|
||||
|
||||
void
|
||||
VGUI_ChooseTeam_Red(void)
|
||||
{
|
||||
static int initialized;
|
||||
static CUIButton *btns;
|
||||
|
||||
if (!initialized) {
|
||||
vector btnpos = [16,0];
|
||||
initialized = TRUE;
|
||||
winCTTeam = spawn(CUIWindow);
|
||||
winCTTeam.SetTitle("Choose Skin");
|
||||
winCTTeam.SetSize([420,320]);
|
||||
g_uiDesktop.Add(winCTTeam);
|
||||
|
||||
btns = memalloc(sizeof(btnarr_t) * red_team.length);
|
||||
for (int i = 0; i < red_team.length; i++) {
|
||||
btnpos[1] += 30;
|
||||
if (red_team[i].ptr == __NULL__) {
|
||||
continue;
|
||||
}
|
||||
btns[i] = spawn(CUIButton);
|
||||
btns[i].SetTitle(red_team[i].str);
|
||||
btns[i].SetPos(btnpos);
|
||||
btns[i].SetFunc(red_team[i].ptr);
|
||||
winCTTeam.Add(btns[i]);
|
||||
}
|
||||
}
|
||||
|
||||
localcmd("changeclass\n");
|
||||
sendevent("TeamJoin", "f", 2);
|
||||
winChooseTeam.Hide();
|
||||
winCTTeam.Show();
|
||||
winCTTeam.SetPos((video_res / 2) - (winCTTeam.GetSize() / 2));
|
||||
}
|
||||
|
||||
void
|
||||
VGUI_ChooseTeam_Blue(void)
|
||||
{
|
||||
static int initialized;
|
||||
static CUIButton *btns;
|
||||
|
||||
if (!initialized) {
|
||||
vector btnpos = [16,0];
|
||||
initialized = TRUE;
|
||||
winTTeam = spawn(CUIWindow);
|
||||
winTTeam.SetTitle("Choose Skin");
|
||||
winTTeam.SetSize([420,320]);
|
||||
g_uiDesktop.Add(winTTeam);
|
||||
|
||||
btns = memalloc(sizeof(btnarr_t) * blue_team.length);
|
||||
for (int i = 0; i < blue_team.length; i++) {
|
||||
btnpos[1] += 30;
|
||||
if (blue_team[i].ptr == __NULL__) {
|
||||
continue;
|
||||
}
|
||||
btns[i] = spawn(CUIButton);
|
||||
btns[i].SetTitle(blue_team[i].str);
|
||||
btns[i].SetPos(btnpos);
|
||||
btns[i].SetFunc(blue_team[i].ptr);
|
||||
winTTeam.Add(btns[i]);
|
||||
}
|
||||
}
|
||||
|
||||
winChooseTeam.Hide();
|
||||
winTTeam.Show();
|
||||
winTTeam.SetPos((video_res / 2) - (winTTeam.GetSize() / 2));
|
||||
}
|
||||
|
||||
void
|
||||
VGUI_ChooseTeam_Yellow(void)
|
||||
{
|
||||
static int initialized;
|
||||
static CUIButton *btns;
|
||||
|
||||
if (!initialized) {
|
||||
vector btnpos = [16,0];
|
||||
initialized = TRUE;
|
||||
winTTeam = spawn(CUIWindow);
|
||||
winTTeam.SetTitle("Choose Skin");
|
||||
winTTeam.SetSize([420,320]);
|
||||
g_uiDesktop.Add(winTTeam);
|
||||
|
||||
btns = memalloc(sizeof(btnarr_t) * yellow_team.length);
|
||||
for (int i = 0; i < yellow_team.length; i++) {
|
||||
btnpos[1] += 30;
|
||||
if (yellow_team[i].ptr == __NULL__) {
|
||||
continue;
|
||||
}
|
||||
btns[i] = spawn(CUIButton);
|
||||
btns[i].SetTitle(yellow_team[i].str);
|
||||
btns[i].SetPos(btnpos);
|
||||
btns[i].SetFunc(yellow_team[i].ptr);
|
||||
winTTeam.Add(btns[i]);
|
||||
}
|
||||
}
|
||||
|
||||
winChooseTeam.Hide();
|
||||
winTTeam.Show();
|
||||
winTTeam.SetPos((video_res / 2) - (winTTeam.GetSize() / 2));
|
||||
}
|
||||
|
||||
void
|
||||
VGUI_ChooseTeam_Green(void)
|
||||
{
|
||||
static int initialized;
|
||||
static CUIButton *btns;
|
||||
|
||||
if (!initialized) {
|
||||
vector btnpos = [16,0];
|
||||
initialized = TRUE;
|
||||
winTTeam = spawn(CUIWindow);
|
||||
winTTeam.SetTitle("Choose Skin");
|
||||
winTTeam.SetSize([420,320]);
|
||||
g_uiDesktop.Add(winTTeam);
|
||||
|
||||
btns = memalloc(sizeof(btnarr_t) * green_team.length);
|
||||
for (int i = 0; i < green_team.length; i++) {
|
||||
btnpos[1] += 30;
|
||||
if (green_team[i].ptr == __NULL__) {
|
||||
continue;
|
||||
}
|
||||
btns[i] = spawn(CUIButton);
|
||||
btns[i].SetTitle(green_team[i].str);
|
||||
btns[i].SetPos(btnpos);
|
||||
btns[i].SetFunc(green_team[i].ptr);
|
||||
winTTeam.Add(btns[i]);
|
||||
}
|
||||
}
|
||||
|
||||
localcmd("changeclass\n");
|
||||
sendevent("TeamJoin", "f", 3);
|
||||
winChooseTeam.Hide();
|
||||
}
|
||||
|
||||
void
|
||||
VGUI_ChooseTeam_Yellow(void)
|
||||
{
|
||||
localcmd("changeclass\n");
|
||||
sendevent("TeamJoin", "f", 4);
|
||||
winChooseTeam.Hide();
|
||||
}
|
||||
|
||||
void
|
||||
VGUI_GoSpectator(void)
|
||||
{
|
||||
//VGUI_TeamJoin(0);
|
||||
sendevent("TeamJoin", "f", 0);
|
||||
winChooseTeam.Hide();
|
||||
winTTeam.Show();
|
||||
winTTeam.SetPos((video_res / 2) - (winTTeam.GetSize() / 2));
|
||||
}
|
||||
|
||||
void
|
||||
VGUI_ChooseTeam(void)
|
||||
{
|
||||
static int initialized;
|
||||
static CUIButton btnGoRed;
|
||||
static CUIButton btnGoBlue;
|
||||
static CUIButton btnGoYellow;
|
||||
static CUIButton btnGoGreen;
|
||||
static CUIButton btnGoSpectator;
|
||||
|
||||
if (!initialized) {
|
||||
vector btnpos = [16,48];
|
||||
|
||||
initialized = TRUE;
|
||||
winChooseTeam = spawn(CUIWindow);
|
||||
winChooseTeam.SetTitle("Choose Team");
|
||||
winChooseTeam.SetSize('420 320');
|
||||
|
||||
btnGoRed = spawn(CUIButton);
|
||||
btnGoRed.SetTitle("Red Team");
|
||||
btnGoRed.SetPos('8 132');
|
||||
btnGoRed.SetFunc(VGUI_ChooseTeam_Red);
|
||||
for (int t = 1; t <= serverkeyfloat("teams"); t++) {
|
||||
CUIButton btnForTeam;
|
||||
string team_name = serverkey(sprintf("team_%i", t));
|
||||
|
||||
btnGoBlue = spawn(CUIButton);
|
||||
btnGoBlue.SetTitle("Blue Team");
|
||||
btnGoBlue.SetPos('8 162');
|
||||
btnGoBlue.SetFunc(VGUI_ChooseTeam_Blue);
|
||||
btnForTeam = spawn(CUIButton);
|
||||
btnForTeam.SetTitle(team_name);
|
||||
btnForTeam.SetPos(btnpos);
|
||||
|
||||
btnGoYellow = spawn(CUIButton);
|
||||
btnGoYellow.SetTitle("Yellow Team");
|
||||
btnGoYellow.SetPos('8 192');
|
||||
btnGoYellow.SetFunc(VGUI_ChooseTeam_Yellow);
|
||||
switch (team_name) {
|
||||
case "Blue":
|
||||
btnForTeam.SetFunc(VGUI_ChooseTeam_Blue);
|
||||
break;
|
||||
case "Red":
|
||||
btnForTeam.SetFunc(VGUI_ChooseTeam_Red);
|
||||
break;
|
||||
case "Green":
|
||||
btnForTeam.SetFunc(VGUI_ChooseTeam_Green);
|
||||
break;
|
||||
case "Yellow":
|
||||
btnForTeam.SetFunc(VGUI_ChooseTeam_Yellow);
|
||||
break;
|
||||
}
|
||||
|
||||
winChooseTeam.Add(btnForTeam);
|
||||
btnpos[1] += 30;
|
||||
}
|
||||
|
||||
btnGoGreen = spawn(CUIButton);
|
||||
btnGoGreen.SetTitle("Green Team");
|
||||
btnGoGreen.SetPos('8 222');
|
||||
btnGoGreen.SetFunc(VGUI_ChooseTeam_Green);
|
||||
|
||||
btnGoSpectator = spawn(CUIButton);
|
||||
btnGoSpectator.SetTitle("Spectator");
|
||||
|
@ -314,10 +104,6 @@ VGUI_ChooseTeam(void)
|
|||
btnGoSpectator.SetFunc(VGUI_GoSpectator);
|
||||
|
||||
g_uiDesktop.Add(winChooseTeam);
|
||||
winChooseTeam.Add(btnGoRed);
|
||||
winChooseTeam.Add(btnGoBlue);
|
||||
winChooseTeam.Add(btnGoYellow);
|
||||
winChooseTeam.Add(btnGoGreen);
|
||||
winChooseTeam.Add(btnGoSpectator);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,38 +17,73 @@
|
|||
void
|
||||
CSEv_TeamJoin_f(float f)
|
||||
{
|
||||
if (self.classname != "player") {
|
||||
spawnfunc_player();
|
||||
}
|
||||
|
||||
player pl = (player)self;
|
||||
|
||||
/* mess, do it better */
|
||||
if (f < 10) {
|
||||
if (f == 1) {
|
||||
pl.team = 1; /* Blue */
|
||||
forceinfokey(pl, "topcolor", "0x9aff");
|
||||
forceinfokey(pl, "bottomcolor", "0x9aff");
|
||||
} else if (f < 20) {
|
||||
} else if (f == 2) {
|
||||
pl.team = 2; /* Red */
|
||||
f -= 10;
|
||||
forceinfokey(pl, "topcolor", "0xff1800");
|
||||
forceinfokey(pl, "bottomcolor", "0xff1800");
|
||||
} else if (f < 30) {
|
||||
} else if (f == 3) {
|
||||
pl.team = 3; /* Yellow */
|
||||
f -= 20;
|
||||
forceinfokey(pl, "topcolor", "0xffca00");
|
||||
forceinfokey(pl, "bottomcolor", "0xffca00");
|
||||
} else if (f < 40) {
|
||||
} else if (f == 4) {
|
||||
pl.team = 4; /* Green */
|
||||
f -= 30;
|
||||
forceinfokey(pl, "topcolor", "0x3bff00");
|
||||
forceinfokey(pl, "bottomcolor", "0x3bff00");
|
||||
} else {
|
||||
/* invalid */
|
||||
return;
|
||||
}
|
||||
|
||||
/* assign our class type for safe keeping */
|
||||
pl.classtype = f;
|
||||
|
||||
/* turn the player into the class of his choice */
|
||||
pl.MakeClass(f);
|
||||
pl.SpawnIntoGame();
|
||||
if (self.health > 0) {
|
||||
ClientKill();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
CSEv_ClassJoin_f(float f)
|
||||
{
|
||||
|
||||
player pl = (player)self;
|
||||
|
||||
/* invalid */
|
||||
if (pl.team == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.classname != "player") {
|
||||
spawnfunc_player();
|
||||
}
|
||||
|
||||
/* invalid */
|
||||
if (pl.classtype == f)
|
||||
return;
|
||||
|
||||
/* if we're still alive... */
|
||||
if (pl.health > 0) {
|
||||
pl.classtype = f;
|
||||
pl.MakeClass(f);
|
||||
ClientKill();
|
||||
} else {
|
||||
/* insta spawn */
|
||||
|
||||
/* assign our class type for safe keeping */
|
||||
pl.classtype = f;
|
||||
|
||||
/* turn the player into the class of his choice */
|
||||
pl.MakeClass(f);
|
||||
pl.SpawnIntoGame();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue