[Tutorial] 0.3.DL: How to add custom skin, object and use the Redirect()
#1

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:
      pawn Код:
      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.
      pawn Код:
      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:
      pawn Код:
      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.
      pawn Код:
      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.
      pawn Код:
      public OnPlayerRequestDownload(playerid, type, crc)
                  {
                 
                      return 1;
                  }
    • Create a new global variable without size, on top of the OnPlayerRequestDownload with name SERVER_DOWNLOAD.
      pawn Код:
      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.
      pawn Код:
      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.
      pawn Код:
      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.
      pawn Код:
      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)
      pawn Код:
      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.
      pawn Код:
      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.
      pawn Код:
      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.
      pawn Код:
      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.
      pawn Код:
      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.
Reply
#2

nice! one!
Reply
#3

Solution?

sa-mp-219.png

Captura.PNG

Captura1.PNG

Captura2.PNG


PHP код:
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;

Reply
#4

how i can add custon skin of vehicle/weapon ?
Reply
#5

Skin / Weapon isn't supported. You know use just objects and skin's.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)