note Help Needed
This wiki is the result of an ongoing community effort — thank you all for helping!
If you want to provide changes to this page then please click here.
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.
Name | Description |
---|---|
playerid | The ID of the player that request custom model download. |
DOWNLOAD_REQUEST:type | The type of the request. |
crc | The 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;
}
Related Callbacks
The following callbacks might be useful, as they're related to this callback in one way or another.
- OnPlayerFinishedDownloading: This callback is called when a player finishes downloading custom models.