SA-MP Forums Archive
[Include] (sQt) Anti Quick-Turn - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] (sQt) Anti Quick-Turn (/showthread.php?tid=650564)



(sQt) Anti Quick-Turn - StrikerZ - 02.03.2018

Anti Quick-Turn


Код:
The include has been tested for any bugs and so far it's working perfectly.

If you find any bug, report it here.
Introduction:
This include is meant to detect player's using quick-turn hack. It has been made sure that the passenger won't be detected as cheater, so don't worry about that.

Mechanism:
When players use quick-turn, the difference between car's old angle and new angle is 90 degree.

Usage:
One callback is provided for this include to give users the full control of this include.

Код:
Only one function:

- OnPlayerQuickTurn(playerid, turntype)

Turntypes
1 - As a driver
2 - As a passenger
I RECOMMEND NOT TO USE KICK/BAN AS THIS INCLUDE IS IN INITIAL RELEASE.

Changelog:
Код:
V1.1
- Added types in the callback.
- Added a check if player uses quick turn while being as a passenger. (Type #2)
Download:
GitHub
Pastebin
Attachment


Re: (sQt) Anti Quick-Turn - RogueDrifter - 02.03.2018

Very simple and effective, well done!

EDIT: I have an idea to detect passengers safely gonna submit a pull request on github,

I recommend everyone to use this, its pretty safe and actually works.

You just gotta hook the real results (as in setvehiclepos/zangle).


Re: (sQt) Anti Quick-Turn - Pottus - 03.03.2018

Why not do it like this?

Код:
#if defined sQt_Included
    #endinput
#endif

#define sQt_Included

#include <a_samp>

#define         MIN_ROT_VARIANCE        89.0
#define         MAX_ROT_VARIANCE        91.0

/*=================================================
*   Forwarding Hooks
===================================================*/
#if defined sQt_OnPlayerUpdate
forward sQt_OnPlayerUpdate(playerid);
#endif

#if defined sQt_OnPlayerStateChange
forward sQt_OnPlayerStateChange(playerid, newstate, oldstate);
#endif

#if defined OnPlayerQuickTurn
forward OnPlayerQuickTurn(playerid, infractions);
#endif

/*=================================================
*   Variable For Old Angle
===================================================*/
static Float:sQt_OldAngle[MAX_PLAYERS];
static sQt_Infractions[MAX_PLAYERS];

/*=================================================
*   Callbacks
===================================================*/
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new Float:z_rot;
        new vehicleid = GetPlayerVehicleID(playerid);
        GetVehicleZAngle(vehicleid, sQt_OldAngle[playerid]);
    }
    #if defined sQt_OnPlayerStateChange
        return sQt_OnPlayerStateChange(playerid, newstate, oldstate);
    #else
        return 1;
    #endif
}

public OnPlayerUpdate(playerid)
{
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        new Float:z_rot;
        new vid = GetPlayerVehicleID(playerid);
        GetVehicleZAngle(vid, z_rot);

        if((sQt_OldAngle[playerid] - z_rot) <= MIN_ROT_VARIANCE || (sQt_OldAngle[playerid] - z_rot) >= MAX_ROT_VARIANCE)
        {
            sQt_Infractions[playerid]++;
            #if defined OnPlayerQuickTurn
            OnPlayerQuickTurn(playerid, sQt_Infractions[playerid]);
            #endif
        }
        sQt_OldAngle[playerid] = z_rot;
    }
    #if defined sQt_OnPlayerUpdate
        return sQt_OnPlayerUpdate(playerid);
    #else
        return 1;
    #endif
}

public OnPlayerDisconnect(playerid)
{
    sQt_Infractions[playerid] = 0;
    #if defined sQt_OnPlayerDisconnect
        return sQt_OnPlayerDisconnect(playerid);
    #else
        return 1;
    #endif

}


/*=================================================
*   Hooked Functions
===================================================*/
#if defined _ALS_OnPlayerStateChange
  #undef OnPlayerStateChange
#else
    #define _ALSOnPlayerStateChange
#endif

#define OnPlayerStateChange sQt_OnPlayerStateChange

#if defined _ALS_OnPlayerUpdate
  #undef OnPlayerUpdate
