SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Reply
 
Thread Tools Display Modes
Old 11/07/2018, 10:56 PM   #1
willttoonn
Gangsta
 
willttoonn's Avatar
 
Join Date: Nov 2011
Location: Brazil
Posts: 709
Reputation: 47
Default 0.3.DL: How to add custom skin, object and use the Redirect()

SA-MP 0.3.DL
How to add custom skin, object and use the Redirect()
It's necessary use SA-MP 0.3.DL
  • How to add custom skins in server-side
    • You must open models folder inside in your sa-mp server.

    • After this, you will add the .dff and .txd skin files over there.

    • After add the skin files inside of the models folder, you must edit the file artconfig.txt. (This file is located in the same folder)

      Use the params AddCharModel(baseid, newid, dffname[], txdname[]); in the artconfig.txt.
      • baseid - This is the skin base, he will copy the anim, voice and basic sounds to apply in your custom skin. Note: You can use only default sa-mp skins (0-311).
      • newid - This is will be the new skin ID between 20000 and 30000. (e.g. 20012).
      • dffname[] - Here you will be put the location of skin file .dff, starting in folder models.
      • txdname[] - Here you will be put the location of skin file .txd, starting in folder models.

      Example:
      Code:
      AddCharModel(280, 25000, "police_asiatic.dff", "police_asiatic.txd");


    • After edit your artconfig.txt go to server.cfg and put this params to active the artwork.
      Code:
      useartwork 1
    • Start up your samp-server.exe and enjoy.
    • All custom skins will be downloaded before you enter in server.

    • The custom skins are downloaded by client-side and will be placed in folder GTA San Andreas User Files\SAMP\cache\server_iport\. The files has different names that are defined by sa-mp script using some criptografy to make that.
  • How to add custom objects in server-side
    • You must open models folder inside in your sa-mp server.

    • After this, you will add the .dff and .txd skin files over there.

    • After add the skin files inside of the models folder, you must edit the file artconfig.txt. (This file is located in the same folder)

      Use the params AddSimpleModel(virtualworld, baseid, newid, dffname[], txdname[]); in the artconfig.txt.
      • virtualworld - This is the virtual world wherein the object to be visible. If you put value -1 the object will be visible in all virtual worlds.
      • baseid - This is the native objejct, he will copy the colission and anothers params. Note: If you use some object without colission you new object wont have colission.
      • newid - This is will be the new skin ID between -1000 and -30000. (e.g. -24121).
      • dffname[] - Here you will be put the location of custom object file .dff, starting in folder models.
      • txdname[] - Here you will be put the location of custom object file .txd, starting in folder models.

      Example:
      Code:
      AddSimpleModel(-1, 18865, -1000, "AxomCamPOLICE1.dff", "AxomCamPOLICE1.txd");


    • After edit your artconfig.txt go to server.cfg and put this params to active the artwork.
      Code:
      useartwork 1
    • Start up your samp-server.exe and enjoy.
    • All custom objects will be downloaded before you enter in server.

    • The custom skins are downloaded by client-side and will be placed in folder GTA San Andreas User Files\SAMP\cache\server_iport\. The files has different names that are defined by sa-mp script using some criptografy to make that.
  • How to use Redirect()
    • All files placed in your Redirect will must be same to files in samp-server folder models/.
    • Open your gamemode.
    • Put the native OnPlayerRequestDownload(playerid, type, crc) in your script, I suggest on top of the native OnGameModeInit.
      Code:
      			public OnPlayerRequestDownload(playerid, type, crc)
      			{
      			
      				return 1;
      			}
    • Create a new global variable without size, on top of the OnPlayerRequestDownload with name SERVER_DOWNLOAD.
      Code:
      			new SERVER_DOWNLOAD[];
      			public OnPlayerRequestDownload(playerid, type, crc)
      			{
      			
      				return 1;
      			}
    • Put the URL with place of your models in your website. For example, I will use the website http://www.dev-wil.com/downloads/038/models.
      Code:
      			new SERVER_DOWNLOAD[] = "http://www.dev-wil.com/downloads/038/models";
      			public OnPlayerRequestDownload(playerid, type, crc)
      			{
      			
      				return 1;
      			}
    • Now, create the parameters of your OnPlayerRequestDownload so that it replaces the download with sa-mp server by the one of your site. Enter a condition to check if the player is connected. Create conditions with the DOWNLOAD_REQUEST_TEXTURE_FILE and DOWNLOAD_REQUEST_MODEL_FILE types to define the function that will fetch the .txd or the .dff file, respectively.
      Code:
      			new SERVER_DOWNLOAD[] = "http://www.dev-wil.com/downloads/038/models";
      			public OnPlayerRequestDownload(playerid, type, crc)
      			{
      				if(!IsPlayerConnected(playerid))
      					return 0;
      				
      				if(type == DOWNLOAD_REQUEST_TEXTURE_FILE)
      					{}
      				else if(type == DOWNLOAD_REQUEST_MODEL_FILE)
      					{}
      				return 1;
      			}
    • Add the functions FindTextureFileNameFromCRC(crc, retstr[], retstr_size) and FindModelFileNameFromCRC(crc, retstr[], retstr_size) to the sa-mp server write the txd and dff files names to be a find inside of the website.
      Code:
      			new SERVER_DOWNLOAD[] = "http://www.dev-wil.com/downloads/038/models";
      			public OnPlayerRequestDownload(playerid, type, crc)
      			{
      				if(!IsPlayerConnected(playerid))
      					return 0;
      				
      				if(type == DOWNLOAD_REQUEST_TEXTURE_FILE)
      					FindTextureFileNameFromCRC(crc, retstr[], retstr_size);
      				else if(type == DOWNLOAD_REQUEST_MODEL_FILE)
      					FindModelFileNameFromCRC(crc, retstr[], retstr_size);
      				return 1;
      			}
    • Create a local variable to be replace a retstr and alter the retstr_size to sizeof(new_local_var)
      Code:
      			new SERVER_DOWNLOAD[] = "http://www.dev-wil.com/downloads/038/models";
      			public OnPlayerRequestDownload(playerid, type, crc)
      			{
      				if(!IsPlayerConnected(playerid))
      					return 0;
      					
      				new filename[64];
      				
      				if(type == DOWNLOAD_REQUEST_TEXTURE_FILE)
      					FindTextureFileNameFromCRC(crc, filename, sizeof(filename));
      				else if(type == DOWNLOAD_REQUEST_MODEL_FILE)
      					FindModelFileNameFromCRC(crc, filename, sizeof(filename));
      					
      				return 1;
      			}
    • The functions FindTextureFileNameFromCRC e FindModelFileNameFromCRC will be return 1 if find the file or 0 if case is not. Add local variable to be a storage this value and go to next step.
      Code:
      			new SERVER_DOWNLOAD[] = "http://www.dev-wil.com/downloads/038/models";
      			public OnPlayerRequestDownload(playerid, type, crc)
      			{
      				if(!IsPlayerConnected(playerid))
      					return 0;
      					
      				new filename[64], filefound;
      				
      				if(type == DOWNLOAD_REQUEST_TEXTURE_FILE)
      					filefound = FindTextureFileNameFromCRC(crc, filename, sizeof(filename));
      				else if(type == DOWNLOAD_REQUEST_MODEL_FILE)
      					filefound = FindModelFileNameFromCRC(crc, filename, sizeof(filename));
      					
      				return 1;
      			}
    • Now make a condiction if the local variable is 1.
      Code:
      			new SERVER_DOWNLOAD[] = "http://www.dev-wil.com/downloads/038/models";
      			public OnPlayerRequestDownload(playerid, type, crc)
      			{
      				if(!IsPlayerConnected(playerid))
      					return 0;
      					
      				new filename[64], filefound;
      				
      				if(type == DOWNLOAD_REQUEST_TEXTURE_FILE)
      					filefound = FindTextureFileNameFromCRC(crc, filename, sizeof(filename));
      				else if(type == DOWNLOAD_REQUEST_MODEL_FILE)
      					filefound = FindModelFileNameFromCRC(crc, filename, sizeof(filename));
      					
      				if(filefound)
      					{}
      				
      				return 1;
      			}
    • Make a local variable with a size of 256. This variable will be responsible for storing a final URL of the file, containing a main URL and location of the file at that address. Create a format for the variable and insert the URL using the global variable SERVER_DOWNLOAD and the variable filename.
      Code:
      			new SERVER_DOWNLOAD[] = "http://www.dev-wil.com/downloads/038/models";
      			public OnPlayerRequestDownload(playerid, type, crc)
      			{
      				if(!IsPlayerConnected(playerid))
      					return 0;
      					
      				new filename[64], filefound, final_url[256];
      				
      				if(type == DOWNLOAD_REQUEST_TEXTURE_FILE)
      					filefound = FindTextureFileNameFromCRC(crc, filename, sizeof(filename));
      				else if(type == DOWNLOAD_REQUEST_MODEL_FILE)
      					filefound = FindModelFileNameFromCRC(crc, filename, sizeof(filename));
      					
      				if(filefound)
      				{
      					format(final_url, sizeof(final_url), "%s/%s", SERVER_DOWNLOAD, filename);
      				}
      				
      				return 1;
      			}
    • Now insert the function RedirectDownload(playerid, url[]), when the url[] is a last created local variable.
      Code:
      			new SERVER_DOWNLOAD[] = "http://www.dev-wil.com/downloads/038/models";
      			public OnPlayerRequestDownload(playerid, type, crc)
      			{
      				if(!IsPlayerConnected(playerid))
      					return 0;
      					
      				new filename[64], filefound, final_url[256];
      				
      				if(type == DOWNLOAD_REQUEST_TEXTURE_FILE)
      					filefound = FindTextureFileNameFromCRC(crc, filename, sizeof(filename));
      				else if(type == DOWNLOAD_REQUEST_MODEL_FILE)
      					filefound = FindModelFileNameFromCRC(crc, filename, sizeof(filename));
      					
      				if(filefound)
      				{
      					format(final_url, sizeof(final_url), "%s/%s", SERVER_DOWNLOAD, filename);
      					RedirectDownload(playerid, final_url);
      				}
      				return 1;
      			}
    • Turn on the SA-MP Server and go to inside the server, you will perceive a massive speed downloading your custom skins and objects;
    • If the error (22) HTTP Response co... appears is because the URL way find is wrong. Make a debug and find the soluction.

