Main Menu

skin changer

Started by DRACH, January 05, 2021, 07:20:15 AM

Previous topic - Next topic

DRACH

hi sir can you give me a script for skin changer for my server ? without using trainer ., please help me thank you

djebzer

#1
Hey, sorry for the late answer but it might help others.

If you want to do that on GTA III, GTA Vice City or GTA San Andreas you can simply edit the player skin by doing the code below.

I will use a skin ID from GTA:SA that you can find  .



I will make a simple function triggered when you join the server:



Client-side (JavaScript)
[spoiler]
Code (js) Select

// The 'OnPlayerJoined' event is triggered once the player joined the game. (See][/spoiler]

If you want to do it for GTA:IV, it is kinda different since the model has to be requested & loaded to the engine first.

You can use native functions to do that, I will use Niko Bellic's skin ID (hash) for this example that you can find  [url=https://wiki.gtaconnected.com/Resources/GTAIV/PedSkinshere[/url].



[i]Client-side (JavaScript)[/i]
[spoiler][code=js]
// This function creates a command handler that will let you trigger this function uppon writing '/skin' in-game. (See][/spoiler]

If you want to expand the skin changer for larger uses, you can store all skins in a variable as a table and loop through it to search entries. Here is a small example:



[i]Client-side (JavaScript)[/i]
[spoiler][code=js]
const SKINS_LIST = [
   'Carl Johnson',
   'The Truth',
   'Maccer',
   'Taxi Driver',
];

function setSkin(id, name) {
   let skinId = Number(id);
   localPlayer.skin = skinId;
   message('Your skin has been changed to ' + name + '!', COLOUR_LIME);
}

addCommandHandler('skin', (cmd, params) => {
   // Find the skin by ID (number)
   let id = parseInt(params);
   if (SKINS_LIST[id]) {
      let skinName = SKINS_LIST[id];
      return setSkin(id, skinName);
   }
   
   // Find the skin by the name
   for (const skin of SKINS_LIST) {
      if (params.toLowerCase() === skin.toLowerCase()) {
         let skinId = SKINS_LIST.indexOf(skin);
         return setSkin(skinId, skin);
      }
   }
   
   message('Invalid ID/Name!', COLOUR_RED);
});
[/spoiler]

GTA Connected's Discord server[/url] if you want quick responses for further help![/b][/size]

volvofan

Your script does not work for me in GTA 3. I just get: TypeError: localPlayer is null for the line localPlayer.skin = skinId;.
It seems like there isn't any script yet for skin-changing here: https://github.com/VortrexFTW/v-essentials
Maybe in the future?

Vortrex

Quote from: volvofan on June 24, 2024, 10:30:47 PMYour script does not work for me in GTA 3. I just get: TypeError: localPlayer is null for the line localPlayer.skin = skinId;.
It seems like there isn't any script yet for skin-changing here: https://github.com/VortrexFTW/v-essentials
Maybe in the future?

Yes, I'll make one.