03.03.2018, 03:03
Quote:
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 |