esx_core icon indicating copy to clipboard operation
esx_core copied to clipboard

es_extended - throwables, parachutes and gas canisters are not removed by the server

Open mcNuggets1 opened this issue 3 years ago • 4 comments

Describe the bug Parachutes, Gasoline canisters, Throwables etc. aren't removed by the server from the player, when using them all out. You could just reconnect or relog and have atleast 1 of them again. Works for parachutes in a way that grants infinite parachutes.

To Reproduce Steps to reproduce the behavior:

  1. Have a parachute
  2. Use it
  3. See it's gone
  4. Rejoin
  5. It's back

Expected behavior Misc items getting removed by the server after reaching the end of them.

Screenshots None needed

Debug Info (please complete the following information): Irrelevant

Additional context Not needed

mcNuggets1 avatar Jul 29 '22 12:07 mcNuggets1

Fixed in #394

mihldr avatar Aug 12 '22 13:08 mihldr

that fix was rejected?

iSentrie avatar Aug 24 '22 08:08 iSentrie

It wasn't finished. But no comment from anyone tho.

mcNuggets1 avatar Sep 02 '22 12:09 mcNuggets1

Yea I was waiting for maintainers feedback on which path to go before commiting the followup solution regarding the possible cheater abuse discussed in the PR. Got closed for whatever reason though.

mihldr avatar Sep 02 '22 14:09 mihldr

Hi! @mcNuggets1 Thank you for create issue. I honestly don't know why this issue was closed, but I'm here now and we can talk about it.

If I understand correctly, the problem is that certain items are not deleted by the server when they are used up?

What is now the status of this fix?

Thank you for answers.

Gellipapa avatar Nov 27 '22 04:11 Gellipapa

Items are not removed and the fix was closed

mcNuggets1 avatar Nov 27 '22 07:11 mcNuggets1

@mcNuggets1 Why must it always run? Can't we check if someone has thrown something away/used it up? What do you think about this?

Gellipapa avatar Nov 29 '22 19:11 Gellipapa

I honestly don't know any game events that do alert us of that event.

mcNuggets1 avatar Nov 29 '22 19:11 mcNuggets1

I see.

  CreateThread(function()
      while ESX.PlayerLoaded do
	      for i, weapon in ipairs(ESX.GetPlayerData().loadout) do
		      local playerHasWeapon = HasPedGotWeapon(ESX.GetPlayerData().ped, GetHashKey(weapon.name), false)
      
		      if not playerHasWeapon then
			      TriggerServerEvent('esx:removeWeapon', weapon.name)
		      end
	      end 
      
      
	      Wait(1000)
      end
  end)

That's what I meant. That's always the run for cycle but really you should only be holding a gun shouldn't you?

Gellipapa avatar Nov 29 '22 20:11 Gellipapa

I didn't create the code. Optimising the code would look the following:

  • check only for a few weapons, that actually can be removed from inventory
  • allow serverside removal only of these weapons
  • optimise the poorly written code and maybe don't update every second (also maybe do it serverside, not clientside)

mcNuggets1 avatar Nov 29 '22 20:11 mcNuggets1

@mcNuggets1 Oh sorry you just commented there. #394 Could you then write it as you say and if it's good we'll accept it?

Gellipapa avatar Nov 29 '22 21:11 Gellipapa

Whenever I get the time, I could take a look at it. Currently Im a little bit busy however.

mcNuggets1 avatar Nov 29 '22 21:11 mcNuggets1

No problem, thank you on behalf of the ESX team.

Gellipapa avatar Nov 29 '22 21:11 Gellipapa