RedirectDownload

From SA-MP Wiki

Jump to: navigation, search


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


Description:

Redirect a player custom AddCharModel or AddSimpleModel download to a specific HTTP webpage.


Parameters:
(playerid, url[])
playeridThe ID of the player that requested custom models download.
url[]The URL to redirect download


Return Values:

  • 1: The function executed successfully.
  • 0: The function failed to execute.


Example Usage: From dl_redirect filterscript

new baseurl[] = "https://files.sa-mp.com/server";
 
public OnPlayerRequestDownload(playerid, type, crc)
{
	new fullurl[256+1];
	new dlfilename[64+1];
	new foundfilename=0;
 
	if(!IsPlayerConnected(playerid)) return 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,256,"%s/%s",baseurl,dlfilename);
		RedirectDownload(playerid,fullurl);
	}
 
	return 0;
}


Related Functions

The following functions may be useful, as they are related to this function in one way or another.

Template:AddCharModel Template:AddSimpleModel Template:AddSimpleModelTimed

Related Callbacks

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

Template:OnPlayerRequestDownload

Personal tools
Navigation
Toolbox