forked from ugurbayraktarr/Plugins-for-CSGO-Servers
-
Notifications
You must be signed in to change notification settings - Fork 3
/
adminHerkesiIzleme.sp
110 lines (84 loc) · 2.13 KB
/
adminHerkesiIzleme.sp
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
#include <sourcemod>
#include <cstrike>
public Plugin myinfo =
{
name = "specmode",
author = "Hattrick HKS",
description = "Admin Spectator Mode",
version = "1.0",
url = "http://hattrick.go.ro/"
};
#define REQUIRED_FLAG ADMFLAG_BAN
enum SpecMode
{
SpecMode_None = 0,
SpecMode_1ST_Person = 4,
SpecMode_3RD_Person,
SpecMode_Free_Look
};
public void OnPluginStart()
{
RegConsoleCmd("spec_mode", OnSpecMode);
}
public Action OnSpecMode(int iId, int iArgs)
{
static int iMode = view_as<int>(SpecMode_None);
if (iId >= 1 && iId <= MaxClients && IsClientInGame(iId) && \
!IsFakeClient(iId) && !IsClientSourceTV(iId) && \
F_IsAdmin(iId) && F_CanSwitchSpecMode(iId, iMode))
{
switch (iMode)
{
case view_as<int>(SpecMode_1ST_Person):
{
SetEntProp(iId, Prop_Send, "m_iObserverMode", view_as<int>(SpecMode_3RD_Person));
}
case view_as<int>(SpecMode_3RD_Person):
{
SetEntProp(iId, Prop_Send, "m_iObserverMode", view_as<int>(SpecMode_Free_Look));
}
case view_as<int>(SpecMode_Free_Look):
{
SetEntProp(iId, Prop_Send, "m_iObserverMode", view_as<int>(SpecMode_1ST_Person));
}
}
return Plugin_Stop;
}
return Plugin_Continue;
}
bool F_IsAdmin(int iId)
{
static int iFlags = 0;
iFlags = GetUserFlagBits(iId);
if (iFlags & ADMFLAG_ROOT)
{
return true;
}
if (iFlags & REQUIRED_FLAG)
{
return true;
}
return false;
}
bool F_CanSwitchSpecMode(int iId, int& iMode)
{
static int iTeam = CS_TEAM_NONE;
static int iSpecMode = view_as<int>(SpecMode_None);
iMode = iSpecMode;
if (IsPlayerAlive(iId))
{
return false;
}
iTeam = GetClientTeam(iId);
if (iTeam != CS_TEAM_T && iTeam != CS_TEAM_CT)
{
return false;
}
iSpecMode = GetEntProp(iId, Prop_Send, "m_iObserverMode");
iMode = iSpecMode;
if (iSpecMode == view_as<int>(SpecMode_None))
{
return false;
}
return true;
}