-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
convert: esx_basicneeds > bpt_basicneeds
- convert esx_basicneeds > bpt_basicneeds -
- Loading branch information
1 parent
15b9ff8
commit b525611
Showing
27 changed files
with
225 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
server-data/resources/[bpt_addons]/bpt_basicneeds/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<h1 align='center'>bpt_basicneeds</a></h1> | ||
<p align='center'><a href='https://discord.gg/ksGfNvDEfq'>Discord</a> | ||
|
||
Copyright (C) 2024 bitpredator | ||
|
||
This program Is free software: you can redistribute it And/Or modify it under the terms Of the GNU General Public License As published by the Free Software Foundation, either version 3 Of the License, Or (at your option) any later version. | ||
|
||
This program Is distributed In the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty Of MERCHANTABILITY Or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License For more details. | ||
|
||
ATTENTION: | ||
You are not authorized to change the name of the resource and the resources within it. | ||
|
||
If you want to contribute you can open a pull request. | ||
|
||
You are not authorized to sell this software (this is free project). | ||
|
||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
|
||
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. |
4 changes: 4 additions & 0 deletions
4
server-data/resources/[bpt_addons]/bpt_basicneeds/bpt_basicneeds.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
INSERT INTO `items` (`name`, `label`, `weight`) VALUES | ||
('bread', 'Bread', 1), | ||
('water', 'Water', 1) | ||
; |
132 changes: 132 additions & 0 deletions
132
server-data/resources/[bpt_addons]/bpt_basicneeds/client/main.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
local IsDead = false | ||
local IsAnimated = false | ||
|
||
AddEventHandler("bpt_basicneeds:resetStatus", function() | ||
TriggerEvent("bpt_status:set", "hunger", 500000) | ||
TriggerEvent("bpt_status:set", "thirst", 500000) | ||
end) | ||
|
||
RegisterNetEvent("bpt_basicneeds:healPlayer") | ||
AddEventHandler("bpt_basicneeds:healPlayer", function() | ||
-- restore hunger & thirst | ||
TriggerEvent("bpt_status:set", "hunger", 1000000) | ||
TriggerEvent("bpt_status:set", "thirst", 1000000) | ||
|
||
-- restore hp | ||
local playerPed = PlayerPedId() | ||
SetEntityHealth(playerPed, GetEntityMaxHealth(playerPed)) | ||
end) | ||
|
||
AddEventHandler("esx:onPlayerDeath", function() | ||
IsDead = true | ||
end) | ||
|
||
AddEventHandler("esx:onPlayerSpawn", function(spawn) | ||
if IsDead then | ||
TriggerEvent("bpt_basicneeds:resetStatus") | ||
end | ||
|
||
IsDead = false | ||
end) | ||
|
||
AddEventHandler("bpt_status:loaded", function(status) | ||
TriggerEvent("bpt_status:registerStatus", "hunger", 1000000, "#CFAD0F", function(status) | ||
return Config.Visible | ||
end, function(status) | ||
status.remove(100) | ||
end) | ||
|
||
TriggerEvent("bpt_status:registerStatus", "thirst", 1000000, "#0C98F1", function(status) | ||
return Config.Visible | ||
end, function(status) | ||
status.remove(75) | ||
end) | ||
end) | ||
|
||
AddEventHandler("bpt_status:onTick", function(data) | ||
local playerPed = PlayerPedId() | ||
local prevHealth = GetEntityHealth(playerPed) | ||
local health = prevHealth | ||
|
||
for k, v in pairs(data) do | ||
if v.name == "hunger" and v.percent == 0 then | ||
if prevHealth <= 150 then | ||
health = health - 5 | ||
else | ||
health = health - 1 | ||
end | ||
elseif v.name == "thirst" and v.percent == 0 then | ||
if prevHealth <= 150 then | ||
health = health - 5 | ||
else | ||
health = health - 1 | ||
end | ||
end | ||
end | ||
|
||
if health ~= prevHealth then | ||
SetEntityHealth(playerPed, health) | ||
end | ||
end) | ||
|
||
AddEventHandler("bpt_basicneeds:isEating", function(cb) | ||
cb(IsAnimated) | ||
end) | ||
|
||
RegisterNetEvent("bpt_basicneeds:onUse") | ||
AddEventHandler("bpt_basicneeds:onUse", function(type, prop_name, anim) | ||
if not IsAnimated then | ||
local anim = anim | ||
IsAnimated = true | ||
if type == "food" then | ||
prop_name = prop_name or "prop_cs_burger_01" | ||
anim = anim | ||
elseif type == "drink" then | ||
prop_name = prop_name or "prop_ld_flow_bottle" | ||
anim = anim | ||
end | ||
|
||
CreateThread(function() | ||
local playerPed = PlayerPedId() | ||
local x, y, z = table.unpack(GetEntityCoords(playerPed)) | ||
local prop = CreateObject(joaat(prop_name), x, y, z + 0.2, true, true, true) | ||
local boneIndex = GetPedBoneIndex(playerPed, 18905) | ||
AttachEntityToEntity(prop, playerPed, boneIndex, 0.12, 0.028, 0.001, 10.0, 175.0, 0.0, true, true, false, true, 1, true) | ||
|
||
ESX.Streaming.RequestAnimDict(anim.dict, function() | ||
TaskPlayAnim(playerPed, anim.dict, anim.name, anim.settings[1], anim.settings[2], anim.settings[3], anim.settings[4], anim.settings[5], anim.settings[6], anim.settings[7], anim.settings[8]) | ||
RemoveAnimDict(anim.dict) | ||
|
||
Wait(3000) | ||
IsAnimated = false | ||
ClearPedSecondaryTask(playerPed) | ||
DeleteObject(prop) | ||
end) | ||
end) | ||
end | ||
end) | ||
|
||
-- Backwards compatibility | ||
RegisterNetEvent("bpt_basicneeds:onEat") | ||
AddEventHandler("bpt_basicneeds:onEat", function(prop_name) | ||
local Invoke = GetInvokingResource() | ||
|
||
print(("[^3WARNING^7] ^5%s^7 used ^5bpt_basicneeds:onEat^7, this method is deprecated and should not be used! Refer to ^5https://bitpredator.github.io/bptdevelopment/docs/FiveM/bpt_basicneeds/events/oneat^7 for more info!"):format(Invoke)) | ||
|
||
if not prop_name then | ||
prop_name = "prop_cs_burger_01" | ||
end | ||
TriggerEvent("bpt_basicneeds:onUse", "food", prop_name) | ||
end) | ||
|
||
RegisterNetEvent("bpt_basicneeds:onDrink") | ||
AddEventHandler("bpt_basicneeds:onDrink", function(prop_name) | ||
local Invoke = GetInvokingResource() | ||
|
||
print(("[^3WARNING^7] ^5%s^7 used ^5bpt_basicneeds:onDrink^7, this method is deprecated and should not be used! Refer to ^5https://bitpredator.github.io/bptdevelopment/docs/FiveM/bpt_basicneeds/events/ondrink^7 for more info!"):format(Invoke)) | ||
|
||
if not prop_name then | ||
prop_name = "prop_ld_flow_bottle" | ||
end | ||
TriggerEvent("bpt_basicneeds:onUse", "drink", prop_name) | ||
end) |
21 changes: 21 additions & 0 deletions
21
server-data/resources/[bpt_addons]/bpt_basicneeds/config.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Config = {} | ||
Config.Locale = GetConvar("esx:locale", "en") | ||
Config.Visible = true | ||
|
||
Config.Items = { | ||
["bread"] = { | ||
type = "food", | ||
prop = "prop_cs_burger_01", | ||
status = 200000, | ||
remove = true, | ||
anim = { dict = "mp_player_inteat@burger", name = "mp_player_int_eat_burger_fp", settings = { 8.0, -8, -1, 49, 0, 0, 0, 0 } }, | ||
}, | ||
|
||
["water"] = { | ||
type = "drink", | ||
prop = "prop_ld_flow_bottle", | ||
status = 100000, | ||
remove = true, | ||
anim = { dict = "mp_player_intdrink", name = "loop_bottle", settings = { 1.0, -1.0, 2000, 0, 1, true, true, true } }, | ||
}, | ||
} |
28 changes: 28 additions & 0 deletions
28
server-data/resources/[bpt_addons]/bpt_basicneeds/fxmanifest.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
fx_version("adamant") | ||
|
||
game("gta5") | ||
|
||
description("Adds a Hunger & Thrist system") | ||
lua54("yes") | ||
version("1.0.1") | ||
|
||
shared_script("@es_extended/imports.lua") | ||
|
||
server_scripts({ | ||
"@es_extended/locale.lua", | ||
"locales/*.lua", | ||
"config.lua", | ||
"server/main.lua", | ||
}) | ||
|
||
client_scripts({ | ||
"@es_extended/locale.lua", | ||
"locales/*.lua", | ||
"config.lua", | ||
"client/main.lua", | ||
}) | ||
|
||
dependencies({ | ||
"es_extended", | ||
"bpt_status", | ||
}) |
5 changes: 5 additions & 0 deletions
5
server-data/resources/[bpt_addons]/bpt_basicneeds/locales/en.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Locales["en"] = { | ||
["used_food"] = "You have eaten 1x %s", | ||
["used_drink"] = "You have drinked 1x %s", | ||
["got_healed"] = "You have been healed.", | ||
} |
5 changes: 5 additions & 0 deletions
5
server-data/resources/[bpt_addons]/bpt_basicneeds/locales/it.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Locales["it"] = { | ||
["used_bread"] = "hai usato 1x panino", | ||
["used_water"] = "hai usato 1x acqua", | ||
["got_healed"] = "Sei stato curato.", | ||
} |
4 changes: 4 additions & 0 deletions
4
server-data/resources/[bpt_addons]/bpt_basicneeds/localization/it_bpt_basicneeds.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
INSERT INTO `items` (`name`, `label`, `weight`) VALUES | ||
('bread', 'Pane', 1), | ||
('water', 'Acqua', 1) | ||
; |
32 changes: 0 additions & 32 deletions
32
server-data/resources/[esx_addons]/esx_basicneeds/README.md
This file was deleted.
Oops, something went wrong.
72 changes: 0 additions & 72 deletions
72
server-data/resources/[esx_addons]/esx_basicneeds/client/main.lua
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.