#else
    #define _ALS_OnPlayerUpdate
#endif

#define OnPlayerUpdate sQt_OnPlayerUpdate

#if defined _ALS_OnPlayerDisconnect
  #undef OnPlayerDisconnect
#else
    #define _ALS_OnPlayerDisconnect
#endif

#define OnPlayerDisconnect sQt_OnPlayerDisconnect



Re: (sQt) Anti Quick-Turn - StrikerZ - 03.03.2018

Quote:
Originally Posted by Pottus
Посмотреть сообщение
Why not do it like this?

Код:
#if defined sQt_Included
    #endinput
#endif

#define sQt_Included

#include <a_samp>

#define         MIN_ROT_VARIANCE        89.0
#define         MAX_ROT_VARIANCE        91.0

/*=================================================
*   Forwarding Hooks
===================================================*/
#if defined sQt_OnPlayerUpdate
forward sQt_OnPlayerUpdate(playerid);
#endif

#if defined sQt_OnPlayerStateChange
forward sQt_OnPlayerStateChange(playerid, newstate, oldstate);
#endif

#if defined OnPlayerQuickTurn
forward OnPlayerQuickTurn(playerid, infractions);
#endif

/*=================================================
*   Variable For Old Angle
===================================================*/
static Float:sQt_OldAngle[MAX_PLAYERS];
static sQt_Infractions[MAX_PLAYERS];

/*=================================================
*   Callbacks
===================================================*/
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new Float:z_rot;
        new vehicleid = GetPlayerVehicleID(playerid);
        GetVehicleZAngle(vehicleid, sQt_OldAngle[playerid]);
    }
    #if defined sQt_OnPlayerStateChange
        return sQt_OnPlayerStateChange(playerid, newstate, oldstate);
    #else
        return 1;
    #endif
}

public OnPlayerUpdate(playerid)
{
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        new Float:z_rot;
        new vid = GetPlayerVehicleID(playerid);
        GetVehicleZAngle(vid, z_rot);

        if((sQt_OldAngle[playerid] - z_rot) <= MIN_ROT_VARIANCE || (sQt_OldAngle[playerid] - z_rot) >= MAX_ROT_VARIANCE)
        {
            sQt_Infractions[playerid]++;
            #if defined OnPlayerQuickTurn
            OnPlayerQuickTurn(playerid, sQt_Infractions[playerid]);
            #endif
        }
        sQt_OldAngle[playerid] = z_rot;
    }
    #if defined sQt_OnPlayerUpdate
        return sQt_OnPlayerUpdate(playerid);
    #else
        return 1;
    #endif
}

public OnPlayerDisconnect(playerid)
{
    sQt_Infractions[playerid] = 0;
    #if defined sQt_OnPlayerDisconnect
        return sQt_OnPlayerDisconnect(playerid);
    #else
        return 1;
    #endif

}


/*=================================================
*   Hooked Functions
===================================================*/
#if defined _ALS_OnPlayerStateChange
  #undef OnPlayerStateChange
#else
    #define _ALSOnPlayerStateChange
#endif

#define OnPlayerStateChange sQt_OnPlayerStateChange

#if defined _ALS_OnPlayerUpdate
  #undef OnPlayerUpdate
#else
    #define _ALS_OnPlayerUpdate
#endif

#define OnPlayerUpdate sQt_OnPlayerUpdate

#if defined _ALS_OnPlayerDisconnect
  #undef OnPlayerDisconnect
#else
    #define _ALS_OnPlayerDisconnect
#endif

#define OnPlayerDisconnect sQt_OnPlayerDisconnect
I used the exact number for a reason. I have debugged the cheat and its exact 90 difference and moreover Rogue said that its better to use exact number cuz he said when player turns left angle goes from 0 to 360


Re: (sQt) Anti Quick-Turn - Pottus - 03.03.2018

That is not a reason for anything. You have locked the script into a 1.0 degree range of setting off your detection.

https://sampwiki.blast.hk/wiki/Floatround_method

It makes absolutely no sense to use rounding at all for what you are doing.


Re: (sQt) Anti Quick-Turn - RogueDrifter - 03.03.2018

