View difference between Paste ID: uvdnw8Jq and 1MaDsEGE
SHOW: | | - or go back to the newest paste.
1
#define FILTERSCRIPT
2
3
#include <open.mp>
4
#include <zcmd>
5
#include <sscanf2>
6
#include <pawn.RakNet>
7
8
// -
9
#define VERS "2.2"
10
11
#define C_GREEN 0x20DD6AFF
12
#define C_ERROR 0xA01616FF
13
14
#define MOBILE_CLIENT "ED40ED0E8089CC44C08EE9580F4C8C44EE8EE990"
15
16
#define KEY_PRESSED(%0) \
17
	(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
18
19
// -
20
new Text:acTD;
21
// -
22
new bool:pSuspicious[MAX_PLAYERS];
23
new bool:mobilePlayer[MAX_PLAYERS];
24
new bool:pAlreadyChecked[MAX_PLAYERS];
25
new bool:pCheck[MAX_PLAYERS];
26
// -
27
new pCheat[MAX_PLAYERS];
28
new pCheckTimer[MAX_PLAYERS][2];
29
new pCheckSum[MAX_PLAYERS];
30
// -
31
new rMemAddr[10];
32
33
enum PR_JoinData
34
{
35
	PR_iVersion,
36
 	PR_byteMod,
37
  	PR_byteNicknameLen,
38
   	PR_NickName[24],
39
    PR_uiClientChallengeResponse,
40
    PR_byteAuthKeyLen,
41
    PR_auth_key[50],
42
    PR_iClientVerLen,
43
    PR_ClientVersion[30]
44
};
45
46
// -
47
forward autoSobCheck(playerid);
48
forward kickPlayer(playerid);
49
forward putPIW(pID);
50
forward pCheckPlayer(pID);
51
forward respawnAfterDeath(playerid);
52
// -
53
54
new opcodes[10] = {
55
    0x06865E,
56
    0xA88774,
57
    0xDB6746,
58
    0xFDB957,
59
    0x52D558,
60
    0xE4FC58,
61
    0x1BA246,
62
    0xB0C56F,
63
    0xF9855E,
64
    0xF51D54  
65
};
66
67
// -- Commands --
68
69
CMD:checkp(playerid, params[])
70
{
71
	new pID, string[52];
72
73
	// -
74
	if ( !IsPlayerAdmin(playerid) ) return SendClientMessage(playerid, C_GREEN, "[Server]: You must be an Administrator to use this command!");
75
    if ( sscanf(params, "i", pID) ) return SendClientMessage(playerid, C_GREEN, "[Server]: /checkp [ID]");
76
    if ( pAlreadyChecked[pID] == true ) return SendClientMessage(playerid, C_ERROR, "[ERROR]: You've already checked this Player!");
77
    if ( !IsPlayerConnected(pID) ) return format(string, 52, "The player with the given ID: (%d) is not online!", pID), SendClientMessage(playerid, C_GREEN, string);
78
79
    SendClientMessage(playerid, C_GREEN, "[System]: A player check request has been sent!");
80
81
	// -
82
    pCheck[pID] = true;
83
    // -
84
    TextDrawShowForPlayer(pID, acTD);
85
    PlayerPlaySound(pID, 1185, 1985.1318, -141.6173, -6.6582);
86
	// --
87
	SetPlayerInterior(pID, 20);
88
	SetPlayerVirtualWorld(pID, pID+random(20));
89
	SetPlayerHealth(pID, 100.0);
90
    SetPlayerPosFindZ(pID, 1985.1318, -141.6173, -6.6582);
91
	// -
92
	pCheckTimer[pID][0] = SetTimerEx("putPIW", 900, true, "d", pID);
93
	pCheckTimer[pID][1] = SetTimerEx("pCheckPlayer", 78000, false, "d", pID);
94
	// -
95
	SendClientMessage(pID, C_ERROR, "[System]: You are under checking, please wait about 1,5 min");
96
	// -
97
	return 1;
98
}
99
100
// -- Callbacks --
101
102
public OnFilterScriptInit()
103
{
104
	print("--------------------------------------------------");
105
	print("\t");
106
	print("\t");
107
	print("	 AntyCheat "VERS" by Pevenaider loaded			 ");
108
	print("\t");
109
	print("\t");
110
	print("--------------------------------------------------");
111
	
112
	// -- TextDraw --
113
	acTD = TextDrawCreate(-101.000000, -41.000000, "LD_RCE4:race18");
114
	TextDrawBackgroundColour(acTD, 255);
115
	TextDrawFont(acTD, TEXT_DRAW_FONT:4);
116
	TextDrawLetterSize(acTD, 0.500000, 1.000000);
117
	TextDrawColour(acTD, 255);
118
	TextDrawSetOutline(acTD, 0);
119
	TextDrawSetProportional(acTD, true);
120
	TextDrawSetShadow(acTD, 1);
121
	TextDrawSetSelectable(acTD, false);
122
	return 1;
123
}
124
125
public OnPlayerConnect(playerid)
126
{
127
    new version[24], pAuth[43];
128
    
129
	// --
130
	mobilePlayer[playerid] = false;
131
    pSuspicious[playerid] = false;
132
	pAlreadyChecked[playerid] = false;
133
    pCheat[playerid] = -1;
134
    
135
	// -- Client version | GPCI --
136
    GetPlayerVersion(playerid, version, sizeof(version));
137
    GPCI(playerid, pAuth, sizeof(pAuth));
138
139
    if ( !strcmp ( MOBILE_CLIENT, pAuth, true ) )
140
	{
141
	    new pIP[16+1];
142
	    
143
	    GetPlayerIp(playerid, pIP, sizeof(pIP));
144
145
    	if (pCheckSum[playerid] == 0xBEEF)
146
		{
147
		    mobilePlayer[playerid] = true;
148
	    } else {
149
			SendClientMessage(playerid, C_ERROR, "[ERROR] There was a problem with the mobile version authentication, Your IP is temporarily blocked!");
150
			BlockIpAddress(pIP, 60 * 3000);
151
	    }
152
	}
153
	
154
	if ( strcmp ( version, "0.3.7" ) == 0 && mobilePlayer[playerid] == false )
155
	{
156
		SendClientMessage(playerid, C_ERROR, "[ERROR] The server requires a client version newer than 0.3.7 R1!");
157
		SetTimerEx("kickPlayer", 2000, false, "d", playerid);
158
	}
159
160
	if ( pCheck[playerid] == true )
161
	{
162
	    TextDrawHideForPlayer(playerid, acTD);
163
		KillTimer(pCheckTimer[playerid][0]);
164
		KillTimer(pCheckTimer[playerid][1]);
165
	    pCheck[playerid] = false;
166
	}
167
168
    // -
169
    SendClientCheck(playerid, 0x47, 0, 0, 0x4);
170
    SendClientCheck(playerid, 0x48, 0, 0, 0x4);
171
    // -
172
	
173
	for (new i = 0; i < 10; i++) rMemAddr[i] = anotherForm(opcodes[i]), SendClientCheck(playerid, 0x5, rMemAddr[i], 0x0, 0x4);
174
175
	// -- Check RPC --
176
    CallLocalFunction("Sec_OnClientCheckResponse", "iiii", playerid, 0x47, 0xCECECE, 256);
177
    CallLocalFunction("Sec_OnClientCheckResponse", "iiii", playerid, 0x48, 0xDEDEDE, 256);
178
	// -
179
	
180
	pCheckSum[playerid] = -1;
181
    SetTimerEx("autoSobCheck", 2900, false, "i", playerid);
182
    return 1;
183
}
184
185
public OnPlayerDisconnect(playerid, reason)
186
{
187
	if ( pCheck[playerid] == true )
188
	{
189
	    TextDrawHideForPlayer(playerid, acTD);
190
		KillTimer(pCheckTimer[playerid][0]);
191
		KillTimer(pCheckTimer[playerid][1]);
192
	    pCheck[playerid] = false;
193
	}
194
	return 1;
195
}
196
197
public OnPlayerDeath(playerid, killerid, WEAPON:reason)
198
{
199
	if( pCheck[playerid] == true )
200
	{
201
	  	pAlreadyChecked[playerid] = true;
202
	   	pCheck[playerid] = false;
203
	   	// -
204
	    KillTimer(pCheckTimer[playerid][0]);
205
	    KillTimer(pCheckTimer[playerid][1]);
206
	    // -
207
	    SetTimerEx("respawnAfterDeath", 5000, false, "d", playerid);
208
	}
209
	return 1;
210
}
211
212
public OnPlayerCommandReceived(playerid, cmdtext[])
213
{
214
	if(pCheck[playerid] == true)
215
	{
216
		SendClientMessage(playerid, -1, "[ERROR]: You can not use commands right now!");
217
		return 0;
218
	}
219
	return 1;
220
}
221
222
public OnPlayerKeyStateChange(playerid, KEY:newkeys, KEY:oldkeys)
223
{
224
	if(KEY_PRESSED(KEY_ACTION) && pCheck[playerid] == true) Kick(playerid);
225
	return 1;
226
}
227
228
public Sec_OnClientCheckResponse(playerid, actionid, memaddr, retndata)
229
{
230
	switch(actionid)
231
	{
232
	    case 0x47:
233
	    {
234
	        if ( mobilePlayer[playerid] == false && memaddr == 0x0 && retndata != 256 )
235
	        {
236
	            pSuspicious[playerid] = false;
237
	        }
238
	        if ( mobilePlayer[playerid] == false && memaddr == 0xCECECE && retndata == 256 )
239
	        {
240
	            pSuspicious[playerid] = true;
241
	            // -
242
    			SendClientCheck(playerid, 0x47, 0, 0, 0x4);
243
	        }
244
	    }
245
	    case 0x48:
246
	    {
247
	        if ( mobilePlayer[playerid] == false && memaddr != 0xDEDEDE && retndata == 0 )
248
	        {
249
	            pSuspicious[playerid] = false;
250
	        }
251
	        if ( mobilePlayer[playerid] == false && memaddr == 0xDEDEDE && retndata == 256 )
252
	        {
253
	            pSuspicious[playerid] = true;
254
	            // -
255
    			SendClientCheck(playerid, 0x48, 0, 0, 0x4);
256
	        }
257
	    }
258
	    case 0x5:
259
	    {
260
		    if ( memaddr == rMemAddr[0] && retndata != 192) pCheat[playerid] = 1; // S0beit
261
		    if ( memaddr == rMemAddr[1] && retndata != 72) pCheat[playerid] = 2; // - CLEO
262
		    if ( memaddr == rMemAddr[2] && retndata != 192) pCheat[playerid] = 3;
263
		    if ( memaddr == rMemAddr[3] && retndata != 68) pCheat[playerid] = 4;
264
		    if ( memaddr == rMemAddr[4] && retndata != 196) pCheat[playerid] = 5;
265
		    if ( memaddr == rMemAddr[5] && retndata != 64) pCheat[playerid] = 6; // - CLEO
266
		    if ( memaddr == rMemAddr[6] && retndata != 8 ) pCheat[playerid] = 7; // CLEO5+Ultimate ASI Loader
267
			if ( memaddr == rMemAddr[7] && retndata != 200 ) pCheat[playerid] = 8; // SilentPatch
268
			if ( memaddr == rMemAddr[8] && retndata != 200 ) pCheat[playerid] = 9; // SampFuncs.asi
269
			if ( memaddr == rMemAddr[9] && retndata != 128 ) pCheat[playerid] = 10; // Sobfox.asi
270
		}
271
	}
272
	return 0;
273
}
274
275
public OnClientCheckResponse(playerid, actionid, memaddr, retndata)
276
{
277
    #if defined Sec_OnClientCheckResponse
278
    	Sec_OnClientCheckResponse(playerid, actionid, memaddr, retndata);
279
    #endif
280
    return 1;
281
}
282
#if defined _ALS_OnClientCheckResponse
283
    #undef OnClientCheckResponse
284
#else
285
    #define _ALS_OnClientCheckResponse
286
#endif
287
#define OnClientCheckResponse Sec_OnClientCheckResponse
288
#if defined Sec_OnClientCheckResponse
289
    forward Sec_OnClientCheckResponse(playerid, actionid, memaddr, retndata);
290
#endif
291
292
public autoSobCheck(playerid)
293
{
294
	if ( mobilePlayer[playerid] == true )
295
	{
296
	    SendClientMessage(playerid, C_GREEN, "You’re currently playing the mobile version of SA-MP.");
297
	}
298
	// --
299
	if ( pSuspicious[playerid] == true )
300
	{
301
	    SendClientMessage(playerid, C_ERROR, "[ERROR] System has detected that you are probably using some mods. If you think this is a mistake, please contact the Admin.");
302
		SetTimerEx("kickPlayer", 2500, false, "d", playerid);
303
	}
304
	if ( pCheat[playerid] > 0 )
305
 	{
306
		for(new i = 0; i < 7; i++) SendClientMessage(playerid, -1, " ");
307
  		SendClientMessage(playerid, C_GREEN, "--------------------------------------------");
308
    }
309
	// --
310
	switch ( pCheat[playerid] )
311
	{
312
	    case 1:SendClientMessage(playerid, C_ERROR, "[ERROR] System has detected that you are using S0beit mod. Remove it and return to the server!"), SetTimerEx("kickPlayer", 2500, false, "d", playerid);
313
		case 2..6:SendClientMessage(playerid, C_ERROR, "[ERROR] System has detected that you are using CLEO mod. Remove it and return to the server!"), SetTimerEx("kickPlayer", 2500, false, "d", playerid);
314
		case 7:SendClientMessage(playerid, C_ERROR, "[ERROR] System has detected that you are using CLEO5+Ultimate ASI Loader mod. Remove it and return to the server!"), SetTimerEx("kickPlayer", 2500, false, "d", playerid);
315
		case 8:SendClientMessage(playerid, C_ERROR, "[ERROR] System has detected that you are using SilentPatch. Remove it and return to the server!"), SetTimerEx("kickPlayer", 2500, false, "d", playerid);
316
		case 9:SendClientMessage(playerid, C_ERROR, "[ERROR] System has detected that you are using SampFuncs. Remove it and return to the server!"), SetTimerEx("kickPlayer", 2500, false, "d", playerid);
317
		case 10:SendClientMessage(playerid, C_ERROR, "[ERROR] System has detected that you are using S0beit mod. Remove it and return to the server!"), SetTimerEx("kickPlayer", 2500, false, "d", playerid);
318
	}
319
	return 1;
320
}
321
322
forward OnIncomingRPC(playerid, rpcid, BitStream:bs);
323
public OnIncomingRPC(playerid, rpcid, BitStream:bs)
324
{
325
	switch ( rpcid )
326
	{
327
	    case 25:
328
	    {
329
        	new JoinData[PR_JoinData];
330
        	
331
        	BS_ReadJoinServer(bs, JoinData);
332
			BS_ReadUint16(bs, pCheckSum[playerid]);
333
		}
334
	}
335
	return 1;
336
}
337
338
/*
339
	Oxygen Checker
340
*/
341
342
public putPIW(pID)
343
{
344
	if ( pCheck[pID] == true )
345
	{
346
		if ( !IsPlayerInRangeOfPoint(pID, 100.0, 1985.1318, -141.6173, -6.6582) ) pUseSob(pID);
347
348
		new Float:health;
349
		GetPlayerHealth(pID, health);
350
		
351
		if ( health < 100.0 ) // Clean player
352
		{
353
	 		KillTimer(pCheckTimer[pID][0]);
354
	   		KillTimer(pCheckTimer[pID][1]);
355
		    //
356
		    SetPlayerInterior(pID, 0);
357
		    SetPlayerVirtualWorld(pID, 0);
358
		    TextDrawHideForPlayer(pID, acTD);
359
		 	PlayerPlaySound(pID, 1186, 0.0, 0.0, 0.0);
360
	   		//
361
	 		pCheck[pID] = false;
362
	 		pAlreadyChecked[pID] = true;
363
	 		SpawnPlayer(pID);
364
		}
365
		SetPlayerPosFindZ(pID, 1985.1318, -141.6173+random(4), -6.6582);
366
		SetPlayerFacingAngle(pID, 1+random(5));
367
	}
368
	return 1;
369
}
370
371
public pCheckPlayer(pID)
372
{
373
	new Float:health;
374
	GetPlayerHealth(pID, health);
375
	
376
	if ( health >= 100.0 )
377
	{
378
		pUseSob(pID);
379
     	pCheck[pID] = false;
380
    }
381
    return 1;
382
}
383
384
public respawnAfterDeath(playerid)
385
{
386
	SetPlayerInterior(playerid, 0);
387
 	SetPlayerVirtualWorld(playerid, 0);
388
	SpawnPlayer(playerid);
389
	// -
390
	TextDrawHideForPlayer(playerid, acTD);
391
	// -
392
 	PlayerPlaySound(playerid, 1186, 0.0, 0.0, 0.0);
393
    return 1;
394
}
395
// -----
396
397
public kickPlayer(playerid) Kick(playerid);
398
399
// -
400
stock pUseSob(playerid)
401
{
402
	KillTimer(pCheckTimer[playerid][0]);
403
	KillTimer(pCheckTimer[playerid][1]);
404
    pCheck[playerid] = false;
405
    
406
	SendClientMessage(playerid, C_ERROR, "[ERROR] System has detected that you are using S0beit mod. Remove it and return to the server!"), SetTimerEx("kickPlayer", 2000, false, "d", playerid);
407
	return 1;
408
}
409
410
stock anotherForm(input)
411
{
412
    new result;
413
414
    #emit LOAD.S.pri input
415
    #emit CONST.alt 0xFF
416
    #emit AND
417
    #emit CONST.alt 16
418
    #emit SHL
419
    #emit STOR.S.pri result
420
421
    #emit LOAD.S.pri input
422
    #emit CONST.alt 0xFF00
423
    #emit AND
424
    #emit LOAD.S.alt result
425
    #emit ADD
426
    #emit STOR.S.pri result
427
428
    #emit LOAD.S.pri input
429
    #emit CONST.alt 0xFF0000
430
    #emit AND
431
    #emit CONST.alt 16
432
    #emit SHR
433
    #emit LOAD.S.alt result
434
    #emit ADD
435
    #emit STOR.S.pri result
436
437
    return result;
438
}
439
440
stock BS_ReadJoinServer(BitStream:bs, data[PR_JoinData])
441
{
442
    BS_ReadValue( bs, PR_INT32, data[PR_iVersion], PR_UINT8, data[PR_byteMod], PR_UINT8, data[PR_byteNicknameLen], PR_STRING, data[PR_NickName], data[PR_byteNicknameLen],
443
    	PR_UINT32, data[PR_uiClientChallengeResponse],
444
     	PR_UINT8, data[PR_byteAuthKeyLen],
445
      	PR_STRING, data[PR_auth_key], data[PR_byteAuthKeyLen],
446
       	PR_UINT8, data[PR_iClientVerLen]
447
	);
448
	
449
	BS_ReadValue( bs, PR_STRING, data[PR_ClientVersion], (data[PR_iClientVerLen] >= 30 ? 30:data[PR_iClientVerLen]) );
450
}