[BR][G]host Premium Member
Posts : 127 Points : 159 Reputation : 1 Join date : 2013-01-09 In-game username : GhostRider
| Subject: Anti_aim(Don't know is it right section) Sat Jan 12, 2013 5:17 pm | |
| If this isn't good section remove it This script detects when a player is using autoaim and not joypad. pretty simple, made it as an example; maybe someone here can improve my idea. so here's how its done. GetPlayerTargetPlayer always returns 65535 (INVALID_PLAYER_ID) for players that are using autoaim (and joypad doesn't really matter - this will detect if you shoot your gun and are using AUTOAIM.) I don't know if this was intended or not by SA-MP devs. anyway, when you understand that GetPlayerTargetPlayer always returns 65535 I think its easy from there. don't know really where to post this. I posted my old joypad detection method in the tutorial section but people just cried. move it were-ever if i messed up. the accuracy is pretty damn good if i do say so myself - but i'm posting this so you guys can look at it and maybe improve it, or use it if you want to. script: 1./* 2. Autoaim detection script - NOT joypad. 3. 4. - By Whitetiger 5. 6. - Credits: Lorenc_, TheGamer!, [U]214 7. */ 8. 9.#include 10. 11.#define DEBUG 0 12. 13.new bool:autoaim[MAX_PLAYERS] = {false, ...}; 14.new checkautoaim[MAX_PLAYERS] = {9999, ...}; 15.new pressingaimtick[MAX_PLAYERS] = {-1, ...}; 16.new bool:keyfire[MAX_PLAYERS] = {false, ...}; 17.new bool:ispressingaimkey[MAX_PLAYERS] = {false, ...}; 18.new bool:CheckNextAim[MAX_PLAYERS] = {false, ...}; 19. 20.public OnFilterScriptInit() { 21. for(new i=0; i < MAX_PLAYERS; ++i) { 22. if(IsPlayerConnected(i)) { 23. OnPlayerConnect(i); 24. } 25. } 26. return 1; 27.} 28. 29.public OnPlayerConnect(playerid) { 30. checkautoaim[playerid] = 9999; 31. pressingaimtick[playerid] = -1; 32. autoaim[playerid] = false; 33. keyfire[playerid] = false; 34. ispressingaimkey[playerid] = false; 35. CheckNextAim[playerid] = false; 36. 37. return 1; 38.} 39. 40.public OnPlayerUpdate(playerid) { 41. new var = GetPlayerTargetPlayer(playerid); 42. if(var != INVALID_PLAYER_ID) { 43. CheckNextAim[playerid] = true; 44. } 45. #if DEBUG == 1 46. new str[129]; 47. format(str, sizeof(str), "%d", GetPlayerTargetPlayer(playerid)); 48. SendClientMessage(playerid, -1, str); 49. #endif 50. if(checkautoaim[playerid] <= 10) { 51. if(var != INVALID_PLAYER_ID) { 52. checkautoaim[playerid] = 9999; 53. } 54. checkautoaim[playerid]++; 55. if(checkautoaim[playerid] == 11) { 56. 57. #if DEBUG == 1 58. new pname[MAX_PLAYER_NAME]; 59. GetPlayerName(playerid, pname, sizeof(pname)); 60. format(str, sizeof(str), "*** AUTOAIM WARNING - %s ***", pname); 61. SendClientMessageToAll(-1, str); 62. #endif 63. autoaim[playerid] = true; 64. 65. CallRemoteFunction("OnPlayerDetectedAutoaim", "d", playerid); 66. } 67. } 68. return 1; 69.} 70. 71. 72. 73.public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid) { 74. 75. new Float:X, Float:Y, Float:Z; 76. GetPlayerPos(damagedid, X, Y, Z); 77. new str[128]; 78. format(str, sizeof(str), "%d == false %d < %d && %d != -1 && %d == 53 && %d == %d && %d == 1 && %d && %d == false", CheckNextAim[playerid], pressingaimtick[playerid], GetTickCount(), pressingaimtick[playerid], GetPlayerCameraMode(playerid), GetPlayerTargetPlayer(playerid), INVALID_PLAYER_ID, IsPlayerInRangeOfPoint(playerid, 50, X, Y, Z), notallowed(weaponid), keyfire[playerid]); 79. #if DEBUG == 1 80. SendClientMessage(playerid, -1, str); 81. #endif 82. printf(" Autoaim Detection information: %s", str); 83. if(CheckNextAim[playerid] == false && pressingaimtick[playerid] < GetTickCount() && pressingaimtick[playerid] != -1 && GetPlayerCameraMode(playerid) == 53 && GetPlayerTargetPlayer(playerid) == INVALID_PLAYER_ID && IsPlayerInRangeOfPoint(playerid, 50, X, Y, Z) == 1 && notallowed(weaponid) && keyfire[playerid] == false && !IsPlayerInAnyVehicle(damagedid)) { 84. checkautoaim[playerid] = 0; 85. } 86.} 87. 88.public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) 89.{ 90. if(!(oldkeys & KEY_FIRE) && (newkeys & KEY_FIRE) && !(newkeys & KEY_HANDBRAKE)) { 91. keyfire[playerid] = true; 92. } else if(!(newkeys & KEY_FIRE)) keyfire[playerid] = false; 93. if(!ispressingaimkey[playerid]) CheckNextAim[playerid] = false; 94. ispressingaimkey[playerid] = !!(newkeys & KEY_HANDBRAKE); 95. if(ispressingaimkey[playerid] && !(oldkeys & KEY_HANDBRAKE)) { 96. pressingaimtick[playerid] = GetTickCount()+500; 97. } 98. return 1; 99.} 100. 101. 102.stock notallowed(weaponid) { 103. switch(weaponid) { 104. 105. case 25..27, 16..18, 34..37, 39..40, 43..200: return 0; 106. // Blocks shotguns, sniper rifle, RPG, heat seaker satchel charges etc - besides shotguns these are unaffected by autoaim 107. // the reason shotguns are removed from checking is because i've found them to be unreliable. 108. default:return 1; 109. } 110. return 1; 111.} 112. 113. 114.stock IsPlayerUsingAutoaim(playerid) return autoaim[playerid];
EDIT:the indention on pastebin is messed up. it should be okay when you paste it in PAWNO.It seems it can be done.
Last edited by [BR][G]host on Sat Jan 12, 2013 5:19 pm; edited 1 time in total (Reason for editing : the indention on pastebin is messed up. it should be okay when you paste it in PAWNO.) | |
|
[BR][G]host Premium Member
Posts : 127 Points : 159 Reputation : 1 Join date : 2013-01-09 In-game username : GhostRider
| Subject: Re: Anti_aim(Don't know is it right section) Sat Jan 12, 2013 5:20 pm | |
| EDIT:pawn Code: new bool:autoaim[MAX_PLAYERS] = {false, ...};new checkautoaim[MAX_PLAYERS] = {9999, ...};new LastTargeted[MAX_PLAYERS] = {-1, ...};new pressingaimtick[MAX_PLAYERS] = {-1, ...};new bool:keyfire[MAX_PLAYERS] = {false, ...};new bool:ispressingaimkey[MAX_PLAYERS] = {false, ...};new bool:CheckNextAim[MAX_PLAYERS] = {false, ...}; | |
|
[BR][G]host Premium Member
Posts : 127 Points : 159 Reputation : 1 Join date : 2013-01-09 In-game username : GhostRider
| Subject: Re: Anti_aim(Don't know is it right section) Wed Jan 16, 2013 4:08 pm | |
| | |
|
[BR][G]host Premium Member
Posts : 127 Points : 159 Reputation : 1 Join date : 2013-01-09 In-game username : GhostRider
| Subject: Re: Anti_aim(Don't know is it right section) Thu Jan 17, 2013 3:31 pm | |
| | |
|
[BR][G]host Premium Member
Posts : 127 Points : 159 Reputation : 1 Join date : 2013-01-09 In-game username : GhostRider
| Subject: Re: Anti_aim(Don't know is it right section) Sat Jan 19, 2013 12:49 pm | |
| | |
|
[BR]Joker Head Administrator
Posts : 1236 Points : 1322 Reputation : 36 Join date : 2012-07-13 Age : 24 In-game username : [BR]Joker[nL]
| Subject: Re: Anti_aim(Don't know is it right section) Sat Jan 19, 2013 1:09 pm | |
| | |
|
Ougnou Member
Posts : 6 Points : 10 Reputation : 3 Join date : 2013-01-16
| Subject: Re: Anti_aim(Don't know is it right section) Tue Jan 22, 2013 4:58 pm | |
| | |
|
[BR][G]host Premium Member
Posts : 127 Points : 159 Reputation : 1 Join date : 2013-01-09 In-game username : GhostRider
| Subject: Re: Anti_aim(Don't know is it right section) Tue Jan 22, 2013 6:41 pm | |
| | |
|
Sponsored content
| Subject: Re: Anti_aim(Don't know is it right section) | |
| |
|