RedEM-RP / redemrp_inventory

An Inventory System for RedEM:RP
GNU General Public License v3.0
13 stars 21 forks source link

How To Register usable item #19

Closed Gentil-Boo closed 3 years ago

Gentil-Boo commented 3 years ago

I knwon there is an example fo what to do, but I don't understand what file I have to edit.

and when I use

giveitem 1 bread 1

In the server console I got errors

`SCRIPT ERROR: @redemrp_inventory/server/sv_main.lua:397: attempt to index a nil value (local 'user')

ref (@redemrp_inventory/server/sv_main.lua:397) handler (@redem_roleplay/server/sv_main.lua:78) ref (@redemrp_inventory/server/sv_main.lua:396)`

SirFreddie commented 3 years ago

I knwon there is an example fo what to do, but I don't understand what file I have to edit.

and when I use

giveitem 1 bread 1

In the server console I got errors

`SCRIPT ERROR: @redemrp_inventory/server/sv_main.lua:397: attempt to index a nil value (local 'user')

ref (@redemrp_inventory/server/sv_main.lua:397) handler (@redem_roleplay/server/sv_main.lua:78) ref (@redemrp_inventory/server/sv_main.lua:396)`

You have to use it like this /giveitem bread 1 . Make sure you are an admin or superadmin. The item is given to yourself not to the selected id.

Gentil-Boo commented 3 years ago

Unfortunately it does not work either

SirFreddie commented 3 years ago

Unfortunately it does not work either

Do you have the item registered on your inventory config.lua?

Gentil-Boo commented 3 years ago

after another test, it's working for the bread with your command /giveitem bread 1 in the game console.

but if I tried /giveitem WEAPON_MELEE_LANTERN_ELECTRIC 1 nothing happen

SirFreddie commented 3 years ago

Awesome! Make sure you have it registered like this in your inventory and try using /giveitem WEAPON_MELEE_LANTERN_ELECTRIC 100

["WEAPON_MELEE_LANTERN_ELECTRIC"] =
{
    label = "Electric Lamp",
    description = "A source of light, fire & fun",
    weight = 0.5,
    canBeDropped = true,
    requireLvl = 0,
    weaponHash = GetHashKey("weapon_melee_davy_lantern"),
      imgsrc = "items/weapon_melee_electric_lantern.png",
    type = "item_weapon",
},
Gentil-Boo commented 3 years ago

Its' working. thx you

One last question. How to eat the bread in my inventory? When I drag and drop the bread on use windows, nothing happen

SirFreddie commented 3 years ago

Its' working. thx you

One last question. How to eat the bread in my inventory? When I drag and drop the bread on use windows, nothing happen

No problem! If you want to eat the bread, first of all you have to set the variable (on the bread item) canBeUsed = true inside the inventory config.lua. After that you have to register as usable item and add the logic to increase your food. You can check the script redemrp_status if you want to know more about usable consumables.

Gentil-Boo commented 3 years ago

Good. Now I can eat bread and drink water. there is this code into my config.lua for the crafting

Config.Crafting = {

["bread"] = {

items = { "empty","empty","empty", "wheat","wheat","wheat", "empty","empty","empty" }, requireJob = "empty", type = "cooking", amount = 1,

},

}

But, how to craft in the game, I did not find out. I need to use the 6 squares in inventory, but how ?

SirFreddie commented 3 years ago

As you can see there, type = "cooking" that means you require a cooking type crafting table to do that. In order to create crafting tables, check the redemrp_inventory README, there are also some examples in RedEM discord support chats aswell. I think if you put "empty" instead of "cooking" there, you will be able to craft right on the spot.

SirFreddie commented 3 years ago

Try adding that into the server side of any script, make sure you add this on top of it aswell:

data = {}
TriggerEvent("redemrp_inventory:getData",function(call)
        data = call
end)