Skip to content
Nexius edited this page Oct 14, 2024 · 11 revisions

Variant 1: ignoring bad packet

#if !defined IsNaN
    #define IsNaN(%0) ((%0) != (%0))
#endif

const AIM_SYNC = 203;

IPacket:AIM_SYNC(playerid, BitStream:bs)
{
    new aimData[PR_AimSync];

    BS_IgnoreBits(bs, 8); // ignore packetid (byte)
    BS_ReadAimSync(bs, aimData);

    if (IsNaN(aimData[PR_aimZ])) {
        return 0; // ignore bad packet
    }

    return 1;
}

Variant 2: rewrite and continue packet processing

#if !defined IsNaN
    #define IsNaN(%0) ((%0) != (%0))
#endif

const AIM_SYNC = 203;

IPacket:AIM_SYNC(playerid, BitStream:bs)
{
    new aimData[PR_AimSync];

    BS_IgnoreBits(bs, 8); // ignore packetid (byte)
    BS_ReadAimSync(bs, aimData);

    if (IsNaN(aimData[PR_aimZ])) {
        aimData[PR_aimZ] = 0.0;

        BS_SetWriteOffset(bs, 8);
        BS_WriteAimSync(bs, aimData); // rewrite
    }

    return 1;
}