If you have any doubt please comment this thread. If you find any error or bad translation send me a PM.
Sorry my bad english, I am not native speaker.
__________________


Wil
Sometimes a captain has to make the unpopular call because that's his responsibility

/WiltonFreitas willttoonn Wil#3638

Advanced Roleplay
Staff — Management
Development Team — Head Developer
willttoonn is offline   Reply With Quote
Old 11/07/2018, 11:11 PM   #2
RedRex
Huge Clucker
 
RedRex's Avatar
 
Join Date: Jan 2016
Location: Portugal <3
Posts: 481
Reputation: 29
Default Re: 0.3.DL: How to add custom skin, object and use the Redirect()

nice! one!
__________________
Laverton's Cops and Robbers
LCNR Soon
We are working on it. JUST WAIT US!! Soon updating to hosted tap!
RedRex is offline   Reply With Quote
Old 26/08/2018, 09:40 PM   #3
SapMan
Big Clucker
 
Join Date: Jul 2017
Posts: 100
Reputation: 12
Default Re: 0.3.DL: How to add custom skin, object and use the Redirect()

Solution?

sa-mp-219.png

Captura.PNG

Captura1.PNG

Captura2.PNG


PHP Code:
new SERVER_DOWNLOAD[] = "http://github.com/SapMan/ServerModels/tree/master/models/";
public 
OnPlayerRequestDownload(playeridtypecrc)
{
    if(!
IsPlayerConnected(playerid)) return 0;
    
    new 
filename[64], filefoundurl_final[256];
    
    if(
type == DOWNLOAD_REQUEST_TEXTURE_FILE)
        
filefound FindTextureFileNameFromCRC(crcfilenamesizeof(filename));
    else if(
type == DOWNLOAD_REQUEST_MODEL_FILE)
        
filefound FindModelFileNameFromCRC(crcfilenamesizeof(filename));

    if(
filefound)
    {
        
format(url_finalsizeof(url_final), "%s/%s"SERVER_DOWNLOADfilename);
        
RedirectDownload(playeridurl_final);
    }
    return 
1;

SapMan is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Menu Skin Custom Help nguyenthanhdanhsamp Scripting Help 1 27/05/2018 04:44 PM
Set NPC skin at 0.3.8 custom skin Zeus666 Scripting Help 0 16/01/2018 07:38 PM
Custom skin bug Psycho96 SA-MP 0.3.DL 2 08/11/2017 10:41 PM
0.3.8 SetSpawnInfo custom skin bug m4karow SA-MP 0.3.DL 13 07/11/2017 08:31 PM
[Pedido] Skin Custom Lateamcraft Português/Portuguese 8 29/06/2013 12:03 AM


All times are GMT. The time now is 07:20 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.