Quote:
Originally Posted by StrikerZ
Посмотреть сообщение
I used the exact number for a reason. I have debugged the cheat and its exact 90 difference and moreover Rogue said that its better to use exact number cuz he said when player turns left angle goes from 0 to 360
His script will work because he blocked it between 89 and 91 but he missed the negative angle so it will counter the cheat but not always.

I hardly see a difference that would affect much between yours and his.


Re: (sQt) Anti Quick-Turn - Pottus - 03.03.2018

Quote:
Originally Posted by RogueDrifter
Посмотреть сообщение
His script will work because he blocked it between 89 and 91 but he missed the negative angle so it will counter the cheat but not always.

I hardly see a difference that would affect much between yours and his.
Well, why would you ever want to disregard precision? That is such a poor mentality. I equate that statement right away to "it's good enough" for me nothing is ever good enough. Sure I talk shit to you guys! I know it but I talk the same shit to myself constantly.

I will talk some more shit that is..... neither of you guys have proven shit to me beyond you are both probably capable of taking your work to the extreme.

The sooner you guys stop making these petty bullshit releases and go for the gold I won't be fully impressed until that time.


Re: (sQt) Anti Quick-Turn - RogueDrifter - 04.03.2018

Quote:
Originally Posted by Pottus
Посмотреть сообщение
Well, why would you ever want to disregard precision? That is such a poor mentality. I equate that statement right away to "it's good enough" for me nothing is ever good enough. Sure I talk shit to you guys! I know it but I talk the same shit to myself constantly.

I will talk some more shit that is..... neither of you guys have proven shit to me beyond you are both probably capable of taking your work to the extreme.

The sooner you guys stop making these petty bullshit releases and go for the gold I won't be fully impressed until that time.
Whoa, i was giving you an advice, you missed the negative angle! your suggestion won't always work, take time to read. I don't really go around releasing things to impress anyone...
Quote:
Originally Posted by Pottus
petty bullshit releases and go for the gold
Why call someone's hard work petty bullshit? moreover how is this going for the gold? how is this 'gold' in any matter? name one thing anyone gets out of this?

Not the perfect way to show your pov on anything tbh, but hey that's like totally your opinion mate, tho, that's not what i'd call creative criticism at all, you provided an incomplete code (missed the -90 angle) which also has no explanation i don't see how that'll help anyone.

I don't understand how is this not accurate or not precise, you only gave range for the angle 89 to 91 which won't even matter, it's checked for at OPU, the moment a quickturn happens (old-new = 90) it will get detected...

I'll be speaking for myself, all i ever done since i joined here was provide material that i thought would be helpful and i maintained it to provide decent standard projects that were never provided before and held, everything is abandoned, hardly anyone cares but yet here you are picking on the ones who do.


Re: (sQt) Anti Quick-Turn - Pottus - 04.03.2018

I'm just trying to push you guys to do better. That is all and I made a mistake there but an easy fix and I was well aware of that I just didn't address it at all. I don't know why I have to be such a prick


Re: (sQt) Anti Quick-Turn - RogueDrifter - 04.03.2018

Quote:
Originally Posted by Pottus
Посмотреть сообщение
I'm just trying to push you guys to do better. That is all and I made a mistake there but an easy fix and I was well aware of that I just didn't address it at all. I don't know why I have to be such a prick
Ah well lol, i'm improving myself and i'm sure striker will as well, i keep updating as u can see and soon it'll be perfect, thanks for the share.


Re: (sQt) Anti Quick-Turn - StrikerZ - 04.03.2018

Update V1.1
The include has got an extra parameter for the OnPlayerQuickTurn callback. Check the main post for more info. Thanks to Rogue for helping out


Re: (sQt) Anti Quick-Turn - seanny - 08.03.2018

I found a compiler stopping bug in the code. I posted an issue on github along with a fix.

https://github.com/Sunehildeep/OnPla...kTurn/issues/1


Re: (sQt) Anti Quick-Turn - StrikerZ - 08.03.2018

Quote:
Originally Posted by seanny
Посмотреть сообщение
I found a compiler stopping bug in the code. I posted an issue on github along with a fix.

https://github.com/Sunehildeep/OnPla...kTurn/issues/1
Fixed the typo, thanks for that