跳到主要內容

OnPlayerRequestDownload

注意

此回呼函式於 SA-MP 0.3.DL R1 版本中新增,在更早的版本中無法使用!

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.