[Include] OPRF.inc - OnPlayerRapidFire [0.3z]
#1

OPRF - OnPlayerRapidFire
Recently, I saw an include by [uL]Pottus in limiting the weapon shots (in case of quicker shots or even for rapid fires). It inspired me to create a pretty simple include which detects rapid fires when it's being done.

Rapid Fire

Rapid Fire is a cleo cheat which does shots rapidly and can be harmful for servers on 0.3z with lagcompmode 'On' which concentrates on DM/TDM. It can even kill player in less than a second in case of weapons which are in categories like assault rifles, desert eagle, or shotgun.

If you still don't have any idea about Rapid Fire, please check out the video at the end of the topic.

Change Log
Код:
23-02-2014
 - Initial Release.
 - Fixed some issues with arrays.
 - Fixed the problem for sub-machine guns like Tec9 (ID:32) and uzi (ID:28)
 
24-02-2014 (v2 Released)
 - Added support for Sniper Rifle and Country Rifle.
 (Thanks to 'West X' for reporting about it)

26-8-2014

 - Improved the way of detection.
 - Added : GetPlayerLastShotTick which returns the last shot tick of the player.
 
    Usage : GetPlayerLastShotTick(playerid);
Hooked Callbacks

Following are the hooked callbacks on the version 3 of this include.

pawn Код:
OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);
OnPlayerConnect(playerid);
OnGameModeInit(); //Even if it's used for filterscript, this callback gets called.
Usage
OnPlayerRapidFire is called when a player does rapid shots, it provides the playerid, weaponid and interval of the rapid shots. Returning 0 on this callback won't allow the rest data under OnPlayerWeaponShot to go on and also would cancel that shot sync.
pawn Код:
forward OnPlayerRapidFire(playerid, weaponid, intervals);
/*
    playerid - the player who shoots rapid fires.
    weaponid - the weapon which did rapid shots.
    intervals - the difference between last shot time and the current one.
    Return : 0 will stop sending the shot data sync to others, 1 will send the shot data sync to others.*/
Examples

pawn Код:
#include <a_samp>
#include <OPRF>

public OnPlayerRapidFire(playerid, weaponid, intervals)
{
    Kick(playerid); //Kicks the player for rapid firing.
    return 0; //Returning 0 so that the damage doesn't occur and also the rest codes under OnPlayerWeaponShot won't get called.
}
Downloads

GitHub - Includes source and complete examples
NOTE : If you're facing any false detections on assault rifles or submachine guns, consider using this snippet : http://forum.sa-mp.com/showpost.php?...6&postcount=27

Use the one called "OPRF.inc". If you've found anything wrong with "OPRF.inc", get to "oldfiles" directory and use "OPRF2.inc".

NOTE: I'm suggesting not to use things relating like sending/receiving data under the 'OnPlayerRapidFire' callback. Even if using, create an array or use the 'intervals' argument to get it flawless or else there would be lag occurring.

• If you got any suggestions for the improvement of the include, feel free to post it here.
• Download "OPRF.inc" version which is the latest one, v3.
• If this include detects someone whose innocent at first, I suggest you to create warning counts to ensure that things are alright.
This often happens only with assault rifles when it's shot on long distances. So a warning system would be good to cease that out or simply "return 0" on the callback when rapid fire is being called on assault rifles (ID 30 and 31).
Quote:
Originally Posted by BlueSky_
Посмотреть сообщение
There's a small issue with the detection, mainly due to FPS differences. I tested this on different FPS and came to see that M4 gets detected if we're shooting at LONG distances with better FPS rates. That would be what RCON1 reported too. I hope this gets fixed soon.
Media
[ame]http://www.youtube.com/watch?v=-ENba8dmIFU[/ame]

Regards,
Lordzy.
Reply
#2

Nice
Reply
#3

Quote:
Originally Posted by TonyII
Посмотреть сообщение
Nice
Thanks, a video has been uploaded in showing rapid shots and an example of avoiding it. (Example code has also been attached with the topic and GitHub)
Reply
#4

That's pretty useful. Nice job!
Reply
#5

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
That's pretty useful. Nice job!
Thanks!
A major bug has been found with the include which was it affects globally to everyone. I forgot to get it as an array and now, it's fixed. In case if anyone has downloaded the old one, I request them to download the newest one.
Reply
#6

Lordz and his stuffz. Could come in handy to some servers.
Reply
#7

Often this bug

Код:
 
»Player [IMM] Msk. (2) was trapped by the system for RapidFire (weapon: 31, interval: 0 ms) at 1m 30s
next
Код:
 
[11:10:20] »Player [IMM] Msk. (2) was trapped by the system for RapidFire (weapon: 32, interval: 11 ms) at 1m 30s
next
Код:
 
[11:11:21] »[Jail] You have been trapped by the system, reason: RapidFire (weapon: 32, interval: 22 ms) 

[11:11:21] »Player mrdrifter (0) was trapped by the system for RapidFire (weapon: 32, interval: 22 ms) at 1m 30s
I would recommend to use
Код:
 
stock RapidWeaponBlock(w)
{
	case 28..32, 38: return 1;
	return 0`;
}
and
Код:
if(!RapidWeaponBlock(GetPlayerWeapon(playerid)){
code...
}
Reply
#8

Quote:
Originally Posted by Scaleta
Посмотреть сообщение
Lordz and his stuffz. Could come in handy to some servers. :)
Thanks!

Quote:
Originally Posted by RCON1
Посмотреть сообщение
Often this bug

Код:
 
»Player [IMM] Msk. (2) was trapped by the system for RapidFire (weapon: 31, interval: 0 ms) at 1m 30s
next
Код:
 
[11:10:20] »Player [IMM] Msk. (2) was trapped by the system for RapidFire (weapon: 32, interval: 11 ms) at 1m 30s
next
Код:
 
[11:11:21] »[Jail] You have been trapped by the system, reason: RapidFire (weapon: 32, interval: 22 ms) 

[11:11:21] »Player mrdrifter (0) was trapped by the system for RapidFire (weapon: 32, interval: 22 ms) at 1m 30s
I would recommend to use
Код:
 
stock RapidWeaponBlock(w)
{
	case 28..32, 38: return 1;
	return 0`;
}
and
Код:
if(!RapidWeaponBlock(GetPlayerWeapon(playerid)){
code...
}
Thank you for your report, this has also been experienced by me earlier however I thought that it was a problem in my usage. As Rapid Fire won't get effected on sub-machine guns like Tec9(ID:32) or Uzi (ID:28), it has been disabled from getting called. But I'm not sure about your M4 issue, it hasn't been experienced by me or anyone else. Please make sure about it once more. I'll be looking forward for further updates of rapid-fire cheats so I could test them out and update the include.

I request to those who have downloaded this to re-download once again.
Reply
#9


Really Niice :O
Reply
#10

Thanks man ! It is really useful

+REP
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)