<?xml version="1.0"?>
<rss version="2.0"><channel><title>Includes Latest Topics</title><link>https://forum.sa-mp.cc/index.php?/forum/30-includes/</link><description>Includes Latest Topics</description><language>en</language><item><title><![CDATA[Southclaw's & Pottus's Anti-cheat patches]]></title><link>https://forum.sa-mp.cc/index.php?/topic/21-southclaws-pottuss-anti-cheat-patches/</link><description><![CDATA[<div align="center">
	 
</div>

<div align="center">
	<span style="font-size:26px;"><span style="color:#48d1cc;">Anti-cheat patches</span></span>
</div>

<p>
	<span style="color:#48d1cc;"><span style="font-size:18px;">Objective:</span></span><br />
	Southclaw and I have decided to keep a resource of anti-hack patches which can be easily integrated into your script. Every patch will follow some basic guidelines for implementation, as well as a description of the cheat which the patch prevents. Please keep in mind these are not designed to be an anti-cheat system addressing a complete system is really on an individual basis and often directly needs to be integrated into the gamemode it's self instead this patches are meant to build on your anti-cheat system by providing a means of quick implementation.<br /><br /><span style="color:#48d1cc;"><span style="font-size:18px;">Guidelines:</span></span><br />
	- Patches are to be designed to be included BEFORE YSI<br />
	- Patches will contain ALS hooking only<br />
	- Patches will contain a callback with the following prefix OnAntiCheat ..... () ex OnAntiCheatAutoAim(playerid)<br />
	- Patches will have a description outlining the anticheat<br />
	- Patches can use y_iterate<br /><br /><br /><span style="color:#ff0000;">_________________________________________________________________________________________________________________________________________________<br />
	                     ___________________________________________________________________________________________________________________</span>
</p>

<p style="text-align:center;">
	 
</p>

<p style="text-align:center;">
	<span style="font-size:18px;">Patches</span>
</p>

<p>
	<span style="color:#ff0000;">_________________________________________________________________________________________________________________________________________________<br />
	                    ___________________________________________________________________________________________________________________</span><br /><br />
	Name: Autobullet<br />
	Type: Animation / Weapon exploit<br />
	Description: Modifies the behavior of walking weapons allowing them to be used like running weapons it also skips the reload animations.<br />
	Detection Method: There is a velocity range in which this exploit happens however it is also possible to achieve the same velocity in some circumstances by using the slide-shoot-run bug that is why there is player key checks in place to make sure that does not happen. A player receiving 3 infractions will result in OnAntiCheatAutoBullet() being called.<br />
	Callback: <span style="color:#ff0000;">public OnAntiCheatAutoBullet(playerid, weaponid)</span><br />
	pawn code:
</p>

<pre class="ipsCode">
// Anti autobullet exploit detection by [uL]Pottus
#define             MAX_AUTOBULLET_INFRACTIONS          3
#define             AUTOBULLET_RESET_DELAY              30

static AutoBulletInfractions[MAX_PLAYERS];
static LastInfractionTime[MAX_PLAYERS];

forward OnAntiCheatAutoBullet(playerid, weaponid);

public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    if(!IsPlayerInAnyVehicle(playerid))
    {
        switch(weaponid)
        {
            case 27, 23, 25, 29, 30, 31, 33, 24, 38:
            {
                if(CheckSpeed(playerid))
                {
                    if(gettime() - LastInfractionTime[playerid] &gt;= AUTOBULLET_RESET_DELAY) AutoBulletInfractions[playerid] = 1;
                    else AutoBulletInfractions[playerid]++;
                    LastInfractionTime[playerid] = gettime();

                    if(AutoBulletInfractions[playerid] == MAX_AUTOBULLET_INFRACTIONS)
                    {
                        AutoBulletInfractions[playerid] = 0;
                        CallLocalFunction("OnAntiCheatAutoBullet", "ii", playerid, weaponid);
                        return 0;
                    }
                }
            }
        }
    }
    
    if (funcidx("ACAutoB_OnPlayerWeaponShot") != -1)
    {
        return CallLocalFunction("ACAutoB_OnPlayerWeaponShot", "iiiifff", playerid, weaponid, hittype, hitid, fX, fY, fZ);
    }
    return 1;
}

#if defined _ALS_OnPlayerWeaponShot
    #undef OnPlayerWeaponShot
#else
    #define _ALS_OnPlayerWeaponShot
#endif
#define OnPlayerWeaponShot ACAutoB_OnPlayerWeaponShot

