Remco1337 Posted April 27, 2020 Posted April 27, 2020 (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 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 April 27, 2020 by Remco1337
polack Posted April 27, 2020 Posted April 27, 2020 (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 April 27, 2020 by polack
Remco1337 Posted April 27, 2020 Author Posted April 27, 2020 (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 April 27, 2020 by Remco1337
Division Posted April 27, 2020 Posted April 27, 2020 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now