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