forward ACAutoB_OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);

public OnPlayerDisconnect(playerid, reason)
{
    AutoBulletInfractions[playerid] = 0;

    if (funcidx("ACAutoB_OnPlayerDisconnect") != -1)
    {
        return CallLocalFunction("ACAutoB_OnPlayerDisconnect", "ii", playerid, reason);
    }
    return 1;
}

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

forward ACAutoB_OnPlayerDisconnect(playerid, reason);


static CheckSpeed(playerid)
{
    new Keys,ud,lr;
    GetPlayerKeys(playerid,Keys,ud,lr);

    if(ud == KEY_UP &amp;&amp; lr != KEY_LEFT &amp;&amp; lr != KEY_RIGHT)
    {
        new Float:Velocity[3];
        GetPlayerVelocity(playerid, Velocity[0], Velocity[1], Velocity[2]);
        Velocity[0] = floatsqroot( (Velocity[0]*Velocity[0])+(Velocity[1]*Velocity[1])+(Velocity[2]*Velocity[2]));
        if(Velocity[0] &gt;= 0.11 &amp;&amp; Velocity[0] &lt;= 0.13) return 1;
    }
    return 0;
}</pre>

<p>
	 
</p>

<p>
	<strong>Name: Connection spoofing<br />
	Type: Server exploit<br />
	Description: It was possible in 0.3x to spoof a connection to a server when a player is already connected, this will result in the players name being changed to the spoofed name unprotected servers could potentially have player accounts overwritten. It is currently unknown if this exploit exists in 0.3z however it assumed that it still could potentially happen in any case this patch provides protection by preventing OnPlayerConnect() from being called to the rest of the script. IMPORTANT Make sure this is placed before any other includes that use OnPlayerConnect!!!!<br />
	Detection Method: When a player connects a variable is set that they are connected, if another connection happens on the same ID while they are still connected this is considered a spoof.<br />
	Callback: <span style="color:#ff0000;">public OnAntiCheatPlayerSpoof(playerid)</span><br /><span style="font-size:16px;">Edit - I have confirmed this as still possible.</span></strong><br />
	 
</p>

<p>
	pawn code:<br />
	 
</p>

<pre class="ipsCode">
// Anti connection spoofing patch by [uL]Pottus

forward OnAntiCheatPlayerSpoof(playerid);

static bool:PlayerConnected[MAX_PLAYERS];
static PlayerNames[MAX_PLAYERS][MAX_PLAYER_NAME];

