RedEM-RP / redemrp_skin

A Character Creation system for RedEM:RP
https://redemrp.org/
GNU General Public License v3.0
7 stars 19 forks source link

Player skin "Loading..." #26

Closed andeim closed 3 years ago

andeim commented 3 years ago

I've a problem with my dev instance with loading skins. I'm using redemrp_skin (clone from github) When my database is empty (no character created) the game is loading, the skin UI is popping and i can customize my hero. The problem appears when i deco/reco. Redm find my character, load the json's skin but nothin occure for the client. The console print "Loading..." The `while test == false ̀ loop never ending in cl_main ...

Squibsie commented 3 years ago

Did you ever remedy this? I appear to be having similar issues.

DevDokus commented 3 years ago

That problem you get if you make changes on your characters skin with a different plugin, for example the Barber. Your skin becomes corrupted and it fails to fetch it, leaving you in a infinite loading screen. I fixed this in a server I am developing for to create a counter in the loop, and once it reaches 30, it deletes the characters skins of this player and gives him a message to relog. Once he relogs he/she will, after loading, be booted into the character skin creator

Just replace the following event.


--------------------------------
CLIENT - ( Replace the event )
--------------------------------
RegisterNetEvent('redemrp_skin:applySkin')
AddEventHandler('redemrp_skin:applySkin', function(_data, target , clothes)
    Citizen.CreateThread(function()
        local _clothes = clothes
        local _t = target
        local _target = _t or PlayerPedId()
        local test = false

        local data = _data
        if _t == nil then
            local model = "mp_male"
            if tonumber(data.sex) == 1 then
                model = "mp_male"
            elseif tonumber(data.sex) == 2 then
                model = "mp_female"
            end
            LoadModel(PlayerPedId() , model)
            _target =  PlayerPedId()
            SetEntityAlpha(_target, 0)
        end
                components_data = data

        local StuckCounter = 0
        while test == false do
            StuckCounter = (StuckCounter + 1)
            FixIssues(_target, data)
            LoadBoody(_target, data)
            LoadHead(_target, data)
            LoadHair(_target, data)
            LoadEyes(_target, data)
            LoadBodySize(_target, data)
            LoadFeatures(_target, data)
            LoadOverlays(_target, data)
            Wait(500)
            Citizen.InvokeNative(0x704C908E9C405136, _target)
            Citizen.InvokeNative(0xCC8CA3E88256E58F, _target, 0, 1, 1, 1, 0)
            test =  HasBodyComponentsLoaded (_target ,tonumber(data.hair) > 1 , tonumber(data.beard) > 1)
              LoadHeight(_target, data)

            if (StuckCounter >= 1) then print("[ DevDokus ][ Anti Infitite Load ]: Stuck Counter = [ "..StuckCounter.."/30 ]") end
            if (StuckCounter >= 30) then
              StuckCounter = 0
              print("[ DevDokus ][ Anti Infitite Load ]: It Seems you are stuck in the loading menu") Wait(2500)
              print("[ DevDokus ][ Anti Infitite Load ]: We are going to reset your characters skin.") Wait(2500)
              print("[ DevDokus ][ Anti Infitite Load ]: Once done you should be able to login again.") Wait(2500)
              print("[ DevDokus ][ Anti Infitite Load ]: PLEASE WAIT! DO NOT LOGOUT OR SHUTDOWN THE GAME!!!") Wait(2500)
              print("[ DevDokus ][ Anti Infitite Load ]: Character Fixing in Progress ....")

              TriggerServerEvent('DevDokus:Skin:S:FixCharacter') Wait(5000)
              print("[ DevDokus ][ Anti Infitite Load ]: Character Fixing Successful!") Wait(2500)
              print("[ DevDokus ][ Anti Infitite Load ]: You can not exit and reload RedM!") Wait(2500)
              print("[ DevDokus ][ Anti Infitite Load ]: You have to reload!")
            end

        end
        if _t == nil then
            SetEntityAlpha(_target, 255)
            TriggerServerEvent("redemrp_clothing:loadClothes", 1)
            TriggerServerEvent('redemrp_respawn:TestDeathStatus')
        else
            if not next(_clothes) then
                TriggerEvent("redemrp_identity:removeLoadingScreen")
            else
                TriggerEvent("redemrp_clothing:load", _clothes, _target)
            end

        end
    end)
end)

--------------------------------
SERVER LUA (Just add this in) 
--------------------------------
RegisterServerEvent('DevDokus:Skin:S:FixCharacter')
AddEventHandler('DevDokus:Skin:S:FixCharacter', function()
  local Steam
  for i = 0, GetNumPlayerIdentifiers(source) - 1 do
      local id = GetPlayerIdentifier(source, i)
      if string.find(id, "steam") then Steam = id end
  end

  print("[ DevDokus ][ Anti Infitite Load ]: User "..Steam.." | Got stuck in the load menu")
  print("[ DevDokus ][ Anti Infitite Load ]: Users skins are reset.")
  MySQL.Async.execute('delete from skins where identifier=@identifier', {
    identifier = Steam
  }, function() end)
end)