-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmm_attribute_start_with_charge.sp
57 lines (47 loc) · 1.26 KB
/
mm_attribute_start_with_charge.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
#include <sourcemod>
#include <sdkhooks>
#include <tf2>
#include <tf2_stocks>
#include <tf2wearables>
#include <sdktools_stringtables>
#include <sdktools_tempents>
#include <sdktools>
#include <tf2attributes>
#include <tf_custom_attributes>
#include <stocksoup/var_strings>
#include <berobot_constants>
#include <berobot>
float g_Amount = 1.0;
public void OnPluginStart()
{
HookEvent("player_spawn", Event_PlayerSpawn, EventHookMode_Post);
HookEvent("post_inventory_application", Event_PlayerSpawn, EventHookMode_Post);
}
public Action Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(GetEventInt(event, "userid"));
CreateTimer(0.6, Timer_StatCheck, client);
}
public Action Timer_StatCheck(Handle timer, int client)
{
if (HasStats(client))
{
if(HasEntProp(client, Prop_Send, "m_flRageMeter"))
{
SetEntPropFloat(client, Prop_Send, "m_flRageMeter", g_Amount);
}
}
}
bool HasStats(int client)
{
if (IsValidClient(client))
{
char stat_buffer[256];
if (!TF2CustAttr_GetString(client, "start-with-charge", stat_buffer, sizeof(stat_buffer))) {
return false;
}
g_Amount = ReadFloatVar(stat_buffer, "amount", 1.0);
return true;
}
return false;
}