public OnPlayerConnect(playerid)
{
    // User was already connected cheat detected
    if(PlayerConnected[playerid])
    {
        SetPlayerName(playerid, PlayerNames[playerid]);
        CallLocalFunction("OnAntiCheatPlayerSpoof", "i", playerid);
        return 1;
    }
    else
    {
        GetPlayerName(playerid, PlayerNames[playerid], MAX_PLAYER_NAME);
        PlayerConnected[playerid] = true;
    }

    if (funcidx("AntiSpoof_OnPlayerConnect") != -1)
    {
        return CallLocalFunction("AntiSpoof_OnPlayerConnect", "i", playerid);
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    PlayerConnected[playerid] = false;

    if (funcidx("AntiSpoof_OnPlayerDisconnect") != -1)
    {
        return CallLocalFunction("AntiSpoof_OnPlayerDisconnect", "ii", playerid, reason);
    }
    return 1;
}


#if defined _ALS_OnPlayerConnect
    #undef OnPlayerConnect
#else
    #define _ALS_OnPlayerConnect
#endif
#define OnPlayerConnect AntiSpoof_OnPlayerConnect

forward AntiSpoof_OnPlayerConnect(playerid);

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

forward AntiSpoof_OnPlayerDisconnect(playerid, reason);
</pre>

<p>
	 
</p>

<p>
	<strong>Name: NPC Connection spoofing<br />
	Type: Server exploit<br />
	Description: This is very similar to connection spoofing and was an issue in 0.3x it is assumed that it is still possible in the new SAMP version. It will result in faked NPC connections to the server. IMPORTANT Make sure this is placed before any other includes that use OnPlayerConnect!!!!<br />
	Detection Method: All real NPC connections can only occur on IP: 127.0.0.1 if the IP is different then it is a spoofed NPC connection<br />
	Callback: <span style="color:#ff0000;">public OnAntiCheatNPCSpoof(playerid)</span></strong><br /><br />
	pawn code:<br />
	 
</p>

<pre class="ipsCode">
// Anti NPC spoof by [uL]Pottus

forward OnAntiCheatNPCSpoof(playerid);

public OnPlayerConnect(playerid)
{
    if(IsPlayerNPC(playerid))
    {
        new ip[16];
        GetPlayerIp(playerid, ip, sizeof(ip));
        if (!!strcmp(ip, "127.0.0.1"))
        {
            new name[MAX_PLAYER_NAME];
            format(name, sizeof(name), "%i", gettime());
            SetPlayerName(playerid, name);
            CallLocalFunction("OnAntiCheatNPCSpoof", "i", playerid);
            return 1;
        }
    }
    if (funcidx("AntiNPC_OnPlayerConnect") != -1)
    {
        return CallLocalFunction("AntiNPC_OnPlayerConnect", "i", playerid);
    }
    return 1;
}

#if defined _ALS_OnPlayerConnect
    #undef OnPlayerConnect
#else
    #define _ALS_OnPlayerConnect
#endif
#define OnPlayerConnect AntiNPC_OnPlayerConnect

forward AntiNPC_OnPlayerConnect(playerid);
</pre>

<p>
	 
</p>

<p>
	<strong>Name: Lag Troll<br />
	Type: Vehicle Cheat<br />
	Description: This cheat appears to send fake packets to the server in rapid succession by copying the position of the targeted vehicle the result is a lag type effect.<br />
	Callback: <span style="color:#ff0000;">public OnAntiCheatLagTroll(playerid)</span></strong><br />
	 
</p>

<p>
	pawn code:
</p>

<pre class="ipsCode">
#define         MAX_VEHICLE_ID_CHANGES          5

static LastVehicleID[MAX_PLAYERS];
static VehicleIDChanges[MAX_PLAYERS];
static VehicleIDChangeTime[MAX_PLAYERS];

forward OnAntiCheatLagTroll(playerid);

public OnPlayerUpdate(playerid)
{
    new vid = GetPlayerVehicleID(playerid);
    if(vid &gt; 0)
    {
        if(vid != LastVehicleID[playerid])
        {
            if(GetTickCount() - VehicleIDChangeTime[playerid] &lt; 5000)
            {
                VehicleIDChanges[playerid]++;
                if(VehicleIDChanges[playerid] &gt; MAX_VEHICLE_ID_CHANGES)
                {
                    CallLocalFunction("OnAntiCheatLagTroll", "i", playerid);
                    return 0;
                }
            }
            else VehicleIDChanges[playerid] = 1;
        }
        LastVehicleID[playerid] = vid;
        VehicleIDChangeTime[playerid] = GetTickCount();
    }

    if (funcidx("AntiLT_OnPlayerUpdate") != -1)
    {
        return CallLocalFunction("AntiLT_OnPlayerUpdate", "i", playerid);
    }
    return 1;
}

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

forward AntiLT_OnPlayerUpdate(playerid);
</pre>

<p>
	 
</p>]]></description><guid isPermaLink="false">21</guid><pubDate>Sun, 27 Sep 2020 08:18:28 +0000</pubDate></item><item><title>gBug - Prevent 'the G bug' - prevents players teleporting into passenger seat</title><link>https://forum.sa-mp.cc/index.php?/topic/19-gbug-prevent-the-g-bug-prevents-players-teleporting-into-passenger-seat/</link><description><![CDATA[<div style="color:#000000;font-size:13.3333px;">
	There is a bug in SA:MP where if you press G to enter a vehicle as a passenger and the driver drives away, you run after them and after 3 seconds you get teleported in regardless of how far away the vehicle is. This include fixes that.<br /><br /><a href="https://www.youtube.com/watch?v=N-Gt4n8Yx9k" rel="external nofollow">https://www.youtube.com/watch?v=N-Gt4n8Yx9k</a><br />
	Tested hundreds of times, seems flawless.<br /><br /><b>Download:</b><br /><a href="https://pastebin.com/KxU52Y1k" rel="external nofollow">https://pastebin.com/KxU52Y1k</a><br />
	You will need the y_hooks include which is part of YSI.<br /><br />
	All you need to do is include it in your gamemode. Nothing else is required.<br /><br />
	Let me know if you find any problems with it!<br /><br />
	Thanks.
</div>]]></description><guid isPermaLink="false">19</guid><pubDate>Sun, 27 Sep 2020 08:09:02 +0000</pubDate></item></channel></rss>
