-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnoobprotector.sp
130 lines (103 loc) · 3.26 KB
/
noobprotector.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
#pragma semicolon 1
#pragma newdecls required
#include <kcf_core>
#include <smutils>
#include <sdkhooks>
#include <insurgency>
#include <ins_supporter>
public Plugin myinfo =
{
name = "Noob Protector",
author = "Kyle",
description = "<- description ->",
version = "1.0",
url = "https://www.kxnrl.com"
};
static float g_fSpawnTime[MAXPLAYERS+1];
static int g_iServerId = -1;
static int g_iOffset = -1;
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
RegPluginLibrary("Insurgency-NoobProtector");
MarkNativeAsOptional("Ins_GetSupporter");
return APLRes_Success;
}
public void OnPluginStart()
{
SMUitls_InitUserMessage();
SMUtils_SetChatPrefix("[{purple}魔法少女{white}]");
SMUtils_SetChatSpaces(" ");
HookEvent("player_spawn", Event_Spawn, EventHookMode_Post);
for(int client = MinClients; client <= MaxClients; ++client)
if (IsClientInGame(client))
OnClientPutInServer(client);
g_iServerId = KCF_Server_GetSrvId();
g_iOffset = FindSendPropInfo("CINSPlayer", "m_EquippedGear");
}
public void KCF_OnServerLoaded(int sid, int mod)
{
g_iServerId = sid;
}
public void OnClientPutInServer(int client)
{
if (IsFakeClient(client))
return;
SDKHook(client, SDKHook_OnTakeDamage, Event_TraceAlive);
}
public void Event_Spawn(Event e, const char[] name, bool db)
{
int client = GetClientOfUserId(e.GetInt("userid"));
g_fSpawnTime[client] = GetGameTime();
}
public Action Event_TraceAlive(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &weapon, float damageForce[3], float damagePosition[3], int damagecustom)
{
if (attacker > MaxClients || attacker < MinClients) return Plugin_Continue;
if (damagetype == DMG_BLAST)
{
if (g_iServerId == 12 || g_iServerId == 13)
{
switch (GetPlayerArmorType(victim))
{
case Armor_Light:
{
damage *= 0.75;
return Plugin_Changed;
}
case Armor_Heavy:
{
damage *= 0.55;
return Plugin_Changed;
}
case Armor_None : return Plugin_Continue;
default: return Plugin_Continue;
}
}
if (attacker == victim)
return Plugin_Continue;
if (GetGameTime() - g_fSpawnTime[victim] <= GetProtectTime(victim))
{
if (IsClientInGame(attacker))
{
Chat(victim, "{blue}已免疫来自{green} %N {blue}的爆炸物伤害", attacker);
Chat(attacker, "{green} %N {blue}处于出生爆炸物保护时间内", victim);
}
return Plugin_Handled;
}
}
return Plugin_Continue;
}
stock CINSArmorType GetPlayerArmorType(int client)
{
return view_as<CINSArmorType>(GetEntData(client, g_iOffset + (4 * view_as<int>(m_Gear_Armor))));
}
stock float GetProtectTime(int client)
{
int level = Vip(client);
return 8.0 + level * 1.5;
}
stock int Vip(int client)
{
if (!LibraryExists("Insurgency-Supporter"))
return 0;
return Ins_GetSupporter(client);
}