mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-01 18:58:54 +00:00
Add files
This commit is contained in:
@@ -1,2 +1,18 @@
|
||||
# fxserver-esx_optionalneeds
|
||||
FXServer ESX Optional Needs
|
||||
|
||||
[REQUIREMENTS]
|
||||
- esx_status https://github.com/FXServer-ESX/fxserver-esx_status
|
||||
|
||||
[INSTALLATION]
|
||||
|
||||
1) CD in your resources/[esx] folder
|
||||
2) Clone the repository
|
||||
```
|
||||
git clone https://github.com/FXServer-ESX/fxserver-esx_optionalneeds esx_optionalneeds
|
||||
```
|
||||
3) Add this in your server.cfg :
|
||||
|
||||
```
|
||||
start esx_optionalneeds
|
||||
```
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'
|
||||
|
||||
description 'ESX Optional Needs'
|
||||
|
||||
server_scripts {
|
||||
'server/main.lua'
|
||||
}
|
||||
|
||||
client_scripts {
|
||||
'client/main.lua'
|
||||
}
|
||||
+165
@@ -0,0 +1,165 @@
|
||||
ESX = nil
|
||||
local IsAlreadyDrunk = false
|
||||
local DrunkLevel = -1
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while ESX == nil do
|
||||
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
|
||||
Citizen.Wait(0)
|
||||
end
|
||||
end)
|
||||
|
||||
function Drunk(level, start)
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
|
||||
local playerPed = GetPlayerPed(-1)
|
||||
|
||||
if start then
|
||||
DoScreenFadeOut(800)
|
||||
Wait(1000)
|
||||
end
|
||||
|
||||
if level == 0 then
|
||||
|
||||
RequestAnimSet("move_m@drunk@slightlydrunk")
|
||||
|
||||
while not HasAnimSetLoaded("move_m@drunk@slightlydrunk") do
|
||||
Citizen.Wait(0)
|
||||
end
|
||||
|
||||
SetPedMovementClipset(playerPed, "move_m@drunk@slightlydrunk", true)
|
||||
|
||||
elseif level == 1 then
|
||||
|
||||
RequestAnimSet("move_m@drunk@moderatedrunk")
|
||||
|
||||
while not HasAnimSetLoaded("move_m@drunk@moderatedrunk") do
|
||||
Citizen.Wait(0)
|
||||
end
|
||||
|
||||
SetPedMovementClipset(playerPed, "move_m@drunk@moderatedrunk", true)
|
||||
|
||||
elseif level == 2 then
|
||||
|
||||
RequestAnimSet("move_m@drunk@verydrunk")
|
||||
|
||||
while not HasAnimSetLoaded("move_m@drunk@verydrunk") do
|
||||
Citizen.Wait(0)
|
||||
end
|
||||
|
||||
SetPedMovementClipset(playerPed, "move_m@drunk@verydrunk", true)
|
||||
|
||||
end
|
||||
|
||||
SetTimecycleModifier("spectator5")
|
||||
SetPedMotionBlur(playerPed, true)
|
||||
SetPedIsDrunk(playerPed, true)
|
||||
|
||||
if start then
|
||||
DoScreenFadeIn(800)
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
function Reality()
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
|
||||
local playerPed = GetPlayerPed(-1)
|
||||
|
||||
DoScreenFadeOut(800)
|
||||
Wait(1000)
|
||||
|
||||
ClearTimecycleModifier()
|
||||
ResetScenarioTypesEnabled()
|
||||
ResetPedMovementClipset(playerPed, 0)
|
||||
SetPedIsDrunk(playerPed, false)
|
||||
SetPedMotionBlur(playerPed, false)
|
||||
|
||||
DoScreenFadeIn(800)
|
||||
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
AddEventHandler('esx_status:loaded', function(status)
|
||||
|
||||
TriggerEvent('esx_status:registerStatus', 'drunk', 0, '#8F15A5',
|
||||
function(status)
|
||||
if status.val > 0 then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end,
|
||||
function(status)
|
||||
status.remove(1500)
|
||||
end
|
||||
)
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
|
||||
while true do
|
||||
|
||||
Wait(1000)
|
||||
|
||||
TriggerEvent('esx_status:getStatus', 'drunk', function(status)
|
||||
|
||||
if status.val > 0 then
|
||||
|
||||
local start = true
|
||||
|
||||
if IsAlreadyDrunk then
|
||||
start = false
|
||||
end
|
||||
|
||||
local level = 0
|
||||
|
||||
if status.val <= 250000 then
|
||||
level = 0
|
||||
elseif status.val <= 500000 then
|
||||
level = 1
|
||||
else
|
||||
level = 2
|
||||
end
|
||||
|
||||
if level ~= DrunkLevel then
|
||||
Drunk(level, start)
|
||||
end
|
||||
|
||||
IsAlreadyDrunk = true
|
||||
DrunkLevel = level
|
||||
end
|
||||
|
||||
if status.val == 0 then
|
||||
|
||||
if IsAlreadyDrunk then
|
||||
Reality()
|
||||
end
|
||||
|
||||
IsAlreadyDrunk = false
|
||||
DrunkLevel = -1
|
||||
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx_optionalneeds:onDrink')
|
||||
AddEventHandler('esx_optionalneeds:onDrink', function()
|
||||
|
||||
local playerPed = GetPlayerPed(-1)
|
||||
|
||||
TaskStartScenarioInPlace(playerPed, "WORLD_HUMAN_DRINKING", 0, 1)
|
||||
Citizen.Wait(1000)
|
||||
ClearPedTasksImmediately(playerPed)
|
||||
|
||||
end)
|
||||
@@ -0,0 +1,4 @@
|
||||
Config = {}
|
||||
|
||||
Config.TickTime = 100
|
||||
Config.UpdateClientTime = 5000
|
||||
@@ -0,0 +1,17 @@
|
||||
ESX = nil
|
||||
|
||||
TriggerEvent('esx:getSharedObject', function(obj)
|
||||
ESX = obj
|
||||
end)
|
||||
|
||||
ESX.RegisterUsableItem('beer', function(source)
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
xPlayer.removeInventoryItem('beer', 1)
|
||||
|
||||
TriggerClientEvent('esx_status:add', source, 'drunk', 250000)
|
||||
TriggerClientEvent('esx_optionalneeds:onDrink', source)
|
||||
TriggerClientEvent('esx:showNotification', source, 'Vous avez utilisé 1x ~y~Bière~s~')
|
||||
|
||||
end)
|
||||
Reference in New Issue
Block a user