Jump to content

Recommended Posts

Posted

Good evening,
I'm looking for some days for a way to change individual garments on a character. However, until now without success.

I did not get any further with player.setClothes. I have tried many values, but my player's clothing has not changed. Can someone help me there?

I am thankful for every help.
greeting
Kai

Posted

Here is an example code of my server. You just have to require this file in your index.js (server file package)

When you run in checkpoint of police station in mission row, you will get clothing of a male police officer and some weapons:

//Sets a blip on the map so you see the location

let policeBlipVector = new mp.Vector3(446.99676513671875, -983.9864501953125, 30.689605712890625); //Set a Vector3
let userBlip = mp.blips.new(60, policeBlipVector, {
        name: "PoliceHQ",
        scale: 1,
        color: 3,
        alpha: 255,
        drawDistance: 100,
        shortRange: true,
        rotation: 0,
        dimension: 0,
    }); //Create a Blip on a Policestation

// creates a checkpoint to run in

let copCheckpoint = mp.checkpoints.new(1, new mp.Vector3(458.07373046875, -990.92236328125, 29), 2,
{
    direction: new mp.Vector3(0.2, 0,2, 0.2),
    color: [ 255, 255, 255, 50 ],
    visible: true,
    dimension: 0
});    

// Handler if you enter checkpoint (you will add ammo if you run in multiple time as the code does not check if already entered the checkpoint)

mp.events.add("playerEnterCheckpoint", (player, checkpoint) => {
    
    if(checkpoint === copCheckpoint) {
        
    if(player.data.copLevel > 0) { // This var checks if you have coplevel greater then 0 which comes out of database on player login
        
        // Remove all weapons
        player.removeAllWeapons();
        // assault rifle
        player.giveWeapon(0xFAD1F1C9, 200);
        // pistol
        player.giveWeapon(0xBFE256D4, 50);
        // assault tonfa
        player.giveWeapon(0x678B81B1, 200);
        // assault tazer
        player.giveWeapon(0x3656C8C1, 100);        
        // Set Uniform
        player.setClothes(3,0,0,2);
        player.setClothes(8,58,0,2);
        player.setClothes(6,25,0,2);
        player.setClothes(4,35,0,2);
        player.setClothes(11,55,0,2);
        
    } else {
        player.notify("You are not a police officer");
    }
    
    }
        
});

 

  • Like 1
Posted
1 hour ago, cmdflow said:

Here is an example code of my server. You just have to require this file in your index.js (server file package)

When you run in checkpoint of police station in mission row, you will get clothing of a male police officer and some weapons:


//Sets a blip on the map so you see the location

let policeBlipVector = new mp.Vector3(446.99676513671875, -983.9864501953125, 30.689605712890625); //Set a Vector3
let userBlip = mp.blips.new(60, policeBlipVector, {
        name: "PoliceHQ",
        scale: 1,
        color: 3,
        alpha: 255,
        drawDistance: 100,
        shortRange: true,
        rotation: 0,
        dimension: 0,
    }); //Create a Blip on a Policestation

// creates a checkpoint to run in

let copCheckpoint = mp.checkpoints.new(1, new mp.Vector3(458.07373046875, -990.92236328125, 29), 2,
{
    direction: new mp.Vector3(0.2, 0,2, 0.2),
    color: [ 255, 255, 255, 50 ],
    visible: true,
    dimension: 0
});    

// Handler if you enter checkpoint (you will add ammo if you run in multiple time as the code does not check if already entered the checkpoint)

mp.events.add("playerEnterCheckpoint", (player, checkpoint) => {
    
    if(checkpoint === copCheckpoint) {
        
    if(player.data.copLevel > 0) { // This var checks if you have coplevel greater then 0 which comes out of database on player login
        
        // Remove all weapons
        player.removeAllWeapons();
        // assault rifle
        player.giveWeapon(0xFAD1F1C9, 200);
        // pistol
        player.giveWeapon(0xBFE256D4, 50);
        // assault tonfa
        player.giveWeapon(0x678B81B1, 200);
        // assault tazer
        player.giveWeapon(0x3656C8C1, 100);        
        // Set Uniform
        player.setClothes(3,0,0,2);
        player.setClothes(8,58,0,2);
        player.setClothes(6,25,0,2);
        player.setClothes(4,35,0,2);
        player.setClothes(11,55,0,2);
        
    } else {
        player.notify("You are not a police officer");
    }
    
    }
        
});

 

2

Not a big issue, just thought I'd let you know when you're creating something like blips, if you're not changing the value you don't have to put in the same as the default value, not sure but scale could be 1 by default. Just thought I'd mention it cause it can cut down on lines if you end up with some pretty big files. The below would work the same but if you already know this just ignore this, thought I'd let you know just in case.

let userBlip = mp.blips.new(60, policeBlipVector, {
        name: "PoliceHQ",
        scale: 1,
        color: 3,
        drawDistance: 100,
        shortRange: true,
    }); //Create a Blip on a Policestation
  • Like 3

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...