-
Notifications
You must be signed in to change notification settings - Fork 1
/
antideaglespam.sp
54 lines (45 loc) · 1.79 KB
/
antideaglespam.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
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>
#include <smlib>
#pragma semicolon 1
#define PLUGIN_NAME "AntiDeagle Spray"
#define PLUGIN_AUTHOR "DiogoOnAir"
#define PLUGIN_DESCRIPTION "AntiDeagleSpray"
#define PLUGIN_VERSION "1.1"
public Plugin myinfo =
{
name = PLUGIN_NAME,
author = PLUGIN_AUTHOR,
description = PLUGIN_DESCRIPTION,
version = PLUGIN_VERSION,
};
public OnPluginStart()
{
HookEvent("weapon_fire", Event_WeaponFire);
}
public void Event_WeaponFire(Event event, const char[] sEventName, bool bDontBroadcast)
{
// Get the client
int client = GetClientOfUserId(event.GetInt("userid"));
// Check if our sir is valid
if (IsClientInGame(client))
{
// Array to store the client's weapon in
char sWeapon[32];
// Get the client's weapon and store it in the array
GetClientWeapon(client, sWeapon, sizeof(sWeapon));
// If the client has a deagle
if (StrEqual(sWeapon, "weapon_deagle"))
// Trigger this timer, pass the client's userid to the callback, it's safer
CreateTimer(0.5, ChangeKnife, GetClientUserId(client));
}
}
public Action ChangeKnife(Handle timer, int data)
{
// since we've got the client's userid stored in the "data" var, we somehow have to get the actual client from that userid
int client = GetClientOfUserId(data);
if (IsClientInGame(client))
// set the client's weapon to a grenade, because counting starts at 0, for knife; simply change 3 with 2
Client_SetActiveWeapon(client, GetPlayerWeaponSlot(client, 3));
}