إنتقل إلى المحتوى الرئيسي

OnPlayerRequestDownload

warning

This callback was added in SA-MP 0.3.DL R1 and will not work in earlier versions!

Description​

This callback is called when a player request for custom model downloads.

NameDescription
playeridThe ID of the player that request custom model download.
DOWNLOAD_REQUEST:typeThe type of the request.
crcThe CRC checksum of custom model file.

Returns​

0 - Deny the download request

1 - Accept the download request

Examples​

#define DOWNLOAD_REQUEST_EMPTY (DOWNLOAD_REQUEST:0)
#define DOWNLOAD_REQUEST_MODEL_FILE (DOWNLOAD_REQUEST:1)
#define DOWNLOAD_REQUEST_TEXTURE_FILE (DOWNLOAD_REQUEST:2)

new baseUrl[] = "https://assets.open.mp";

public OnPlayerRequestDownload(playerid, DOWNLOAD_REQUEST:type, crc)
{
if (!IsPlayerConnected(playerid))
{
return 0;
}

new fullUrl[256 + 1];
new dlFileName[64 + 1];
new foundFileName = 0;

if (type == DOWNLOAD_REQUEST_TEXTURE_FILE)
{
foundFileName = FindTextureFileNameFromCRC(crc, dlFileName, 64);
}
else if (type == DOWNLOAD_REQUEST_MODEL_FILE)
{
foundFileName = FindModelFileNameFromCRC(crc, dlFileName, 64);
}

if (foundFileName)
{
format(fullUrl, sizeof(fullUrl), "%s/%s", baseUrl, dlFileName);
RedirectDownload(playerid, fullUrl);
}

return 0;
}

The following callbacks might be useful, as they're related to this callback in one way or another.

The following functions might be useful, as they're related to this callback in one way or another.