OnPlayerWeaponShot bug
#1

So i was working on the weapon ammo hack anticheat when i suddenly discover this shit..







smetaka = Serverside Ammo

cmetaka = Clientside Ammo

mind the +1 bcs i decrease it after the message.
Reply
#2

Looks like your dream is crushed.





































Nice find. An alternative would be to detect when a player presses LEFT CLICK.
Reply
#3

Yeah, but it wouldn't be effective as OnPlayerWeaponShot.
Reply
#4

In terms of the anticheat, if the client ammo is lower than expected, update the serverside ammo to that amount and you should have no issues.

But nice find.
Reply
#5

This has been bugging me too. I've crafted this function to detect when a player is looking backward with their camera:

PHP код:
stock IsAimingBehind(playerid) {
    static
        
Float:cPosXFloat:cPosYFloat:cPosZ,
        
Float:pPosXFloat:pPosYFloat:pPosZ,
        
Float:cFacAngFloat:pFacAng;
    
GetPlayerPos(playeridpPosXpPosYpPosZ);
    
GetPlayerFacingAngle(playeridpFacAng);
    
GetPlayerCameraPos(playeridcPosXcPosYcPosZ);
    
cFacAng 90 + (atan2((cPosY pPosY), (cPosX pPosX)));
    static
        
Float:cOppFacAng = ((pFacAng 180) ? (pFacAng 180) : (pFacAng 180));
    return ((
cFacAng 90) < cOppFacAng < (cFacAng 90)) || ((cFacAng 90) < cOppFacAng < (cFacAng 90));

The name of the function is a bit ambiguous. It doesn't check if the player is aiming, but that's something that you can easily change.

This function does the following:
  • Calculates the facing angle of the player's camera (Not the player's character)
  • Inverses the calculated vector relative to the facing angle of the player (the character)
  • Checks if that falls within the 180° behind the player
You can use this in a looping timer to keep checking it when the player is holding KEY_HANDBRAKE / KEY_AIM (if KEY_AIM is defined in your script).

This function still needs some tweaking and improvement, but it works and can be used for now. A current improvement that I can think of is the use of GetPlayerCameraFrontVector (?). Also while testing this, I noticed that the aim angle is larger than 90° on each side, so this can be improved too.

(?): At least I think GetPlayerCameraFrontVector replaces the calculations that I've done and if so, probably does them more efficiently.

I would appreciate if someone with more insight into this stuff could and wants to help me improve this function (and also explain the process, as I'm interested in learning too)!
Reply
#6

Quote:
Originally Posted by AndySedeyn
Посмотреть сообщение
This has been bugging me too. Now, to clarify, I'm not the best in mathematics, but I've crafted this function to detect when a player is looking backward with their camera:

PHP код:
stock IsAimingBehind(playerid) {
    static
        
Float:cPosXFloat:cPosYFloat:cPosZ,
        
Float:pPosXFloat:pPosYFloat:pPosZ,
        
Float:cFacAngFloat:pFacAng;
    
GetPlayerPos(playeridpPosXpPosYpPosZ);
    
GetPlayerFacingAngle(playeridpFacAng);
    
GetPlayerCameraPos(playeridcPosXcPosYcPosZ);
    
cFacAng 90 + (atan2((cPosY pPosY), (cPosX pPosX)));
    static
        
Float:cOppFacAng = ((pFacAng 180) ? (pFacAng 180) : (pFacAng 180));
    return ((
cFacAng 90) < cOppFacAng < (cFacAng 90)) || ((cFacAng 90) < cOppFacAng < (cFacAng 90));

The name of the function is a bit ambiguous. It doesn't check if the player is aiming, but that's something that you can easily change.

This function does the following:
  • Calculates the facing angle of the player's camera (Not the player's character)
  • Inverses the calculated vector relative to the facing angle of the player (the character)
  • Checks if that falls within the 180° behind the player
You can use this in a looping timer to keep checking it when the player is holding KEY_HANDBRAKE / KEY_AIM (if KEY_AIM is defined in your script).

This function still needs some tweaking and improvement, but it works and can be used for now. A current improvement that I can think of is the use of GetPlayerCameraFrontVector (?). Also while testing this, I noticed that the aim angle is larger than 90° on each side, so this can be improved too.

(?): At least I think GetPlayerCameraFrontVector replaces the calculations that I've done and if so, probably does them more efficiently.

I would appreciate if someone with more insight into this stuff could and wants to help me improve this function (and also explain the process, as I'm interested in learning too)!
That's not going to solve all of your problems. If you face a wall (not aiming behind) and shoot with a Tec9 for example, it won't detect it, nor is OnPlayerWeaponShotCalled.
Reply
#7

I guess the wall can be detected with ColAndreas. Set a point to somewhere in front of the player and see if there's an object between it:

Function from AbyssMorgan's 3DTryg:
PHP код:
Tryg3DProt:: bool:IsBetweenPlayerToPointIsWall(playerid,Float:x,Float:y,Float:z) {
    new 
Float:xA,Float:yA,Float:zA,Float:xC,Float:yC,Float:zC;
    
GetPlayerPos(playerid,xA,yA,zA);
    
CA_RayCastLine(xA,yA,zA,x,y,z,xC,yC,zC);
    if(
xC == 0.0 || yC == 0.0 || zC == 0.0) return false;
    return 
true;

@Crayder, any better ideas? (I linked this post on his VMs)
Reply
#8

It's still not going to work like that... They can be close to a wall and still shoot normal.

Detect the animation, one must be applied.
Reply
#9

Quote:
Originally Posted by SickAttack
View Post
They can also hold the botton down.
That can be detected too... Hammering on obvious details isn't helping to "fix" this.
Reply
#10

Quote:
Originally Posted by AndySedeyn
View Post
That can be detected too... Hammering on obvious details isn't helping to "fix" this.
Then get to work. If you can detect the animation, then all of this ColAndreas, math stuff isn't needed.

By they can also hold it down. I'm referring to ammo hack going through. They just stand by a wall, shoot the hell out of others, and then they can keep their ammo to 1 value lower or so.

Time based calculations won't be as accurate, but you can get a number to base off (with an if-then) and prevent that with GetPlayerAmmo.

---------------------

Edit: You don't even need to detect the animation, it can be done by just using OnPlayerKeyStateChange.
Reply
#11

Can you help me save admins data I do not know how to do that
Reply
#12

Quote:
Originally Posted by aprender123
Посмотреть сообщение
Can you help me save admins data I do not know how to do that


Ask for help in the Scripting Help section.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)