Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Drugs effects (coke-weed) and usable items #18

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
219 changes: 177 additions & 42 deletions client/main.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
local IsAlreadyDrunk = false
local DrunkLevel = -1
local IsAlreadyDrug = false
local DrugLevel = -1

function Drunk(level, start)

CreateThread(function()

local playerPed = PlayerPedId()

if start then
Expand All @@ -13,35 +13,29 @@ function Drunk(level, start)
end

if level == 0 then

RequestAnimSet("move_m@drunk@slightlydrunk")

while not HasAnimSetLoaded("move_m@drunk@slightlydrunk") do
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
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
Wait(0)
end

SetPedMovementClipset(playerPed, "move_m@drunk@verydrunk", true)

end

SetTimecycleModifier("spectator5")
Expand All @@ -51,15 +45,11 @@ function Drunk(level, start)
if start then
DoScreenFadeIn(800)
end

end)

end

function Reality()

CreateThread(function()

local playerPed = PlayerPedId()

DoScreenFadeOut(800)
Expand All @@ -72,14 +62,11 @@ function Reality()
SetPedMotionBlur(playerPed, false)

DoScreenFadeIn(800)

end)

end

AddEventHandler('esx_status:loaded', function(status)

TriggerEvent('esx_status:registerStatus', 'drunk', 0, '#8F15A5',
TriggerEvent('esx_status:registerStatus', 'drunk', 0, '#8F15A5',
function(status)
if status.val > 0 then
return true
Expand All @@ -92,16 +79,12 @@ AddEventHandler('esx_status:loaded', function(status)
end
)

CreateThread(function()

while true do

Wait(1000)
CreateThread(function()
while true do
Wait(1000)

TriggerEvent('esx_status:getStatus', 'drunk', function(status)

if status.val > 0 then

TriggerEvent('esx_status:getStatus', 'drunk', function(status)
if status.val > 0 then
local start = true

if IsAlreadyDrunk then
Expand All @@ -124,34 +107,186 @@ AddEventHandler('esx_status:loaded', function(status)

IsAlreadyDrunk = true
DrunkLevel = level
end
end

if status.val == 0 then

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 = PlayerPedId()

end
TaskStartScenarioInPlace(playerPed, "WORLD_HUMAN_DRINKING", 0, 1)
Wait(1000)
ClearPedTasksImmediately(playerPed)
end)

end)
------DRUGS---------
AddEventHandler('esx_status:loaded', function(status)
TriggerEvent('esx_status:registerStatus', 'drug', 0, '#9ec617',
function(status)
if status.val > 0 then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return status.val > 0

return false
else
return false
end
end, function(status)
status.remove(1500)
end)

CreateThread(function()
while true do
Wait(1000)

TriggerEvent('esx_status:getStatus', 'drug', function(status)
if status.val > 0 then
local start = true

end
if IsAlreadyDrug then
start = false
end

end)
local level = 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is local variable all time 0, you don't set any other value in code.


if status.val <= 950000 then
level = 0
else
overdose()
end

if level ~= DrugLevel then
end

IsAlreadyDrug = true
DrugLevel = level
end

if status.val == 0 then
if IsAlreadyDrug then
Normal()
end

IsAlreadyDrug = false
DrugLevel = -1
end
end)
end
end)
end)

RegisterNetEvent('esx_optionalneeds:onDrink')
AddEventHandler('esx_optionalneeds:onDrink', function()

local playerPed = PlayerPedId()

TaskStartScenarioInPlace(playerPed, "WORLD_HUMAN_DRINKING", 0, 1)
--When effects ends go back to normal
function Normal()
CreateThread(function()
local playerPed = PlayerPedId()

ClearTimecycleModifier()
ResetScenarioTypesEnabled()
ResetPedMovementClipset(playerPed, 0)
SetPedMotionBlur(playerPed, false)
end)
end

--In case too much drugs dies of overdose set everything back
function overdose()
CreateThread(function()
local playerPed = PlayerPedId()

SetEntityHealth(playerPed, 0)
ClearTimecycleModifier()
ResetScenarioTypesEnabled()
ResetPedMovementClipset(playerPed, 0)
SetPedMotionBlur(playerPed, false)
ESX.ShowNotification(TranslateCap('overdose'))
end)
end

-- Cocaine effect (Run really fast + paranoïa move + auto-jump)
RegisterNetEvent('esx_optionalneeds:runMan')
AddEventHandler('esx_optionalneeds:runMan', function()
RequestAnimSet("move_m@hurry_butch@b")
while not HasAnimSetLoaded("move_m@hurry_butch@b") do
Wait(0)
end
onDrugs = true
count = 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why global variable? You should change to local count.

DoScreenFadeOut(1000)
Wait(1000)
SetPedMotionBlur(PlayerPedId(), true)
SetTimecycleModifier("spectator5")
SetPedMovementClipset(PlayerPedId(), "move_m@hurry_butch@b", true)
SetRunSprintMultiplierForPlayer(PlayerId(), 1.2)
DoScreenFadeIn(1000)
repeat
ShakeGameplayCam('SMALL_EXPLOSION_SHAKE', 0.1)
TaskJump(PlayerPedId(), false, true, false)
Wait(20000)
count = count + 1
until count == 16
DoScreenFadeOut(1000)
Wait(1000)
DoScreenFadeIn(1000)
ClearTimecycleModifier()
ResetPedMovementClipset(PlayerPedId(), 0)
SetRunSprintMultiplierForPlayer(PlayerId(), 1.0)
ClearAllPedProps(PlayerPedId(), true)
SetPedMotionBlur(PlayerPedId(), false)
ESX.ShowNotification(TranslateCap('effects_disapear'))
onDrugs = false
end)

--- Weed effect (sprint speed reduced)

RegisterNetEvent('esx_optionalneeds:onWeed')
AddEventHandler('esx_optionalneeds:onWeed', function()
local playerPed = PlayerPedId()

RequestAnimSet("move_m@hipster@a")
while not HasAnimSetLoaded("move_m@hipster@a") do
Wait(0)
end

TaskStartScenarioInPlace(playerPed, "WORLD_HUMAN_SMOKING_POT", 0, 1)
Wait(3000)
ClearPedTasksImmediately(playerPed)
SetTimecycleModifier("spectator5")
SetPedMotionBlur(playerPed, true)
SetPedMovementClipset(playerPed, "move_m@hipster@a", true)

--Effects
local player = PlayerId()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line move to 252 row please.

SetRunSprintMultiplierForPlayer(player, 0.7)

Wait(300000)

SetRunSprintMultiplierForPlayer(player, 1.0)
end)

-- Useitem thread
RegisterNetEvent('esx_optionalneeds:useItemCoke')
AddEventHandler('esx_optionalneeds:useItemCoke', function()
--local lib, anim = 'anim@amb@nightclub@peds@', 'missfbi3_party_snort_coke_b_male3' -- Play animation sitting and snorting
local lib, anim = 'anim@mp_player_intcelebrationmale@face_palm', 'face_palm'
local playerPed = PlayerPedId()
ESX.ShowNotification(TranslateCap('drugs_taken'))
ESX.Streaming.RequestAnimDict(lib, function()
TaskPlayAnim(playerPed, lib, anim, 8.0, -8.0, -1, 32, 0, false, false, false)

Wait(500)
while IsEntityPlayingAnim(playerPed, lib, anim, 3) do
Wait(0)
DisableAllControlActions(0)
end

end)
TriggerEvent('esx_optionalneeds:runMan')
end)
end)
9 changes: 8 additions & 1 deletion locales/en.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
Locales['en'] = {

['used_beer'] = 'you used 1x Beer',
['used_one_coke'] = 'you used 1x Coke Pooch',
['used_one_weed'] = 'you used 1x Weed',

['overdosed'] = "you do an ~r~overdose",
['effects_disapear'] = "The effects are starting to wear off...",
['drugs_taken'] = "You feel the drug rising in your brain and taking effect...",


}
}
8 changes: 7 additions & 1 deletion locales/fr.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
Locales['fr'] = {

['used_beer'] = 'vous avez utilisé 1x Bière',
['used_one_coke'] = 'vous avez utilisé 1x pochon de coke',
['used_one_weed'] = 'vous avez utilisé 1x Weed',

['overdosed'] = "vous avez fait une ~r~overdose",
['effects_disapear'] = "Les effets commencent à se dissiper...",
['drugs_taken'] = "Tu sens la drogue monter dans ton cerveau et faire son effet...",

}
}
22 changes: 22 additions & 0 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,25 @@ ESX.RegisterUsableItem('beer', function(source)
TriggerClientEvent('esx:showNotification', source, TranslateCap('used_beer'))

end)

---Drugs Items
ESX.RegisterUsableItem('coke_pooch', function(source)

local xPlayer = ESX.GetPlayerFromId(source)

xPlayer.removeInventoryItem('coke_pooch', 1)

TriggerClientEvent('esx_status:add', source, 'drug', 499000)
TriggerClientEvent('esx_optionalneeds:useItemCoke', source)
TriggerClientEvent('esx:showNotification', source, TranslateCap('used_one_coke'))
end)

ESX.RegisterUsableItem('weed', function(source)
local xPlayer = ESX.GetPlayerFromId(source)

xPlayer.removeInventoryItem('weed', 1)

TriggerClientEvent('esx_status:add', source, 'drug', 166000)
TriggerClientEvent('esx_optionalneeds:onWeed', source)
TriggerClientEvent('esx:showNotification', source, TranslateCap('used_one_weed'))
end)