pedr0fontoura / fivem-appearance

👀 A flexible player customization script for FiveM.
https://forum.cfx.re/t/release-fivem-appearance/2438537
MIT License
120 stars 73 forks source link

Unexpected end of JSON input #9

Closed omeking2013 closed 3 years ago

omeking2013 commented 3 years ago

problem

Error when join the server and ui wont appear how to fix?? (1.1.0 version)

MintKind commented 3 years ago

Starting the resource last solved this for me. Had it starting as very first before tho.

mufty commented 3 years ago

Starting the resource last solved this for me. Had it starting as very first before tho.

Can confirm starting it last does help... otherwise same issue.

The modules I was starting after this one are: start dpemotes start RealisticVehicleFailure start fh4speed

Just for context maybe they are in conflict.

RockySouthpaw commented 3 years ago

After asking someone about it they told me:

It’s due to the fact the NUI inits before before game scripts.

on('onClientResourceStart', resourceName => {
if (GetCurrentResourceName() != resourceName) {
return;
}
init();
});

The resource only initializes the NUI callbacks after the script is fully started.

Not sure if the fix would require a rework of the existing system but I don’t think starting the resource last is a reliable workaround tbh.

Here’s a screenshot of the dev tools:

mufty commented 3 years ago

Yeah I just got the error even when starting it last

alessiocavallo commented 3 years ago

Same here

weristwiegott commented 3 years ago

in resources.cfg

start fivem-appearance restart fivem-appearance

the error will go away

ElSeba0811 commented 3 years ago

After asking someone about it they told me:

It’s due to the fact the NUI inits before before game scripts.

on('onClientResourceStart', resourceName => {
  if (GetCurrentResourceName() != resourceName) {
    return;
  }
  init();
});

The resource only initializes the NUI callbacks after the script is fully started.

Not sure if the fix would require a rework of the existing system but I don’t think starting the resource last is a reliable workaround tbh.

Here’s a screenshot of the dev tools:

I have also tried this but is not working, also tried putting the resource last and restart it, also doesnt work

ZiggyJoJo commented 3 years ago

Did anyone ever manage to fix this error?

mufty commented 3 years ago

I didn't for the moment I'm using this resource and starting it last that works most of the time while it still can crash sometimes. So I just need to watch out when starting the server for that. If what has been said here is true it's an easy fix tho just didn't have time myself to try to look into it and fix it for real.

ZiggyJoJo commented 3 years ago

I didn't for the moment I'm using this resource and starting it last that works most of the time while it still can crash sometimes. So I just need to watch out when starting the server for that. If what has been said here is true it's an easy fix tho just didn't have time myself to try to look into it and fix it for real.

Yeah I tried that but it didn't work I mostly work with lua not js or HTML so I was hoping someone had an example of how that fix should be done otherwise I'm probably gonna spend the next few days banging my head against a wall till I figure it out

snakewiz commented 3 years ago

How I'm not able to reproduce this? I'm joining the server with the resource already running.

Using the latest release.

server.cfg

ensure fivem-appearance
ensure test

test resource

RegisterCommand(
  "customization",
  () => {
    globalThis.exports["fivem-appearance"].startPlayerCustomization((appearance) => {
      console.log(appearance);
    });
  },
  false
);
ZiggyJoJo commented 3 years ago
setr fivem-appearance:locale "en"
ensure fivem-appearance
RegisterCommand('customization', function()
    local config = {
        ped = true,
        headBlend = true,
        faceFeatures = true,
        headOverlays = true,
        components = true,
        props = true
    }

    Citizen.Wait(1000)

    exports['fivem-appearance']:startPlayerCustomization(function (appearance)
        if (appearance) then
            TriggerServerEvent('fivem-appearance:save', appearance)
            print('Saved')
        else
            print('Canceled')
        end
    end, config)
end, false)

This is how I've got it and it throw's this error on login

image

pedr0fontoura commented 3 years ago

Is this fixed after c7458d259633b7fbc31d2d098b13ef0d07ed5829?