[Release] Cooking [VRP]

Hi guys, i created a simple script that let u cooking food.
That script based on Vrp.
Sorry for my english

To install this script, u need:

First, open vrp_basic_menu/server.lua, and add

function cook (player, ingrd, ingrd2, food, name, amount1, amount2, amountf)
  local seq = {  {"amb@prop_human_bbq@male@base","base",1}  }
  local user_id = vRP.getUserId({player})
  if user_id ~= nil then
    if vRP.getInventoryItemAmount({user_id, ingrd}) > 0 and vRP.getInventoryItemAmount({user_id, ingrd2}) > 0 then
      vRP.tryGetInventoryItem({user_id,ingrd,amount1})
      vRP.tryGetInventoryItem({user_id,ingrd2,amount2})
      vRP.giveInventoryItem({user_id,food,amountf})
      vRPclient.playAnim(player, {true, seq, false})
      TriggerClientEvent("pNotify:SendNotification",user_id,{text = "You create" ..name, type = "success", timeout = (3000),layout = "centerRight"})
    else
      TriggerClientEvent("pNotify:SendNotification",user_id,{text = "You don't  have ingredients", type = "error", timeout = (3000),layout = "centerRight"})
    end
  end
end

Let me explain, in function we have some value like player, ingrd, ingrd2, food, name, amount1, amount2 and amountf
Soo…
player this constanta, which you don’t need to change
ingrd and ingrd2 are ingredients of your food
food this what u will get at the end
amount1 - this amount of first ingredient which u need to cook, and amount2 this amount of second ingredient.
amountf - this amount of food which u will get in the end

Hope you understand

Second what we need to add in server.lua(basic_menu)

local kitchen = {} 
kitchen["Create scrambled eggs with bacon "] = {function(player, choice) -- create a menu choose 
local user_id = vRP.getUserId({player})
    cook(player, "egg", "bacon", "eggbac", "scrambled eggs with bacon", 1, 1, 1)  -- function calling
end, "Ingredients: one egg and  one bacon."}

This your “list” of food, in this example i create a scrambled eggs.

Next, in the end of server.lua we find line

-- ADD STATIC MENU CHOICES  STATIC MENUS NEED TO BE ADDED AT vRP/cfg/gui.lua

under this line we put this line of cod

vRP.addStaticMenuChoices({"kitchen", kitchen})

That all what we need to do, in vrp_basic_menu
Next we go to vrp/cfg/gui.lua. Then u need to find line

cfg.static_menu_types 

and add this

  ["kitchen"] = {
    title = "Kitchen"
  },

then scroll down and find

cfg.static_menus

and add

{"kitchen", -30.91600227356,-587.87414550781,88.712272644043}

But that not all.
Last what we need, that create items.
First of all we create 2 items that don’t have hunger value
Go to vrp/cfg/items.lua and add

["egg"] = {"Egg", "", nil, 0.01},
  ["bacon"] = {"Bacon", "", nil, 0.01},

then go to vrp/cfg/item/food and add

items["eggbac"] = {"scrambled egg with bacon","", gen("eat",-25,0),0.5}

To create your own food, u need to add in basic menu under “local = kitchen” this

kitchen["Food name "] = {function(player, choice) -- create a menu choose 
local user_id = vRP.getUserId({player})
    cook(player, "name of first ingr(from omet list)", "name of second Ingrid(from item list)", "what food u will get in the end(y need to take this from food list)", "Food name", 1, 1, 1)  -- function calling
end, "Ingredients:."}

And don’t forget to add items to food.cfg or items.cfg
And yay, that all what we need to do, if u have some trouble, u can write to me.
If u want to understand how work static GUI, u need to read this very useful tutorial -

some screenshots, better if u install and check by yourself


3 Likes

Uhm first I don’t think you can advertise your discord, don’t quote me on that and second can we get some screenshots? It sounds cool

ofk, wait a bit

ready, screenshots uploaded

if the script were in english, that would be great :grin:

i’m already translated into english

I wish this was for ESX

1 Like

sry, but i don’t work on esx :frowning:

1 Like

Nice release buddy, here you have some suggestions:
You could make it a external resource and make the ingredients load a table instead of just 2 items and the same for the food.

Activate your windows :stuck_out_tongue:

cool good job


Thank you, but it’s not such a big script to add it as a single script, just too many scripts then appear in the list. And at the expense of loading from a separate sheet, a good idea, I’ll think

not too difficult to convert to esx just change 2-3 words … thanks for the script :stuck_out_tongue:

:smirk: nah

that’d be awesome if it was

Is this limited to only the owner of the property? Say you have a few guests and they want to go cook up some eggs and bacon, can they do it as guests or do you have to do it for them?

No, all can cooking, but u may set permission by adding
permissions = {some permissions}

To GUI.lua to line [“kitchen”]

Thank you for responding. I like that you can have guests do their own cooking, or cook for them, that’s really cool. Great roleplay can come from sitting around having a home cooked meal. This is really awesome.
:+1::+1::+1:
Maybe we can expand the menu as well.

you should add Citizen.Wait function for longer cooking

Its client function, i think that won’t work, but oke Ill try