forked from dordnung/Stamm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstamm_resizeplayer.sp
202 lines (142 loc) · 4.03 KB
/
stamm_resizeplayer.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
194
195
196
197
198
199
200
201
202
/**
* -----------------------------------------------------
* File stamm_resizeplayer.sp
* Authors David <popoklopsi> Ordnung
* License GPLv3
* Web http://popoklopsi.de
* -----------------------------------------------------
*
* Copyright (C) 2012-2014 David <popoklopsi> Ordnung
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
// Include
#include <sourcemod>
#include <autoexecconfig>
#undef REQUIRE_PLUGIN
#include <stamm>
#pragma semicolon 1
new Handle:g_hResize;
new Float:g_hClientSize[MAXPLAYERS + 1];
// Plugin ifno
public Plugin:myinfo =
{
name = "Stamm Feature ResizePlayer",
author = "Popoklopsi",
version = "${-version-}", // Version is replaced by GitLab runner due the build phase
description = "Resizes VIP's",
url = "https://gitlab.com/PushTheLimits/Sourcemod/Stamm/wikis"
};
// All Plugins loaded
public OnAllPluginsLoaded()
{
// Stamm not found
if (!STAMM_IsAvailable())
{
SetFailState("Can't Load Feature, Stamm is not installed!");
}
// Not for game CSGO
if (STAMM_GetGame() == GameCSGO)
{
SetFailState("Can't Load Feature. not Supported for your game!");
}
// Load translation and add feaure
STAMM_LoadTranslation();
STAMM_RegisterFeature("VIP Resize Player");
}
// Feature started
public OnPluginStart()
{
// Hook event player spawn
HookEvent("player_spawn", PlayerSpawn);
// Create Config
AutoExecConfig_SetFile("resizeplayer", "stamm/features");
AutoExecConfig_SetCreateFile(true);
g_hResize = AutoExecConfig_CreateConVar("resize_amount", "10", "Resize amount in(+)/de(-)crease in percent each block!");
AutoExecConfig_CleanFile();
AutoExecConfig_ExecuteFile();
}
public STAMM_OnFeatureLoaded(const String:basename[])
{
}
// Add descriptions
public STAMM_OnClientRequestFeatureInfo(client, block, &Handle:array)
{
decl String:fmt[256];
Format(fmt, sizeof(fmt), "%T", "GetResize", client, GetConVarInt(g_hResize) * block);
PushArrayString(array, fmt);
}
// Client is ready
public STAMM_OnClientReady(client)
{
// Default size is 1.0
g_hClientSize[client] = 1.0;
// For each block
for (new i=STAMM_GetBlockCount(); i > 0; i--)
{
// Client has feature
if (STAMM_HaveClientFeature(client, i))
{
// set new size
g_hClientSize[client] = 1.0 + float(GetConVarInt(g_hResize))/100.0 * i;
if (g_hClientSize[client] < 0.1)
{
g_hClientSize[client] = 0.1;
}
// Break here
break;
}
}
}
// Resize player on Spawn
public PlayerSpawn(Handle:event, String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
STAMM_OnClientChangedFeature(client, true, false);
}
public STAMM_OnClientBecomeVip(client, oldlevel, newlevel)
{
STAMM_OnClientReady(client);
}
// Client changed a feature
public STAMM_OnClientChangedFeature(client, bool:mode, bool:isShop)
{
if (STAMM_IsClientValid(client))
{
// Resize is defined in metod OnClientReady
STAMM_OnClientReady(client);
// Setz size
SetEntPropFloat(client, Prop_Send, "m_flModelScale", g_hClientSize[client]);
if (STAMM_GetGame() == GameTF2)
{
// On TF2 setz head size
SetEntPropFloat(client, Prop_Send, "m_flHeadScale", g_hClientSize[client]);
}
}
}
// For TF2 set head size on game frame
public OnGameFrame()
{
if (STAMM_GetGame() == GameTF2)
{
for (new i = 1; i <= MaxClients; i++)
{
if (STAMM_IsClientValid(i) && g_hClientSize[i] != 1.0)
{
// Set head size
SetEntPropFloat(i, Prop_Send, "m_flHeadScale", g_hClientSize[i]);
}
}
}
}