-
Notifications
You must be signed in to change notification settings - Fork 0
/
ForgiveTKMenu.cpp
115 lines (101 loc) · 3.68 KB
/
ForgiveTKMenu.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/* ======== Basic Admin tool ========
* Copyright (C) 2004-2007 Erling K. Sæterdal
* No warranties of any kind
*
* License: zlib/libpng
*
* Author(s): Erling K. Sæterdal ( EKS )
* Credits:
* Menu code based on code from CSDM ( http://www.tcwonline.org/~dvander/cssdm ) Created by BAILOPAN
* Adminloading function from Xaphan ( http://www.sourcemod.net/forums/viewtopic.php?p=25807 ) Created by Devicenull
* Helping on misc errors/functions: BAILOPAN,sslice,devicenull,PMOnoTo,cybermind ( most who idle in #sourcemod on GameSurge realy )
* ============================ */
#include "ForgiveTK.h"
#include "ForgiveTKMenu.h"
#include "BATMenu.h"
#include "Utils.h"
extern int g_ForgiveTKMenu;
extern int g_MaxClients;
extern BATMenuMngr g_MenuMngr;
extern Utils *m_Utils;
extern ConstPlayerInfo g_UserInfo[MAXPLAYERS+1];
extern TeamKillOptionsStruct TKSettings;
extern bool g_IsConnected[MAXPLAYERS+1];
bool ForgiveTKMenu::Display(BATMenuBuilder *make, int playerIndex)
{
make->SetKeys( (1<<0) | (1<<1) | (1<<2) | (1<<3) | (1<<4) | (1<<5) | (1<<6) | (1<<7)| (1<<8) | (1<<9));
char Title[48];
_snprintf(Title,47,"Forgive %s for killing you",g_ForgiveTKCore.GetPlayerName(g_UserInfo[playerIndex].LastTKIndex));
make->SetTitle(Title);
make->AddOption("Yes");
make->AddOption(GetPunishmentText());
if(g_MenuMngr.GetMenuType() == 2)
g_ForgiveTKCore.MessagePlayer(0,"Press ESC to either forgive %s or not",g_ForgiveTKCore.GetPlayerName(g_UserInfo[playerIndex].LastTKIndex));
return true;
}
MenuSelectionType ForgiveTKMenu::MenuChoice(player_t player, int option)
{
int id = player.index;
int IndexAttacker = g_UserInfo[id].LastTKIndex;
if(g_IsConnected[IndexAttacker] == false)
return MENUSELECTION_NOSOUND;
//if(!g_ModSettings.DefaultRadioMenuSupport)
// g_ForgiveTKCore.MessagePlayer(id,"You need to press ESC to see the menu");
if(option == 1) // Forgives the player
{
g_ForgiveTKCore.ForgivePlayerTK(id);
//g_ForgiveTKCore.MessagePlayer(0,"[ForgiveTK] %s choose to forgive %s",g_ForgiveTKCore.GetPlayerName(id),g_ForgiveTKCore.GetPlayerName(g_UserInfo[id].LastTKIndex));
return MENUSELECTION_GOOD;
}
else if(option == 2)
{
if(TKSettings.PunishOption == PunishDisabled)
g_ForgiveTKCore.MessagePlayer(0,"[ForgiveTK] %s choose to NOT forgive %s",g_ForgiveTKCore.GetPlayerName(id),g_ForgiveTKCore.GetPlayerName(g_UserInfo[id].LastTKIndex));
else
PunishPlayer(id);
return MENUSELECTION_GOOD;
}
else
g_MenuMngr.ShowMenu(id,g_ForgiveTKMenu);
return MENUSELECTION_BAD;
}
void ForgiveTKMenu::PunishPlayer(int id)
{
int TKIndex = g_UserInfo[id].LastTKIndex;
if(TKSettings.PunishOption == PunishSlay)
{
g_ForgiveTKCore.MessagePlayer(0,"[ForgiveTK] %s choose to not forgive %s and have him slayed",g_ForgiveTKCore.GetPlayerName(id),g_ForgiveTKCore.GetPlayerName(TKIndex));
g_ForgiveTKCore.GetHelpers()->ClientCommand(g_UserInfo[TKIndex].PlayerEdict,"kill");
}
else if(TKSettings.PunishOption == PunishSlap)
{
int Health = m_Utils->UTIL_GetHealth(g_UserInfo[TKIndex].PlayerEdict) * 0.5;
m_Utils->UTIL_SetHealth(g_UserInfo[TKIndex].PlayerEdict,Health);
}
}
const char *ForgiveTKMenu::GetPunishmentText()
{
/*
// static char PunishText[48];
//
// if(TKSettings.PunishOption == PunishSlay)
// _snprintf(PunishText,47,"No (Slayed)");
//
// else if(TKSettings.PunishOption == PunishSlap)
// _snprintf(PunishText,47,"No (Slap away 50%% of HP)");
//
// else
// _snprintf(PunishText,47,"No");
//
// return PunishText;
*/
switch(TKSettings.PunishOption)
{
case PunishSlay:
return "No (Slayed)";
case PunishSlap:
return "No (Slap away 50%% of HP)";
default:
return "No";
}
}