-
Notifications
You must be signed in to change notification settings - Fork 15
/
Paintball2.sp
191 lines (137 loc) · 4.58 KB
/
Paintball2.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
#pragma semicolon 1
#define DEBUG
#define PLUGIN_AUTHOR "boomix / Mitchell"
#define PLUGIN_VERSION "2.2"
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#include <sdkhooks>
#include <emitsoundany>
#include <autoexecconfig>
#include "paintball2/pb_globals.sp"
#include "paintball2/pb_shoot.sp"
#include "paintball2/pb_downloadprecache.sp"
#include "paintball2/pb_ballglow.sp"
#include "paintball2/pb_shakescreen.sp"
#include "paintball2/pb_paint.sp"
#include "paintball2/pb_grenade.sp"
public Plugin myinfo =
{
name = "Paintball for CS:GO",
author = PLUGIN_AUTHOR,
description = "Paintball gamemode for CS:GO made by boomix, some code from Mitchell",
version = PLUGIN_VERSION,
url = "http://www.burst.lv"
};
public void OnPluginStart()
{
LoopAllPlayers(i)
{
SDKHook(i, SDKHook_WeaponSwitchPost, WeaponEquipPost);
SDKHook(i, SDKHook_WeaponDrop, WeaponDrop);
//SDKHook(i, SDKHook_WeaponEquipPost, WeaponEquipPost);
SetDefaultPlayerCvars(i);
QueryClientConVar(i, "cl_autowepswitch", ConVar_QueryClient);
}
HookEvent("hegrenade_detonate", Event_GrenadeStarted, EventHookMode_Pre);
HookEvent("player_spawn", Event_PlayerSpawn);
//Config files
AutoExecConfig_SetFile("paintball");
HookConVarChange(GrenadeEnable = AutoExecConfig_CreateConVar("sm_grenades_enable", "1", "Gives randomly grenades every round"), OnCvarChanged);
HookConVarChange(GranadeChance = AutoExecConfig_CreateConVar("sm_grenades_chance", "10", "% chance to get grenade on spawn (max 100%)"), OnCvarChanged);
AutoExecConfig_ExecuteFile();
AutoExecConfig_CleanFile();
UpdateConvars();
}
public void OnCvarChanged(Handle hConvar, const char[] chOldValue, const char[] chNewValue)
{
UpdateConvars();
}
public void UpdateConvars()
{
GRENADE_ENABLE = GetConVarInt(GrenadeEnable);
GRENADE_CHANCE = GetConVarInt(GranadeChance);
}
public void WeaponDrop(int client, int weapon)
{
if(weapon > 0 && IsValidEntity(weapon))
{
char classname[120];
GetEntityClassname(weapon, classname, 120);
if(StrContains(classname, "weapon_") != -1)
{
SetEntProp(weapon, Prop_Data, "m_nSolidType", 6);
SetEntProp(weapon, Prop_Send, "m_CollisionGroup", 1);
}
}
}
public void WeaponEquipPost(int client, int weapon)
{
char WeaponName[120];
GetEntityClassname(weapon, WeaponName, sizeof(WeaponName));
if (WeaponTookTimer[client] != null)
{
KillTimer(WeaponTookTimer[client]);
WeaponTookTimer[client] = null;
}
//PrintToChatAll("%s", WeaponName);
//Get stuff from config file
KeyValues kvPaint = CreateKeyValues("Paintball-guns");
SetEntPropFloat(client, Prop_Send, "m_flLaggedMovementValue", 1.0);
if(!kvPaint.ImportFromFile(g_PaintballConfig)) return;
if (!kvPaint.JumpToKey(WeaponName, false)) {
b_HWShootable[client] = false;
return;
} else {
b_HWShootable[client] = true;
}
//Weapon automatic
if(KvGetNum(kvPaint, "auto", 0) == 1)
b_IsGunAutomic[client] = true;
else
b_IsGunAutomic[client] = false;
//HW == Holding weapon
//Bullet speed
i_HWBulletSpeed[client] = kvPaint.GetFloat("bullet-speed", 1600.0);
//Bullet gravity
f_HWBulletGravity[client] = kvPaint.GetFloat("bullet-gravity", 0.2);
//Accuaracy
f_HWAccuracy[client] = kvPaint.GetFloat("accuracy", 0.0);
//Jump accuracy
f_HWJumpAccuracy[client] = kvPaint.GetFloat("jump-accuracy", 0.0);
//Running speed
SetEntPropFloat(client, Prop_Send, "m_flLaggedMovementValue", kvPaint.GetFloat("running-speed", 1.0));
//f_HWRunningSpeed[client] = kvPaint.GetFloat("running-speed", 1.0);
//Reload speed
f_HWReloadingSpeed[client] = kvPaint.GetFloat("reload-speed", 1.0);
//Gun switch speed
f_HWSwitchGunSpeed[client] = kvPaint.GetFloat("switch-guns-speed", 1.0);
//Time between shots
f_HWTimeBetweenShots[client] = kvPaint.GetFloat("shot-delay", 0.01);
if(IsValidEntity(weapon) && b_HWShootable[client])
{
b_JustTookWeapon[client] = true;
int ammo = GetEntProp(weapon, Prop_Send, "m_iClip1");
if(ammo == 0)
{
UnBlockRealShooting(weapon);
b_IsReloading[client] = true;
} else {
BlockRealShooting(weapon);
b_IsReloading[client] = false;
}
WeaponTookTimer[client] = CreateTimer(f_HWSwitchGunSpeed[client], JustTookWeaponDisable, client);
} else {
//PrintToChatAll("%s", WeaponName);
if(StrContains(WeaponName, "knife") == -1 && StrContains(WeaponName, "weapon_hegrenade") == -1)
BlockRealShooting(weapon);
b_IsReloading[client] = false;
b_JustTookWeapon[client] = false;
}
b_JustFired[client] = false;
}
public Action JustTookWeaponDisable(Handle tmr, any client)
{
b_JustTookWeapon[client] = false;
WeaponTookTimer[client] = null;
}