[Release]Model-Menu V3 [9th Oct]


#291

Really cool to see a menu that isn’t made with either NativeUI or WarMenu. Even though I like both of them :stuck_out_tongue:


#292
RegisterServerEvent("clothes:save")
AddEventHandler("clothes:save",function(player_data)
	local _source = source
	local identifier = getID("steam",_source)
	MySQL.Async.execute("UPDATE users SET skin = @skin WHERE identifier = @identifier", {
	  ['@skin'] = tostring(json.encode(player_data)),
	  ['@identifier'] = identifier
	})
	models[identifier] = player_data
	
		local xPlayer = ESX.GetPlayerFromId(source)
		local playerLoadout = {}

		Citizen.CreateThread(function()
		Citizen.Wait(5000)
			for i=1, #playerLoadout, 1 do
				if playerLoadout[i].label ~= nil then
					xPlayer.addWeapon(playerLoadout[i].name, playerLoadout[i].ammo)
				end
			end
		end)
	
	-- Give weapons etc
end)`Preformatted text`

can anyone help with deleting weapons ? do i am close to make this work or thats not the way ?


#293
	local _source = source
	local xPlayer   = ESX.GetPlayerFromId(source)
	local playerLoadout = xPlayer.getLoadout()
	xPlayer.addWeapon(playerLoadout)

SaltyGrandpa could you please help with this code
i realy want to use this script but have no idea how to make that i get weapons back i am trying many difrent ways looking for some code in other scripts but cant get this to work i dont know lua that good to make this
hope you understud and can help me and others here
thank you


#294

There is an esx:restoreLoadout client-side function. Not that this is not safe for net by default, so you cannot trigger it from the server.


#295

so i need this function on server side so playerdata i need change to xplayer ?

	local xPlayer = ESX.GetPlayerFromId(source)
	local weaponback = xPlayer.getLoadout()

	for i=1, weaponback, 1 do
    local weaponHash = GetHashKey(weaponback[i].name)
    GiveWeaponToPed(xPlayer, weaponHash, weaponback[i].ammo, false, false)
  end

#296

No? Did you read my response? Lol. You just have to trigger that client event that I listed.


#297

Ok
what i did now is
i add this function to client and add trigger from server to this function

and now when exit game and come back i got weapon back
only when change model i dont get it back

and i need to solve problem with getting female basic skin after log in
but i see its problem with skinchanger

anyway
Thank you SaltyGrandpa for help!


#298

If you replace TriggerServerEvent("clothes:loaded") in client.lua with TriggerEvent('esx:restoreLoadout') this should work. This is on line 333 and 365.

This resource will not work with esx_skins or skinchanger or any other clothing/player model menu. They’ll constantly conflict with each other.


#300

This isn’t really a good place for this discussion, but pulling from es_extended/client/main.lua:

-- Save loadout
Citizen.CreateThread(function()

  while true do

    Citizen.Wait(1)

    local playerPed      = GetPlayerPed(-1)
    local loadout        = {}
    local loadoutChanged = false

    if IsPedDeadOrDying(playerPed) then
      LoadoutLoaded = false
    end

    for i=1, #Config.Weapons, 1 do

      local weaponHash = GetHashKey(Config.Weapons[i].name)

      if HasPedGotWeapon(playerPed,  weaponHash,  false) and Config.Weapons[i].name ~= 'WEAPON_UNARMED' then

        local ammo = GetAmmoInPedWeapon(playerPed, weaponHash)

        if LastLoadout[Config.Weapons[i].name] == nil or LastLoadout[Config.Weapons[i].name] ~= ammo then
          loadoutChanged = true
        end

        LastLoadout[Config.Weapons[i].name] = ammo

        table.insert(loadout, {
          name  = Config.Weapons[i].name,
          ammo  = ammo,
          label = Config.Weapons[i].label
        })

      else

        if LastLoadout[Config.Weapons[i].name] ~= nil then
          loadoutChanged = true
        end

        LastLoadout[Config.Weapons[i].name] = nil

      end

    end

    if loadoutChanged and LoadoutLoaded then
      ESX.PlayerData.loadout = loadout
      TriggerServerEvent('esx:updateLoadout', loadout)
    end

  end
end)

Anything further should be discussed on the ESX Base release thread.


#302

how to install and how to add models? ty in advance ^^


#303

It’s in the config.lua.


#304

sorry but i don’t get anything there ><