// 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]