CAC_ReadMemory

Description

Reads data from GTA:SA address space.
Response is given in callback CAC_OnMemoryRead.

Definition

native CAC_ReadMemory(player_id, address, size);

Parameters

Return values

Example usage

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        // read 1 byte from 0x8CB7A5 representing the radio station player is currently listening to.
        CAC_ReadMemory(playerid, 0x8CB7A5, 1);
    }
    return 1;
}

public CAC_OnMemoryRead(player_id, address, size, const content[])
{
    if(address == 0x8CB7A5 && size == 1)
    {
        // "content" is an array with "size" elements, each cell containing 1 byte.
        // We read only 1 byte, so the station id is at index 0.
        if(content[0] == 0x07) // Radio X
        {
            SendClientMessage(player_id, -1, "Radio X is indeed the best station.");
        }
        else
        {
            SendClientMessage(player_id, -1, "What the hell are you listening to ?!");
        }
    }
    return 1;
}

Remarks