Jump to content

C# GetPlayerHeadOverlay returning weird value.


Recommended Posts

Posted (edited)

Hi,

I am working on a character creation system and I am trying to recieve the set values which have been set client-wise but it returns some odd values while trying to store it in the database server-side.

This is what it returns serverside: 

FACIAL HAIR: 40 | 40 | NEW: 40

CODE:

int characterFacialHair = NAPI.Player.GetPlayerHeadOverlay(player, 1).Index;
            Console.WriteLine("FACIAL HAIR: " + characterFacialHair + " | " + NAPI.Player.GetPlayerHeadOverlay(player, 1).Index + " | NEW: " + player.GetHeadOverlay(1).Index);

And on clientside it just sets it properly I quess:

AND IT CORRECTLY SHOWS LIKE A MUSTACHE OR ANYTHING SO IT WORKS CLIENT-SIDE

tjtSZ60.png

mp.events.add('customizeCharacterFace', (index, scale) => {
    mp.gui.chat.push("Character activated! ");
    let indexNumber = Number(index);
    let overlay = scale;
    mp.players.local.setFaceFeature(indexNumber, overlay);
    mp.gui.chat.push("Character updated! " + overlay + " | " + indexNumber + " | HEAD: " + mp.players.local.getFaceFeature(1));
});

I use HTML range which have a value of the the indexes of setFaceFeature so for the facial hair it's 0-28 and you see on the clientside debug it sets it properly but somehow still returns weird on the server-side because 40 should be out of range?

 

Edited by Remco1337
Posted (edited)

Why you do "NAPI.Player.GetPlayerhHeadOverlay(player, 1).Index"?

I think the function is something like this: 

NAPI.Player.GetPlayerHeadOverlay(Client player, int index);

Try directly this:

NAPI.Player.GetPlayerHeadOverlay(player, index);

And test it.

Edited by polack
Posted (edited)
Console.WriteLine("FACIAL HAIR: " + characterFacialHair + " | " + NAPI.Player.GetPlayerHeadOverlay(player, 1) + " | NEW: " + player.GetHeadOverlay(1));

SHOWS:

FACIAL HAIR: 136 | GTANetworkAPI.HeadOverlay | NEW: GTANetworkAPI.HeadOverlay

Hence why I used the .index to display the index component of the Object.

Edited by Remco1337
Posted

I dont know, if that function that u're using matches your behavior (never used that before).

Tip:

1. do your char-creation fully clientside and generate a JSON string after character settings got applied.
2. send your JSON string to the server via player.callRemote("server.character.appearance.save", json);
3. take that json, write it into the database or convert it via Newtonsoft into your caracter class and do whatever you like with that

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...