[help] Random items

Hello, i want to create an Farming Script for my FiveM Server. But i dont have any idea how i can do this.

I will an Farming Script where you can open a Shell and when you open it you have the Chance to become 1x Pearl or 1x Diamond or nothing.

Can somebody send me the Code for this?

Hello u can look here: [help] Math.random items and amount
ENJOY!
GL!

Ok, but I dont know how i have to Do this with my items.

Feel free to ask me, I can help u with what i know…
I am sending to you an explanation right now

In the link i sent u, you can find this code:

Items = {
  "cokep",
  "hpipe",
  "lighter",
  "nitro"
}

function RandomItem()
  return Items[math.random(#Items)]
end

function RandomNumber()
	return math.random(2,6)
end

RegisterServerEvent('bankrob:loot')
AddEventHandler('bankrob:loot', function()
  local xPlayer = ESX.GetPlayerFromId(source)
  math.randomseed(GetGameTimer())
  xPlayer.addInventoryItem(RandomItem(), RandomNumber())
end)

Put the items up below after you created them on your data base and trigger it on your client side

1 Like

You can see at @Arielz post #5 :

You can put your Items in there, and need synchronize with your farm script