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: 872
Reputation: 62
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:
      pawn 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.
      pawn 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:
      pawn 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.
      pawn 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.
      pawn Code:
      public OnPlayerRequestDownload(playerid, type, crc)
                  {
                 
                      return 1;
                  }
    • Create a new global variable without size, on top of the OnPlayerRequestDownload with name SERVER_DOWNLOAD.
      pawn 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.
      pawn 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.
      pawn 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.
      pawn 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)
      pawn 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.
      pawn 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.
      pawn 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.
      pawn 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.
      pawn 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.
__________________
Sometimes a captain has to make the unpopular call because that's his responsibility
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: 496
Reputation: 29
Default Re: 0.3.DL: How to add custom skin, object and use the Redirect()

nice! one!
__________________
RedRex's Cops and Robbers
RCNR Soon
We are working on it. Just wait us!! Soon updating to hosted tap after finished.
RedRex is offline   Reply With Quote
Old 26/08/2018, 09:40 PM   #3
SapMan
Banned
 
Join Date: Jul 2017
Posts: 142
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
Old 15/04/2019, 03:25 PM   #4
Hawsn
Little Clucker
 
Hawsn's Avatar
 
Join Date: Jan 2017
Location: Vietnam
Posts: 10
Reputation: 0
Default Re: 0.3.DL: How to add custom skin, object and use the Redirect()

how i can add custon skin of vehicle/weapon ?
Hawsn is offline   Reply With Quote
Old 15/04/2019, 03:29 PM   #5
homelessdrop
Little Clucker
 
homelessdrop's Avatar
 
Join Date: Jan 2016
Posts: 40
Reputation: 17
Default Re: 0.3.DL: How to add custom skin, object and use the Redirect()

Skin / Weapon isn't supported. You know use just objects and skin's.
homelessdrop is offline   Reply With Quote
Old 29/06/2019, 10:52 AM   #6
Bonch
Little Clucker
 
Join Date: Feb 2017
Location: Tbillisi, Georgia
Posts: 21
Reputation: 5
Default Re: 0.3.DL: How to add custom skin, object and use the Redirect()

Nice guide, Thanks. So, I need to write condition
if(files are not downloading)
showLoginDialog():

How to do this?! <#
Bonch is offline   Reply With Quote
Old 31/07/2019, 11:49 PM   #7
willttoonn
Gangsta
 
willttoonn's Avatar
 
Join Date: Nov 2011
Location: Brazil
Posts: 872
Reputation: 62
Default Re: 0.3.DL: How to add custom skin, object and use the Redirect()

Quote:
Originally Posted by Bonch View Post
Nice guide, Thanks. So, I need to write condition
if(files are not downloading)
showLoginDialog():

How to do this?! <#
There is not yet a function in version 0.3.DL that makes it known that downloads are not being performed. However, you can place the login dialog on the public OnPlayerRequestClass.

Quote:
Originally Posted by Hawsn View Post
how i can add custon skin of vehicle/weapon ?
The possibility to add custom vehicles and weapons is not yet available in SA-MP 0.3.DL R1.
__________________
Sometimes a captain has to make the unpopular call because that's his responsibility
willttoonn is offline   Reply With Quote
Old 05/08/2019, 01:11 PM   #8
ognyanov
Big Clucker
 
ognyanov's Avatar
 
Join Date: Apr 2015
Posts: 111
Reputation: 0
Default Re: 0.3.DL: How to add custom skin, object and use the Redirect()

Really useful, thank you!
ognyanov is offline   Reply With Quote
Old 19/08/2019, 06:56 AM   #9
Bonch
Little Clucker
 
Join Date: Feb 2017
Location: Tbillisi, Georgia
Posts: 21
Reputation: 5
Default Re: 0.3.DL: How to add custom skin, object and use the Redirect()

Hey guys, Do you know where to host my models, Like which is best web page for it and how to get direct download link. Thankya.
Bonch 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 01:57 PM.


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