forked from Walderr/ZE-Plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vip_seat.sp
193 lines (143 loc) · 5.12 KB
/
vip_seat.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#include <sdktools>
#include <cstrike>
int bSeated[MAXPLAYERS+1];
Handle tSeatCheck[MAXPLAYERS+1] = INVALID_HANDLE;
public Plugin myinfo =
{
name = "VIP - Seat",
author = "Walderr",
description = "Позволяет садиться на других игроков",
version = "1.1",
url = "http://www.jaze.ru/"
};
public void OnPluginStart()
{
LoadTranslations("common.phrases");
RegAdminCmd("sm_seat", Command_Seat, ADMFLAG_CUSTOM1);
RegAdminCmd("sm_unseat", Command_Unseat, ADMFLAG_CUSTOM1);
HookEvent("round_start", Event_RoundStart);
HookEvent("player_team", Event_PlayerTeam);
}
public Action Event_RoundStart(Handle event, const char[] name, bool dontBroadcast)
{
for(int i = 1; i <= MaxClients; i++)
{
if(bSeated[i]) bSeated[i] = false;
if(IsClientInGame(i) && GetEntPropEnt(i, Prop_Data, "m_hOwnerEntity") != -1) SetEntPropEnt(i, Prop_Data, "m_hOwnerEntity", -1);
}
}
public Action Event_PlayerTeam(Handle event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(GetEventInt(event, "userid"));
int team = GetEventInt(event, "team");
if(bSeated[client])
{
if(team == CS_TEAM_T) FakeClientCommand(client, "sm_unseat");
}
if(team < 2)
{
if(bSeated[client]) FakeClientCommand(client, "sm_unseat");
int owner = GetEntPropEnt(client, Prop_Data, "m_hOwnerEntity");
if(owner != -1)
{
FakeClientCommand(owner, "sm_unseat");
bSeated[owner] = false;
PrintToChat(owner, " \x09[Seat] Игрок %N больше не доступен!", client);
}
}
}
public Action Command_Seat(int client, int args)
{
char arg[64];
GetCmdArgString(arg, sizeof(arg));
new target = FindTarget(client, arg);
if(target == -1) return Plugin_Handled;
if(!IsPlayerAlive(client))
{
PrintToChat(client, " \x09[Seat] Вы должны быть живы!");
return Plugin_Handled;
}
else if(bSeated[client])
{
PrintToChat(client, " \x09[Seat] Вы уже сидите на игроке %N!", GetEntPropEnt(client, Prop_Data, "m_pParent"));
return Plugin_Handled;
}
else if(target == client)
{
PrintToChat(client, " \x09[Seat] На себя садиться нельзя!");
return Plugin_Handled;
}
else if(GetClientTeam(client) != GetClientTeam(target))
{
PrintToChat(client, " \x09[Seat] Можно садиться только на игроков своей команды!");
return Plugin_Handled;
}
else if(GetEntPropEnt(target, Prop_Data, "m_pParent") != -1)
{
PrintToChat(client, " \x09[Seat] Этот игрок уже сидит на ком-то!");
return Plugin_Handled;
}
else if(GetEntPropEnt(target, Prop_Data, "m_hOwnerEntity") != -1)
{
PrintToChat(client, " \x09[Seat] На этом игроке уже сидит %N!", GetEntPropEnt(target, Prop_Data, "m_hOwnerEntity"));
return Plugin_Handled;
}
float m_flTargetOrigin[3];
GetClientAbsOrigin(target, m_flTargetOrigin);
m_flTargetOrigin[2] = m_flTargetOrigin[2] + 30.0;
SetEntityMoveType(client, MOVETYPE_NONE);
TeleportEntity(client, m_flTargetOrigin, NULL_VECTOR, NULL_VECTOR);
SetVariantString("!activator");
AcceptEntityInput(client, "SetParent", target, client);
SetEntPropEnt(target, Prop_Data, "m_hOwnerEntity", client);
bSeated[client] = true;
PrintToChatAll(" \x09[Seat] %N сел на игрока %N.", client, target);
tSeatCheck[client] = CreateTimer(5.0, Timer_SeatCheck, client, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
return Plugin_Handled;
}
public Action Command_Unseat(int client, int args)
{
AcceptEntityInput(client, "ClearParent");
SetEntityMoveType(client, MOVETYPE_WALK);
bSeated[client] = false;
int parent = GetEntPropEnt(client, Prop_Data, "m_pParent");
if(parent != -1)
{
SetEntPropEnt(parent, Prop_Data, "m_hOwnerEntity", -1);
PrintToChatAll(" \x09[Seat] %N слез с игрока %N.", client, parent);
}
if(tSeatCheck[client] != INVALID_HANDLE)
{
KillTimer(tSeatCheck[client]);
tSeatCheck[client] = INVALID_HANDLE;
}
return Plugin_Handled;
}
public Action Timer_SeatCheck(Handle timer, any client)
{
int parent = GetEntPropEnt(client, Prop_Data, "m_pParent");
if(parent == -1)
{
KillTimer(tSeatCheck[client]);
tSeatCheck[client] = INVALID_HANDLE;
return;
}
float clientCoordinates[3];
GetClientAbsOrigin(client, clientCoordinates);
float parentCoordinates[3];
GetClientAbsOrigin(parent, parentCoordinates);
float distance = GetVectorDistance(clientCoordinates, parentCoordinates);
if(distance > 30.0)
{
SetEntPropEnt(parent, Prop_Data, "m_hOwnerEntity", -1);
AcceptEntityInput(client, "ClearParent");
float m_flTargetOrigin[3];
GetClientAbsOrigin(parent, m_flTargetOrigin);
m_flTargetOrigin[2] = m_flTargetOrigin[2] + 30.0;
SetEntityMoveType(client, MOVETYPE_NONE);
TeleportEntity(client, m_flTargetOrigin, NULL_VECTOR, NULL_VECTOR);
SetVariantString("!activator");
AcceptEntityInput(client, "SetParent", parent, client);
SetEntPropEnt(parent, Prop_Data, "m_hOwnerEntity", client);
}
}