The demand for a script like this is raising up so I decided to release it without the source at the moment because I am not done with it. I want to add the animation in the script. You can call the animation when you trigger the event but I will add this feature in the future!
Feature list
- HUD of the Hunger and the Thirst of the player.
- Add Hunger or Thirst (Can’t go higher than 100%)
- Possibility to die if you are starving. (Can be turned off in the config)
- Walking, running multiplier (Can be modified in the config)
- GlobalMultiplier, easier to config the time needed before reaching 0.
As I am not releasing the Source Code yet. Here is a VirusTotal
Download link : Here
Include inventory (useItem) and food shops. Don’t forget the Readme.
Github for externals resources : Here
Changelog
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.2017-05-20 V0.3.2
HOTFIX Huge bug causing to update the quantity to 1 after each use. Get the new version. vdkinv.lua updated.2017-05-20 V0.3.3
HOTFIX Modified FrFuel Blip creation function. I was getting errors from it. The incompatibility seems fixed.
I decided to put both in the same resource when you download it. You can seperate if you need to.
Preview of the HUD. With FrFuel activated. As you can see, I used FrFuel as a base.
Installation process
Unzip the folder in your resources
Add foodhud to your AutoStartResources citmp-server.yml
Config explanation
HungerFactor and ThirstFactor are the value OnTick that will decreased the bar of the player. If you find that the Thirst/Hunger is going down enough you can multiply these by 1.5, 2, etc. Keep them in this format.
The formula is : HungerFactor * Running/WalkingMultiplier * GlobalMultiplier
GlobalMultiplier is 1.5. And can be modified in the config. It’s easier to change this than the Hunger/ThirstFactor. Customize it according to your needs
Here is the 4 TriggerClientEvent that you can use.
Used with a Lua table,
for example with vdk_inventory you can send the whole item that you have created
item = {name="Bottle of Water", id=1, price=5, value=20}
TriggerEvent("food:eat", item)
EventHandlers["food:eat"] += new Action<dynamic>((dynamic res) =>
{
FoodLevel = FoodLevel + res.value >= 100 ? FoodLevel = 100 : FoodLevel += res.value;
});
EventHandlers["food:drink"] += new Action<dynamic>((dynamic res) =>
{
WaterLevel = WaterLevel + res.value >= 100 ? WaterLevel = 100 : WaterLevel += res.value;
});
Used with a int value,
For example you just want to send a value to be added to Hunger/Thirst of the player.
20
TriggerEvent("food:veat", 20)
EventHandlers["food:veat"] += new Action<int>((int val) =>
{
FoodLevel = FoodLevel + val >= 100 ? FoodLevel = 100 : FoodLevel += val;
});
EventHandlers["food:vdrink"] += new Action<int>((int val) =>
{
WaterLevel = WaterLevel + val >= 100 ? WaterLevel = 100 : WaterLevel += val;
});
This one is not playing the animation
Used with a int value,
For example you just want to send a value to be added to Hunger AND Thirst of the player
20
TriggerEvent("food:death", 20)
EventHandlers["food:death"] += new Action<int>((int val) =>
{
WaterLevel = WaterLevel + val >= 100 ? WaterLevel = 100 : WaterLevel += val;
FoodLevel = FoodLevel + val >= 100 ? FoodLevel = 100 : FoodLevel += val;
});
If you would like to contribute to this project, I will add it to github soon.
Keep in mind that I used FrFuel as a base for my script because I wanted to have the same HUD to keep it clean and I wanted to have a compatibility aspect with his resource.
Special mention for the creator of FrFuel, RiderSx, I kept his name in the assembly info.
If you have any question with FiveM Scripting, you can join me on the official Discord.
I have many more resources to share, but they are not “User friendly” at the moment.
All feedback is welcome. Take care and have fun!
*As many of you guys are requesting a “Sample Store, Inventory, UseItem Script” I will try to work on this and it will be something that will give you an idea of what you can do with this script. I’m also working on a Fishing Job at the moment.
Known Issues
If you have this kind of error
Be sure that everything is configured! That the database has the two fields type
and value