· 6 years ago · Apr 02, 2019, 04:32 PM
1#include <sourcemod>
2#include <sdktools>
3#include <multicolors>
4#include <emitsoundany>
5#include <colors>
6#include <clientprefs>
7#include <smlib>
8
9ConVar g_cvKillFeed;
10new kackisi[MAXPLAYERS+1];
11new kackisihs[MAXPLAYERS+1];
12new Handle:db;
13public Plugin:myinfo =
14{
15 name = "Noscope detector",
16 author = "DeadSwim",
17 description = "detector noscope",
18 version = "1.1",
19 url = "www.madgames.eu"
20}
21
22
23public OnPluginStart ()
24{
25 HookEvent("player_death", Event_PlayerDeath_Pre, EventHookMode_Pre);
26 HookEvent("player_death", Event_PlayerDeath);
27 RegConsoleCmd("sm_check", check);
28 g_cvKillFeed = CreateConVar("sm_kf_disable", "0", "1 - Kill feed will be disabled, 0 - enabled", _, true, 0.0, true, 1.0);
29
30 AutoExecConfig(true, "fortnitekillfeed");
31
32 InitDB(db);
33}
34InitDB(&Handle:DbHNDL)
35{
36
37 // Errormessage Buffer
38 new String:Error[255];
39
40 // COnnect to the DB
41 DbHNDL = SQL_Connect("sourcebans", true, Error, sizeof(Error));
42
43
44 // If something fails we quit
45 if(DbHNDL == INVALID_HANDLE)
46 {
47 SetFailState(Error);
48 }
49
50 // Querystring
51 new String:Query[255];
52 Format(Query, sizeof(Query), "CREATE TABLE IF NOT EXISTS tVip (steamid TEXT UNIQUE, name TEXT);");
53
54 // Database lock
55 SQL_LockDatabase(DbHNDL);
56
57 // Execute the query
58 SQL_FastQuery(DbHNDL, Query);
59
60 // Database unlock
61 SQL_UnlockDatabase(DbHNDL);
62
63}
64public bool:OnClientConnect(client)
65{
66 return true;
67}
68public Action:check(client, args)
69{
70 new ck = kackisi[client];
71
72 PrintToChat(client, "Vaše noscope: %d", ck);
73}
74
75
76public void Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
77{
78 int victim = GetClientOfUserId(event.GetInt("userid"));
79 int attacker = GetClientOfUserId(event.GetInt("attacker"));
80
81 char sWeapon[512];
82 event.GetString("weapon", sWeapon, sizeof(sWeapon));
83 new zoombilgi = GetEntProp(attacker, Prop_Send, "m_bIsScoped")
84 for (int i = 1; i <= MaxClients; i++)
85 {
86 if(IsValidClient(i))
87 {
88 if(i == attacker)
89 {
90 if(IsWeaponScope(sWeapon))
91 {
92 if (!zoombilgi)
93 {
94
95 float distance;
96
97 distance = Entity_GetDistance(attacker, victim);
98 distance = Math_UnitsToMeters(distance);
99
100 kackisi[attacker]++;
101 new ck = kackisi[attacker];
102
103 PrintToChatAll(" \x01[\x04MadGames\x01] \x04HrÃ¡Ä \x01%N \x04 noscopnul hráÄe \x01%N\x04 na vzdálenost \x01%01.0fm\x04!", attacker, victim, distance);
104
105 decl String:szSteamId2[MAX_STEAMAUTH_LENGTH];
106 GetClientAuthId(attacker, AuthId_Steam2, szSteamId2, sizeof(szSteamId2));
107 new String:Query[255];
108 Format(Query, sizeof(Query), "INSERT INTO noscope (steamId, delka) VALUES ('%s', '%01.0')", szSteamId2, distance);
109
110 SQL_TQuery(db, SQL_ErrorCheckCallBack, Query);
111 }
112 }
113 }
114 }
115 }
116}
117public Action Event_PlayerDeath_Pre(Event event, const char[] name, bool dontBroadcast)
118{
119 if(g_cvKillFeed.BoolValue)
120 {
121 event.BroadcastDisabled = true;
122 }
123
124 return Plugin_Continue;
125}
126
127stock bool IsWeaponScope(const char[] sWeapon)
128{
129 if( StrEqual(sWeapon, "awp") ||
130 StrEqual(sWeapon, "g3sg1") ||
131 StrEqual(sWeapon, "scar20") ||
132 StrEqual(sWeapon, "ssg08"))
133 {
134 return true;
135 }
136 return false;
137}
138stock bool IsValidClient(int client)
139{
140 if(client >= 1 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client))
141 {
142 return true;
143 }
144 return false;
145}
146
147public SQL_ErrorCheckCallBack(Handle:owner, Handle:hndl, const String:error[], any:data)
148{
149 // This is just an errorcallback for function who normally don't return any data
150 if(hndl == INVALID_HANDLE)
151 {
152 SetFailState("Query failed! %s", error);
153 }
154}