CAC_OnMemoryRead

Description

This callback is called when a client sends to the server the bytes requested by CAC_ReadMemory.

Definition

forward CAC_OnMemoryRead(player_id, address, size, const content[]);

Parameters

Return values

Example usage

// example requires: zcmd-style command processor
COMMAND:cped(player_id, params[])
{
    CAC_ReadMemory(player_id, 0xB6F5F0, 4);
    return 1;
}

public CAC_OnMemoryRead(player_id, address, size, const content[])
{
    if(address == 0xB6F5F0)
    {
        // pointers are 4 bytes, so we must assure that the client sent back 4 bytes
        if(size == 4)
        {
            new CPed = MakeDWORD(content);
            new buf[32];

            format(buf, sizeof(buf), "CPed: 0x%08x", CPed);
            SendClientMessage(player_id, -1, buf);
        }
    }
    return 1;
}
// pack 4 bytes in a PAWN cell
MakeDWORD(const bytes[])
{
    return (bytes[0]) | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24);
}

Remarks