Giter VIP home page Giter VIP logo

foodhud_externals's Introduction

Deprecated, Old FiveM System

foodhud

Requirements

Credits

Changelog

  • 2017-05-19 V0.1 Released first version

  • 2017-05-19 V0.1.1 Added a config file! Added more informations in the post. Now in a zip file, easier to install.

  • 2017-05-20 V0.2 Added GlobalMultiplier in the config file! Added animations for Drinking and Eating. Now you die when you reach 51% of your health (Regeneration was preventing the death of the player) When you die, your needs are replenish

  • 2017-05-20 V0.3 Added External resources that I modified to be able to integrate my foodhud. vdk_inventory, gb_needs There is some shop missing in gb_needs. If you someone want to contribute, you are welcome to.

  • 2017-05-20 V0.3.1 Release a modified version of frfuel to prevent it from crashing on client start. (Main link) Fixed (Trying to) the DataReader mysql error causing by gb_foodshops (github) Moved changedlog on github.

Installation

  • Download the resource here : https://github.com/ldlac/foodhud_externals

  • Place the folder "vdk_inventory" and "gb_foodshops" to resources folder of FiveM

  • Execute modified.sql file in your database (will create the tables, the constraints and add some examples items)

  • If you already have vdk_inventory installed, there is two fields to add in the items table "value" and "type"

  • DON'T FORGET TO MATCH THE ID IN THE SCRIPT WITH THE ONE IN YOUR DATABASE

  • Change your database configuration in config.lua

  • Populate the items and user user_inventory tables to test

  • Add your items to the Database. id - libelle - value (%gain) - type (1 drink, 2 eat)

  • Modify the array in fooditems_sv.lua to match your database

  • Modify the buttons in foodGUI.lua to match your database - Starting at line : 183 DON'T FORGET TO MATCH THE ID IN THE SCRIPT WITH THE ONE IN YOUR DATABASE

Usage

  • For users : Press your Replay Help Button (usually 'K') to show the menu
  • E Near the shop marker
  • For developers : Use "player:receiveItem" and "player:looseItem" events with the item id and quantity as parameters events to add or remove items from the inventory

Thanks

https://forum.fivem.net/t/release-gui-script-v0-8

For the menu

Notes

These two resources have not been made by me. I modified them to match my foodhud script. Credits goes to their respective creator.

##Modification to vdk_inventory

vdkinv.lua

function ItemMenu(itemId)
    ClearMenu()
    MenuTitle = "Details:"
    Menu.addButton("Utiliser", "use", itemId)
    Menu.addButton("Donner", "give", itemId)
end

function use(item)
    if (ITEMS[item].quantity - 1 >= 0) then
        -- Nice var swap for nothing
        TriggerEvent("player:looseItem", item, 1)
        TriggerServerEvent("item:updateQuantity", 1, item)
        -- Calling the Hunger/Thirst
        if ITEMS[item].type == 2 then
            TriggerEvent("food:eat", ITEMS[item])
        elseif ITEMS[item].type == 1 then
            TriggerEvent("food:drink", ITEMS[item])
        else
            -- Any other type? Drugs??????
            Toxicated()
            Citizen.Wait(7000)
            ClearPedTasks(GetPlayerPed(-1))
            Reality()
        end
    end
end




--------------------------------------------------------
function Toxicated()
	  Citizen.Wait(5000)
	  DoScreenFadeOut(1000)
	  Citizen.Wait(1000)
	  ClearPedTasksImmediately(GetPlayerPed(-1))
	  SetTimecycleModifier("spectator5")
	  SetPedMotionBlur(GetPlayerPed(-1), true)
	  SetPedMovementClipset(GetPlayerPed(-1), "MOVE_M@DRUNK@SLIGHTLYDRUNK", true)
	  SetPedIsDrunk(GetPlayerPed(-1), true)
	  DoScreenFadeIn(1000)
end

function Reality()
  Citizen.Wait(50000)
  DoScreenFadeOut(1000)
  Citizen.Wait(1000)
  DoScreenFadeIn(1000)
  ClearTimecycleModifier()
  ResetScenarioTypesEnabled()
  ResetPedMovementClipset(GetPlayerPed(-1), 0)
  SetPedIsDrunk(GetPlayerPed(-1), false)
  SetPedMotionBlur(GetPlayerPed(-1), false)
end

server.lua

AddEventHandler("item:getItems", function()
    items = {}
    local player = getPlayerID(source)
    local executed_query = MySQL:executeQuery("SELECT * FROM user_inventory JOIN items ON `user_inventory`.`item_id` = `items`.`id` WHERE user_id = '@username'", { ['@username'] = player })
    local result = MySQL:getResults(executed_query, { 'quantity', 'libelle', 'item_id', 'value', 'type' }, "item_id")
    if (result) then
        for _, v in ipairs(result) do
            t = { ["quantity"] = v.quantity, ["libelle"] = v.libelle, ["value"] = v.value , ["type"] = v.type }
            table.insert(items, tonumber(v.item_id), t)
        end
    end
    TriggerClientEvent("gui:getItems", source, items)
end)

foodhud_externals's People

Contributors

boubiro avatar ldlac avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

foodhud_externals's Issues

Good Job

Realy nice job but can you update vdk_invenory with new version pls ?

Huh?! getPlayerFromId problem

Hey, thank's for your work but i got a little problem... when i try to buy a item in stores, i got this error on the console:

http://i.imgur.com/EkfXza9.png

And i don't know why this error appears.. x')

EDIT: Sorry i'm an idiot.. XD just forgot to change itemID in foodGUI u_u

Installation troubles

Hi!

I'm just following the instructions on how to set this up but I got stuck at this bit:

  • Execute modified.sql file in your database (will create the tables, the constraints and add some examples items)

How do I do this?

Thanks.

Pull Request

Je sais pas comment on fait du coup, je met sa la x) Pour le menu de FiveM que tu me parlais :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.