OnPlayerWeaponShot bug -
Runn3R - 12.10.2016
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.
Re: OnPlayerWeaponShot bug -
SickAttack - 12.10.2016
Looks like your dream is crushed.
Nice find. An alternative would be to detect when a player presses LEFT CLICK.
Re: OnPlayerWeaponShot bug -
Runn3R - 13.10.2016
Yeah, but it wouldn't be effective as OnPlayerWeaponShot.
Re: OnPlayerWeaponShot bug -
Threshold - 15.10.2016
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.
Re: OnPlayerWeaponShot bug -
AndySedeyn - 06.11.2016
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:cPosX, Float:cPosY, Float:cPosZ,
Float:pPosX, Float:pPosY, Float:pPosZ,
Float:cFacAng, Float:pFacAng;
GetPlayerPos(playerid, pPosX, pPosY, pPosZ);
GetPlayerFacingAngle(playerid, pFacAng);
GetPlayerCameraPos(playerid, cPosX, cPosY, cPosZ);
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)!
Re: OnPlayerWeaponShot bug -
SickAttack - 06.11.2016
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:cPosX, Float:cPosY, Float:cPosZ,
Float:pPosX, Float:pPosY, Float:pPosZ,
Float:cFacAng, Float:pFacAng;
GetPlayerPos(playerid, pPosX, pPosY, pPosZ);
GetPlayerFacingAngle(playerid, pFacAng);
GetPlayerCameraPos(playerid, cPosX, cPosY, cPosZ);
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.
Re: OnPlayerWeaponShot bug -
AndySedeyn - 07.11.2016
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)
Re: OnPlayerWeaponShot bug -
SickAttack - 07.11.2016
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.
Re: OnPlayerWeaponShot bug -
AndySedeyn - 07.11.2016
Quote:
Originally Posted by SickAttack
They can also hold the botton down.
|
That can be detected too... Hammering on obvious details isn't helping to "fix" this.
Re: OnPlayerWeaponShot bug -
SickAttack - 07.11.2016
Quote:
Originally Posted by AndySedeyn
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.
Re: OnPlayerWeaponShot bug -
aprender123 - 08.11.2016
Can you help me save admins data I do not know how to do that
Re: OnPlayerWeaponShot bug -
DTV - 10.11.2016
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.