evgen1137 icon

SendClientCheck usage

evgen1137 | PRO | 01/13/16 05:02:29 PM UTC | 1 ⭐ | 3033 👁️ | Never ⏰ | []
Pawn |

3.2 KB

|

None

|

1 👍

/

0 👎

// SendClientCheck example script by evgen1137
// thanks to MTA devs for structs
#include <a_samp>
 
native SendClientCheck(playerid, type, arg, offset, size);
forward OnClientCheckResponse(playerid, type, arg, response);
 
#define GetBit(%0,%1) ((%0 >> %1) & 1)
 
enum Flags
{
    b0x01,
    bApplyGravity,
    bDisableFriction,
    bCollidable,
    b0x10,
    bDisableMovement,
    b0x40,
    b0x80,
 
    bSubmergedInWater,
    bOnSolidSurface,
    bBroken,
    b0x800,
    b0x1000,
    b0x2000,
    b0x4000,
    b0x8000,
 
    b0x10000,
    b0x20000,
    bBulletProof,
    bFireProof,
    bCollisionProof,
    bMeeleProof,
    bInvulnerable,
    bExplosionProof,
 
    b0x1000000,
    bAttachedToEntity,
    b0x4000000,
    bTouchingWater,
    bEnableCollision,
    bDestroyed,
    b0x40000000,
    b0x80000000
};
 
new PhysFlags[MAX_PLAYERS][Flags];
new Timer;
 
public OnFilterScriptInit()
{
    Timer = SetTimer("TimerFunc", 1000, true);
}
 
public OnFilterScriptExit()
{
    KillTimer(Timer);
}
 
public OnPlayerConnect(playerid)
{
    for(new i = 0; i < 32; i++)
    {
        PhysFlags[playerid][Flags:i] = 0;
    }
    SendClientCheck(playerid, 0x48, 0, 0, 2);
    SendClientCheck(playerid, 0x46, 1598, 0, 28); // 1598 - beachball
    SendClientCheck(playerid, 0x47, 1598, 0, 48); // 1598 - beachball
    return 1;
}
 
public OnClientCheckResponse(playerid, type, arg, response)
{
    new str[128];
    switch(type)
    {
        case 0x2:
        {
            // CPhysicalSAInterface
            // https://github.com/multitheftauto/mtasa-blue/blob/master/MTA10/game_sa/CPhysicalSA.h#L39-L73
            for(new i = 0; i < 32; i++)
            {
                PhysFlags[playerid][Flags:i] = GetBit(arg, i);
            }
            format(str, sizeof(str), "bSubmergedInWater: %d, bOnSolidSurface: %d", PhysFlags[playerid][bSubmergedInWater], PhysFlags[playerid][bOnSolidSurface]);
            SendClientMessage(playerid, -1, str);
        }
        case 0x46:
        {
            // CBaseModelInfoSAInterface
            // https://github.com/multitheftauto/mtasa-blue/blob/master/MTA10/game_sa/CModelInfoSA.h#L138-L181
            format(str, sizeof(str), "Model %d has checksum 0x%x", arg, response);
            SendClientMessage(playerid, -1, str);
        }
        case 0x47: 
        {
            // CColModelSAInterface
            // https://github.com/multitheftauto/mtasa-blue/blob/master/MTA10/game_sa/CColModelSA.h#L87-L91
            format(str, sizeof(str), "Col model %d has checksum 0x%x", arg, response);
            SendClientMessage(playerid, -1, str);
        }
        case 0x48:
        {
            format(str, sizeof(str), "Your computer has been running for %s!", Convert(arg / 1000));
            SendClientMessage(playerid, -1, str);
        }
    }
    return 1;
}
 
forward TimerFunc();
public TimerFunc()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        SendClientCheck(i, 0x2, 0, 0, 2);
    }
}
 
Convert(number)
{
    new hours = 0, mins = 0, secs = 0, string[100];
    hours = floatround(number / 3600);
    mins = floatround((number / 60) - (hours * 60));
    secs = floatround(number - ((hours * 3600) + (mins * 60)));
    if(hours > 0)
    {
        format(string, 100, "%d:%02d:%02d", hours, mins, secs);
    }
    else
    {
        format(string, 100, "%d:%02d", mins, secs);
    }
    return string;
}

Comments