[Include] (sQt) Anti Quick-Turn
#3

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
Reply


Messages In This Thread
(sQt) Anti Quick-Turn - by StrikerZ - 02.03.2018, 14:15
Re: (sQt) Anti Quick-Turn - by RogueDrifter - 02.03.2018, 14:40
Re: (sQt) Anti Quick-Turn - by Pottus - 03.03.2018, 00:27
Re: (sQt) Anti Quick-Turn - by StrikerZ - 03.03.2018, 03:03
Re: (sQt) Anti Quick-Turn - by Pottus - 03.03.2018, 03:17
Re: (sQt) Anti Quick-Turn - by RogueDrifter - 03.03.2018, 08:21
Re: (sQt) Anti Quick-Turn - by Pottus - 03.03.2018, 21:08
Re: (sQt) Anti Quick-Turn - by RogueDrifter - 04.03.2018, 01:14
Re: (sQt) Anti Quick-Turn - by Pottus - 04.03.2018, 02:25
Re: (sQt) Anti Quick-Turn - by RogueDrifter - 04.03.2018, 02:40
Re: (sQt) Anti Quick-Turn - by StrikerZ - 04.03.2018, 06:36
Re: (sQt) Anti Quick-Turn - by seanny - 08.03.2018, 12:26
Re: (sQt) Anti Quick-Turn - by StrikerZ - 08.03.2018, 13:56

Forum Jump:


Users browsing this thread: 2 Guest(s)