753 lines
		
	
	
	
		
			26 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
			
		
		
	
	
			753 lines
		
	
	
	
		
			26 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
DrugsCreator.allEffects = {}
 | 
						|
DrugsCreator.activeEffects = {}
 | 
						|
 | 
						|
local function startTimecycle(timecycleName, maxTimecycleStrenght)
 | 
						|
    maxTimecycleStrenght = maxTimecycleStrenght or 1.0
 | 
						|
 | 
						|
    local time = 10000 -- Time to reach max strenght
 | 
						|
    local interval = 100 -- Strenght increases each interval
 | 
						|
 | 
						|
    local streghtToAddEachInterval = maxTimecycleStrenght / (time/interval)
 | 
						|
 | 
						|
    local timecycleStrength = 0.0
 | 
						|
 | 
						|
    SetTimecycleModifier(timecycleName)
 | 
						|
    
 | 
						|
    while time >= 0 do
 | 
						|
        SetTimecycleModifierStrength(timecycleStrength)
 | 
						|
        Citizen.Wait(interval)
 | 
						|
        time = time - interval
 | 
						|
 | 
						|
        timecycleStrength = timecycleStrength + streghtToAddEachInterval
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
local function startShakingGameplayCam(shakeName, maxAmplitude)
 | 
						|
    local time = 10000
 | 
						|
    local interval = 100
 | 
						|
 | 
						|
    local streghtToAddEachInterval = maxAmplitude / (time/interval)
 | 
						|
 | 
						|
    local amplitude = 0.0
 | 
						|
    ShakeGameplayCam(shakeName, amplitude)
 | 
						|
 | 
						|
    while time >= 0 do
 | 
						|
        SetGameplayCamShakeAmplitude(amplitude)
 | 
						|
 | 
						|
        Citizen.Wait(interval)
 | 
						|
        time = time - interval
 | 
						|
 | 
						|
        amplitude = amplitude + streghtToAddEachInterval
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
DrugsCreator.allEffects.pink_visual = function(duration)
 | 
						|
    local effectName = "visual_color"
 | 
						|
    
 | 
						|
    if(not DrugsCreator.activeEffects[effectName]) then
 | 
						|
        DrugsCreator.activeEffects[effectName] = duration
 | 
						|
 | 
						|
        local timer = 0
 | 
						|
 | 
						|
        local currentTimecycle = GetTimecycleModifierIndex()
 | 
						|
 | 
						|
        local timecycleName = "drug_flying_02"
 | 
						|
        local timecycleStrenght = 1.0
 | 
						|
 | 
						|
        startTimecycle(timecycleName, timecycleStrenght)
 | 
						|
 | 
						|
        while timer <= DrugsCreator.activeEffects[effectName] do
 | 
						|
            if(GetTimecycleModifierIndex() == -1 or GetTimecycleModifierIndex() == currentTimecycle) then
 | 
						|
                SetTimecycleModifier(timecycleName)
 | 
						|
                SetTimecycleModifierStrength(timecycleStrenght)
 | 
						|
            end
 | 
						|
            
 | 
						|
            Citizen.Wait(1000)
 | 
						|
            timer = timer + 1000
 | 
						|
        end
 | 
						|
 | 
						|
        ClearTimecycleModifier()
 | 
						|
        DrugsCreator.activeEffects[effectName] = false
 | 
						|
    else
 | 
						|
        DrugsCreator.activeEffects[effectName] = DrugsCreator.activeEffects[effectName] + duration
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
DrugsCreator.allEffects.visual_shaking = function(duration) 
 | 
						|
    local effectName = "visual_shaking"
 | 
						|
 | 
						|
    if(not DrugsCreator.activeEffects[effectName]) then
 | 
						|
        DrugsCreator.activeEffects[effectName] = duration
 | 
						|
 | 
						|
        local shakeName = "FAMILY5_DRUG_TRIP_SHAKE"
 | 
						|
        local shakeStrenght = 0.6
 | 
						|
 | 
						|
        startShakingGameplayCam(shakeName, shakeStrenght)
 | 
						|
 | 
						|
        local timer = 0
 | 
						|
 | 
						|
        while timer <= DrugsCreator.activeEffects[effectName] do
 | 
						|
            if(not IsGameplayCamShaking()) then
 | 
						|
                ShakeGameplayCam(shakeName, shakeStrenght)
 | 
						|
            end
 | 
						|
 | 
						|
            Citizen.Wait(1000)
 | 
						|
            timer = timer + 1000
 | 
						|
        end
 | 
						|
 | 
						|
        StopGameplayCamShaking()
 | 
						|
        DrugsCreator.activeEffects[effectName] = false
 | 
						|
    else
 | 
						|
        DrugsCreator.activeEffects[effectName] = DrugsCreator.activeEffects[effectName] + duration
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
DrugsCreator.allEffects.drunk_walk = function(duration) 
 | 
						|
    local effectName = "drunk_walk"
 | 
						|
    if(not DrugsCreator.activeEffects[effectName]) then
 | 
						|
        DrugsCreator.activeEffects[effectName] = duration
 | 
						|
 | 
						|
        local plyPed = PlayerPedId()
 | 
						|
 | 
						|
        local timer = 0
 | 
						|
 | 
						|
        local animSet = "move_m@drunk@moderatedrunk"
 | 
						|
        local transitionSpeed = 5.0
 | 
						|
 | 
						|
        RequestAnimSet(animSet)
 | 
						|
 | 
						|
        while not HasAnimSetLoaded(animSet) do
 | 
						|
            Citizen.Wait(0)
 | 
						|
        end
 | 
						|
        
 | 
						|
        while timer <= DrugsCreator.activeEffects[effectName] do
 | 
						|
            SetPedMovementClipset(plyPed, animSet, transitionSpeed)
 | 
						|
 | 
						|
            Citizen.Wait(1000)
 | 
						|
            timer = timer + 1000
 | 
						|
        end
 | 
						|
 | 
						|
        ResetPedMovementClipset(plyPed, transitionSpeed)
 | 
						|
        DrugsCreator.activeEffects[effectName] = false
 | 
						|
    else
 | 
						|
        DrugsCreator.activeEffects[effectName] = DrugsCreator.activeEffects[effectName] + duration
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
DrugsCreator.allEffects.green_visual = function(duration)
 | 
						|
    local effectName = "visual_color"
 | 
						|
 | 
						|
    if(not DrugsCreator.activeEffects[effectName]) then
 | 
						|
        DrugsCreator.activeEffects[effectName] = duration
 | 
						|
 | 
						|
        local timer = 0
 | 
						|
 | 
						|
        local currentTimecycle = GetTimecycleModifierIndex()
 | 
						|
        
 | 
						|
        local timecycleName = "stoned"
 | 
						|
        local timecycleStrenght = 0.54
 | 
						|
 | 
						|
        startTimecycle(timecycleName, timecycleStrenght)
 | 
						|
 | 
						|
        while timer <= DrugsCreator.activeEffects[effectName] do
 | 
						|
            if(GetTimecycleModifierIndex() == -1 or GetTimecycleModifierIndex() == currentTimecycle) then
 | 
						|
                SetTimecycleModifier(timecycleName)
 | 
						|
                SetTimecycleModifierStrength(timecycleStrenght)
 | 
						|
            end
 | 
						|
            
 | 
						|
            Citizen.Wait(1000)
 | 
						|
            timer = timer + 1000
 | 
						|
        end
 | 
						|
 | 
						|
        ClearTimecycleModifier()
 | 
						|
        DrugsCreator.activeEffects[effectName] = false
 | 
						|
    else
 | 
						|
        DrugsCreator.activeEffects[effectName] = DrugsCreator.activeEffects[effectName] + duration
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
DrugsCreator.allEffects.confused_visual = function(duration)
 | 
						|
    local effectName = "visual_color"
 | 
						|
 | 
						|
    if(not DrugsCreator.activeEffects[effectName]) then
 | 
						|
        DrugsCreator.activeEffects[effectName] = duration
 | 
						|
 | 
						|
        local timer = 0
 | 
						|
 | 
						|
        local currentTimecycle = GetTimecycleModifierIndex()
 | 
						|
 | 
						|
        local timecycleName = "drug_wobbly"
 | 
						|
        local timecycleStrenght = 1.0
 | 
						|
 | 
						|
        startTimecycle(timecycleName, timecycleStrenght)
 | 
						|
 | 
						|
        while timer <= DrugsCreator.activeEffects[effectName] do
 | 
						|
            if(GetTimecycleModifierIndex() == -1 or GetTimecycleModifierIndex() == currentTimecycle) then
 | 
						|
                SetTimecycleModifier(timecycleName)
 | 
						|
                SetTimecycleModifierStrength(timecycleStrenght)
 | 
						|
            end
 | 
						|
            
 | 
						|
            Citizen.Wait(1000)
 | 
						|
            timer = timer + 1000
 | 
						|
        end
 | 
						|
 | 
						|
        ClearTimecycleModifier()
 | 
						|
        DrugsCreator.activeEffects[effectName] = false
 | 
						|
    else
 | 
						|
        DrugsCreator.activeEffects[effectName] = DrugsCreator.activeEffects[effectName] + duration
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
 | 
						|
DrugsCreator.allEffects.yellow_visual = function(duration)
 | 
						|
    local effectName = "visual_color"
 | 
						|
 | 
						|
    if(not DrugsCreator.activeEffects[effectName]) then
 | 
						|
        DrugsCreator.activeEffects[effectName] = duration
 | 
						|
 | 
						|
        local timer = 0
 | 
						|
 | 
						|
        local currentTimecycle = GetTimecycleModifierIndex()
 | 
						|
 | 
						|
        local timecycleName = "BeastIntro01"
 | 
						|
        local timecycleStrenght = 1.0
 | 
						|
 | 
						|
        startTimecycle(timecycleName, timecycleStrenght)
 | 
						|
 | 
						|
        while timer <= DrugsCreator.activeEffects[effectName] do
 | 
						|
            if(GetTimecycleModifierIndex() == -1 or GetTimecycleModifierIndex() == currentTimecycle) then
 | 
						|
                SetTimecycleModifier(timecycleName)
 | 
						|
                SetTimecycleModifierStrength(timecycleStrenght)
 | 
						|
            end
 | 
						|
            
 | 
						|
            Citizen.Wait(1000)
 | 
						|
            timer = timer + 1000
 | 
						|
        end
 | 
						|
 | 
						|
        ClearTimecycleModifier()
 | 
						|
        DrugsCreator.activeEffects[effectName] = false
 | 
						|
    else
 | 
						|
        DrugsCreator.activeEffects[effectName] = DrugsCreator.activeEffects[effectName] + duration
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
DrugsCreator.allEffects.blurred_visual = function(duration)
 | 
						|
    local effectName = "visual_color"
 | 
						|
 | 
						|
    if(not DrugsCreator.activeEffects[effectName]) then
 | 
						|
        DrugsCreator.activeEffects[effectName] = duration
 | 
						|
 | 
						|
        local timer = 0
 | 
						|
 | 
						|
        local currentTimecycle = GetTimecycleModifierIndex()
 | 
						|
 | 
						|
        local timecycleName = "BlackOut"
 | 
						|
        local timecycleStrenght = 0.84
 | 
						|
 | 
						|
        startTimecycle(timecycleName, timecycleStrenght)
 | 
						|
 | 
						|
        while timer <= DrugsCreator.activeEffects[effectName] do
 | 
						|
            if(GetTimecycleModifierIndex() == -1 or GetTimecycleModifierIndex() == currentTimecycle) then
 | 
						|
                SetTimecycleModifier(timecycleName)
 | 
						|
                SetTimecycleModifierStrength(timecycleStrenght)
 | 
						|
            end
 | 
						|
            
 | 
						|
            Citizen.Wait(1000)
 | 
						|
            timer = timer + 1000
 | 
						|
        end
 | 
						|
 | 
						|
        ClearTimecycleModifier()
 | 
						|
        DrugsCreator.activeEffects[effectName] = false
 | 
						|
    else
 | 
						|
        DrugsCreator.activeEffects[effectName] = DrugsCreator.activeEffects[effectName] + duration
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
DrugsCreator.allEffects.red_visual = function(duration)
 | 
						|
    local effectName = "visual_color"
 | 
						|
 | 
						|
    if(not DrugsCreator.activeEffects[effectName]) then
 | 
						|
        DrugsCreator.activeEffects[effectName] = duration
 | 
						|
 | 
						|
        local timer = 0
 | 
						|
 | 
						|
        local currentTimecycle = GetTimecycleModifierIndex()
 | 
						|
 | 
						|
        local timecycleName = "damage"
 | 
						|
        local timecycleStrenght = 2.16
 | 
						|
 | 
						|
        startTimecycle(timecycleName, timecycleStrenght)
 | 
						|
 | 
						|
        while timer <= DrugsCreator.activeEffects[effectName] do
 | 
						|
            if(GetTimecycleModifierIndex() == -1 or GetTimecycleModifierIndex() == currentTimecycle) then
 | 
						|
                SetTimecycleModifier(timecycleName)
 | 
						|
                SetTimecycleModifierStrength(timecycleStrenght)
 | 
						|
            end
 | 
						|
            
 | 
						|
            Citizen.Wait(1000)
 | 
						|
            timer = timer + 1000
 | 
						|
        end
 | 
						|
 | 
						|
        ClearTimecycleModifier()
 | 
						|
        DrugsCreator.activeEffects[effectName] = false
 | 
						|
    else
 | 
						|
        DrugsCreator.activeEffects[effectName] = DrugsCreator.activeEffects[effectName] + duration
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
DrugsCreator.allEffects.foggy_visual = function(duration)
 | 
						|
    local effectName = "visual_color"
 | 
						|
 | 
						|
    if(not DrugsCreator.activeEffects[effectName]) then
 | 
						|
        DrugsCreator.activeEffects[effectName] = duration
 | 
						|
 | 
						|
        local timer = 0
 | 
						|
 | 
						|
        local currentTimecycle = GetTimecycleModifierIndex()
 | 
						|
 | 
						|
        local timecycleName = "graveyard_shootout"
 | 
						|
        local timecycleStrenght = 0.48
 | 
						|
 | 
						|
        startTimecycle(timecycleName, timecycleStrenght)
 | 
						|
 | 
						|
        while timer <= DrugsCreator.activeEffects[effectName] do
 | 
						|
            if(GetTimecycleModifierIndex() == -1 or GetTimecycleModifierIndex() == currentTimecycle) then
 | 
						|
                SetTimecycleModifier(timecycleName)
 | 
						|
                SetTimecycleModifierStrength(timecycleStrenght)
 | 
						|
            end
 | 
						|
            
 | 
						|
            Citizen.Wait(1000)
 | 
						|
            timer = timer + 1000
 | 
						|
        end
 | 
						|
 | 
						|
        ClearTimecycleModifier()
 | 
						|
        DrugsCreator.activeEffects[effectName] = false
 | 
						|
    else
 | 
						|
        DrugsCreator.activeEffects[effectName] = DrugsCreator.activeEffects[effectName] + duration
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
DrugsCreator.allEffects.blue_visual = function(duration)
 | 
						|
    local effectName = "visual_color"
 | 
						|
 | 
						|
    if(not DrugsCreator.activeEffects[effectName]) then
 | 
						|
        DrugsCreator.activeEffects[effectName] = duration
 | 
						|
 | 
						|
        local timer = 0
 | 
						|
 | 
						|
        local currentTimecycle = GetTimecycleModifierIndex()
 | 
						|
 | 
						|
        local timecycleName = "MichaelColorCodeBright"
 | 
						|
        local timecycleStrenght = 1.04
 | 
						|
 | 
						|
        startTimecycle(timecycleName, timecycleStrenght)
 | 
						|
 | 
						|
        while timer <= DrugsCreator.activeEffects[effectName] do
 | 
						|
            if(GetTimecycleModifierIndex() == -1 or GetTimecycleModifierIndex() == currentTimecycle) then
 | 
						|
                SetTimecycleModifier(timecycleName)
 | 
						|
                SetTimecycleModifierStrength(timecycleStrenght)
 | 
						|
            end
 | 
						|
            
 | 
						|
            Citizen.Wait(1000)
 | 
						|
            timer = timer + 1000
 | 
						|
        end
 | 
						|
 | 
						|
        ClearTimecycleModifier()
 | 
						|
        DrugsCreator.activeEffects[effectName] = false
 | 
						|
    else
 | 
						|
        DrugsCreator.activeEffects[effectName] = DrugsCreator.activeEffects[effectName] + duration
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
DrugsCreator.allEffects.armor50 = function()
 | 
						|
    AddArmourToPed(PlayerPedId(), 50)
 | 
						|
end
 | 
						|
 | 
						|
DrugsCreator.allEffects.armor100 = function()
 | 
						|
    AddArmourToPed(PlayerPedId(), 100)
 | 
						|
end
 | 
						|
 | 
						|
DrugsCreator.allEffects.health50 = function()
 | 
						|
    local plyPed = PlayerPedId()
 | 
						|
    local currentHealth = GetEntityHealth(plyPed)
 | 
						|
 | 
						|
    local newHealth = currentHealth + 50
 | 
						|
 | 
						|
    local maxHealth = GetEntityMaxHealth(plyPed)
 | 
						|
 | 
						|
    if(newHealth > maxHealth) then
 | 
						|
        SetEntityHealth(plyPed, maxHealth)
 | 
						|
    else
 | 
						|
        SetEntityHealth(plyPed, newHealth)
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
DrugsCreator.allEffects.health100 = function()
 | 
						|
    local plyPed = PlayerPedId()
 | 
						|
 | 
						|
    local maxHealth = GetEntityMaxHealth(plyPed)
 | 
						|
    SetEntityHealth(plyPed, maxHealth)
 | 
						|
end
 | 
						|
 | 
						|
DrugsCreator.allEffects.sprint_faster = function(duration)
 | 
						|
    local effectName = "sprint_faster"
 | 
						|
 | 
						|
    if(not DrugsCreator.activeEffects[effectName]) then
 | 
						|
        DrugsCreator.activeEffects[effectName] = duration
 | 
						|
 | 
						|
        local ply = PlayerId()
 | 
						|
 | 
						|
        local timer = 0
 | 
						|
 | 
						|
        while timer <= DrugsCreator.activeEffects[effectName] do
 | 
						|
            SetRunSprintMultiplierForPlayer(ply, 1.3) -- About 1.49 doesn't work at all
 | 
						|
            
 | 
						|
            Citizen.Wait(1000)
 | 
						|
            timer = timer + 1000
 | 
						|
        end
 | 
						|
 | 
						|
        SetRunSprintMultiplierForPlayer(ply, 1.0)
 | 
						|
        DrugsCreator.activeEffects[effectName] = false
 | 
						|
    else
 | 
						|
        DrugsCreator.activeEffects[effectName] = DrugsCreator.activeEffects[effectName] + duration
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
DrugsCreator.allEffects.swim_faster = function(duration)
 | 
						|
    local effectName = "swim_faster"
 | 
						|
 | 
						|
    if(not DrugsCreator.activeEffects[effectName]) then
 | 
						|
        DrugsCreator.activeEffects[effectName] = duration
 | 
						|
 | 
						|
        local ply = PlayerId()
 | 
						|
 | 
						|
        local timer = 0
 | 
						|
 | 
						|
        while timer <= DrugsCreator.activeEffects[effectName] do
 | 
						|
            SetSwimMultiplierForPlayer(ply, 1.3)
 | 
						|
            
 | 
						|
            Citizen.Wait(1000)
 | 
						|
            timer = timer + 1000
 | 
						|
        end
 | 
						|
 | 
						|
        SetSwimMultiplierForPlayer(ply, 1.0)
 | 
						|
        DrugsCreator.activeEffects[effectName] = false
 | 
						|
    else
 | 
						|
        DrugsCreator.activeEffects[effectName] = DrugsCreator.activeEffects[effectName] + duration
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
DrugsCreator.allEffects.fall = function(duration)
 | 
						|
    local effectName = "fall"
 | 
						|
 | 
						|
    if(not DrugsCreator.activeEffects[effectName]) then
 | 
						|
        DrugsCreator.activeEffects[effectName] = duration
 | 
						|
 | 
						|
        local plyPed = PlayerPedId()
 | 
						|
 | 
						|
        local timer = 0
 | 
						|
 | 
						|
        while timer <= DrugsCreator.activeEffects[effectName] do
 | 
						|
            local randomNumber = math.random(1, 3)
 | 
						|
 | 
						|
            if(randomNumber == 1) then
 | 
						|
                SetPedToRagdollWithFall(plyPed, 1500, 2000, 1, GetEntityForwardVector(plyPed), 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
 | 
						|
            end
 | 
						|
            
 | 
						|
            Citizen.Wait(5000)
 | 
						|
            timer = timer + 5000
 | 
						|
        end
 | 
						|
 | 
						|
        DrugsCreator.activeEffects[effectName] = false
 | 
						|
    else
 | 
						|
        DrugsCreator.activeEffects[effectName] = DrugsCreator.activeEffects[effectName] + duration
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
DrugsCreator.allEffects.infinite_stamina = function(duration)
 | 
						|
    local effectName = "infinite_stamina"
 | 
						|
 | 
						|
    if(not DrugsCreator.activeEffects[effectName]) then
 | 
						|
        DrugsCreator.activeEffects[effectName] = duration
 | 
						|
 | 
						|
        local ply = PlayerId()
 | 
						|
 | 
						|
        local timer = 0
 | 
						|
 | 
						|
        while timer <= DrugsCreator.activeEffects[effectName] do
 | 
						|
            ResetPlayerStamina(ply)
 | 
						|
            
 | 
						|
            Citizen.Wait(1000)
 | 
						|
            timer = timer + 1000
 | 
						|
        end
 | 
						|
 | 
						|
        DrugsCreator.activeEffects[effectName] = false
 | 
						|
    else
 | 
						|
        DrugsCreator.activeEffects[effectName] = DrugsCreator.activeEffects[effectName] + duration
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
DrugsCreator.allEffects.remove_old_effects = function()
 | 
						|
    for effectName, effectTime in pairs(DrugsCreator.activeEffects) do
 | 
						|
        if(effectTime) then
 | 
						|
            DrugsCreator.activeEffects[effectName] = 0
 | 
						|
        end
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
local function assumeDrug(type)
 | 
						|
    local plyPed = PlayerPedId()
 | 
						|
 | 
						|
    if(type == "pill") then
 | 
						|
        local animDict = "mp_suicide"
 | 
						|
        local anim = "pill"
 | 
						|
 | 
						|
        RequestAnimDict(animDict)
 | 
						|
 | 
						|
        while not HasAnimDictLoaded(animDict) do
 | 
						|
            Citizen.Wait(0)
 | 
						|
        end
 | 
						|
 | 
						|
        local animDuration = 3200
 | 
						|
 | 
						|
        TaskPlayAnim(plyPed, animDict, anim, 4.0, 4.0, animDuration, 49, 0.0, 0, 0, 0)
 | 
						|
 | 
						|
        Citizen.Wait(animDuration)
 | 
						|
    elseif(type == "drink") then
 | 
						|
        if(IsPedInAnyVehicle(plyPed, false)) then return end
 | 
						|
 | 
						|
        TaskStartScenarioInPlace(plyPed, "world_human_drinking", 0, true)
 | 
						|
 | 
						|
        Citizen.Wait(10000)
 | 
						|
 | 
						|
        ClearPedTasks(plyPed)
 | 
						|
    elseif(type == "drink_soda") then
 | 
						|
        if(IsPedInAnyVehicle(plyPed, false)) then return end
 | 
						|
 | 
						|
        local animDict = "amb@world_human_drinking@beer@male@idle_a"
 | 
						|
        local animName = "idle_c"
 | 
						|
        Utils.loadAnimDict(animDict)
 | 
						|
 | 
						|
        local objectModel = DRINK_SODA_MODEL
 | 
						|
        Utils.loadModel(objectModel, 10)
 | 
						|
 | 
						|
        local object = CreateObject(objectModel, GetEntityCoords(plyPed), true, false, false)
 | 
						|
        TaskPlayAnim(plyPed, animDict, animName, 8.0, 8.0, 10000, 16, 0.0, false, 0, false)
 | 
						|
 | 
						|
        AttachEntityToEntity(object, plyPed, 91, 0.13620177363839, 0.051340419212092, -0.032412815738839, -78.198566893409, 0, 0, true, true, false, true, 1, true)
 | 
						|
        
 | 
						|
        Citizen.Wait(10000)
 | 
						|
 | 
						|
        DetachEntity(object, false, true)
 | 
						|
        DeleteObject(object)
 | 
						|
        ClearPedTasks(plyPed)
 | 
						|
    elseif(type == "smoke") then
 | 
						|
        if(IsPedInAnyVehicle(plyPed, false)) then return end
 | 
						|
 | 
						|
        TaskStartScenarioInPlace(plyPed, "WORLD_HUMAN_SMOKING_POT", 0, true)
 | 
						|
 | 
						|
        Citizen.Wait(10000)
 | 
						|
 | 
						|
        ClearPedTasks(plyPed)
 | 
						|
    elseif(type == "snort") then
 | 
						|
        if(IsPedInAnyVehicle(plyPed, false)) then return end
 | 
						|
 | 
						|
        local animDict = 'missfbi3_party'
 | 
						|
        local animName = 'snort_coke_b_male3'
 | 
						|
        Utils.loadAnimDict(animDict)
 | 
						|
        TaskPlayAnim(plyPed, animDict, animName, 8.0, 8.0, 7000, 16, 0.22, false, 0, false)
 | 
						|
 | 
						|
        Citizen.Wait(7000)
 | 
						|
 | 
						|
        ClearPedTasks(plyPed)
 | 
						|
    elseif(type == "needle") then
 | 
						|
        local syringeProp = GetHashKey('prop_syringe_01')
 | 
						|
        local syringeDict = "rcmpaparazzo1ig_4"
 | 
						|
        local syringeAnim = "miranda_shooting_up"
 | 
						|
        local syringeBone = 28422
 | 
						|
        local syringeOffset = vector3(0, 0, -0.045)
 | 
						|
        local syringeRot = vector3(0, 0, 0)
 | 
						|
 | 
						|
        RequestAnimDict(syringeDict)
 | 
						|
        while not HasAnimDictLoaded(syringeDict) do
 | 
						|
            Citizen.Wait(150)
 | 
						|
        end
 | 
						|
 | 
						|
        RequestModel(syringeProp)
 | 
						|
        while not HasModelLoaded(syringeProp) do
 | 
						|
            Citizen.Wait(150)
 | 
						|
        end
 | 
						|
 | 
						|
        local syringeObj = CreateObject(syringeProp, 0.0, 0.0, 0.0, true, true, false)
 | 
						|
        local syringeBoneIndex = GetPedBoneIndex(plyPed, syringeBone)
 | 
						|
 | 
						|
        SetCurrentPedWeapon(plyPed, "weapon_unarmed", true)
 | 
						|
        AttachEntityToEntity(syringeObj, plyPed, syringeBoneIndex, syringeOffset.x, syringeOffset.y, syringeOffset.z, syringeRot.x, syringeRot.y, syringeRot.z, false, false, false, false, 2, true)
 | 
						|
        SetModelAsNoLongerNeeded(syringeProp)
 | 
						|
 | 
						|
        local pos = GetEntityCoords(plyPed)
 | 
						|
        local he = GetEntityHeading(plyPed)
 | 
						|
 | 
						|
        TaskPlayAnim(plyPed, syringeDict, syringeAnim, 8.0, 8.0, 6000, 49, 0, 0, 0, 0)
 | 
						|
 | 
						|
        RemoveAnimDict(syringeDict)
 | 
						|
 | 
						|
        Citizen.Wait(1)
 | 
						|
        SetEntityAnimCurrentTime(plyPed, syringeDict, syringeAnim, 0.55)
 | 
						|
 | 
						|
        while(IsEntityPlayingAnim(plyPed, syringeDict, syringeAnim, 3)) do
 | 
						|
            Citizen.Wait(0)
 | 
						|
            DisableControlAction(0,21,true) -- no sprint
 | 
						|
            DisableControlAction(0,24,true) -- no attack
 | 
						|
            DisableControlAction(0,25,true) -- no aim
 | 
						|
            DisableControlAction(0,47,true) -- no weapon
 | 
						|
            DisableControlAction(0,58,true) -- no weapon
 | 
						|
            DisableControlAction(0,263,true) -- no melee
 | 
						|
            DisableControlAction(0,264,true) -- no melee
 | 
						|
            DisableControlAction(0,257,true) -- no melee
 | 
						|
            DisableControlAction(0,140,true) -- no melee
 | 
						|
            DisableControlAction(0,141,true) -- no melee
 | 
						|
            DisableControlAction(0,142,true) -- no melee
 | 
						|
            DisableControlAction(0,143,true) -- no melee
 | 
						|
            DisableControlAction(0,37,true) -- no weapon select
 | 
						|
            DisableControlAction(0,22,true) -- no jump
 | 
						|
        end
 | 
						|
 | 
						|
        SetEntityAsMissionEntity(syringeObj, false, false)
 | 
						|
        DeleteObject(syringeObj)
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
local function processCumulativeEffects(cumulativeEffects)
 | 
						|
    if not cumulativeEffects then return end
 | 
						|
    
 | 
						|
    for i = 1, #cumulativeEffects do
 | 
						|
        local effect = cumulativeEffects[i]
 | 
						|
 | 
						|
        local actionKey = effect.action .. effect.type:gsub("^%l", string.upper) -- Merge action + type ex. "increaseArmor"
 | 
						|
        local event = CUMULATIVE_EFFECTS_EVENTS[actionKey]
 | 
						|
 | 
						|
        if event then
 | 
						|
            TriggerEvent(event, effect.amount)
 | 
						|
        end
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
local function drugEffects(type, effects, duration, cumulativeEffects)
 | 
						|
    assumeDrug(type)
 | 
						|
    processCumulativeEffects(cumulativeEffects)
 | 
						|
 | 
						|
    duration = duration * 1000
 | 
						|
    for k, effect in pairs(effects) do
 | 
						|
        Citizen.CreateThread(function() 
 | 
						|
            DrugsCreator.allEffects[effect](duration)
 | 
						|
        end)
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
RegisterNetEvent(Utils.eventsPrefix .. ':drugEffects', drugEffects)
 | 
						|
 | 
						|
--[[
 | 
						|
 ██████ ██    ██ ███    ███ ██    ██ ██       █████  ████████ ██ ██    ██ ███████     ███████ ███████ ███████ ███████  ██████ ████████ ███████ 
 | 
						|
██      ██    ██ ████  ████ ██    ██ ██      ██   ██    ██    ██ ██    ██ ██          ██      ██      ██      ██      ██         ██    ██      
 | 
						|
██      ██    ██ ██ ████ ██ ██    ██ ██      ███████    ██    ██ ██    ██ █████       █████   █████   █████   █████   ██         ██    ███████ 
 | 
						|
██      ██    ██ ██  ██  ██ ██    ██ ██      ██   ██    ██    ██  ██  ██  ██          ██      ██      ██      ██      ██         ██         ██ 
 | 
						|
 ██████  ██████  ██      ██  ██████  ███████ ██   ██    ██    ██   ████   ███████     ███████ ██      ██      ███████  ██████    ██    ███████ 
 | 
						|
]]
 | 
						|
 | 
						|
local fw = Framework.getFramework() -- 'ESX' o 'QBCore'
 | 
						|
 | 
						|
RegisterNetEvent(Utils.eventsPrefix .. ":cumulative:increaseArmor", function(amount)
 | 
						|
	local ped=PlayerPedId()
 | 
						|
	local oldArmor=GetPedArmour(ped)
 | 
						|
	local newArmor=math.min(100, oldArmor+amount)
 | 
						|
	if (newArmor<0) then return end
 | 
						|
	SetPedArmour(ped, newArmor)
 | 
						|
end)
 | 
						|
 | 
						|
RegisterNetEvent(Utils.eventsPrefix .. ":cumulative:decreaseArmor", function(amount)
 | 
						|
	local ped=PlayerPedId()
 | 
						|
	local oldArmor=GetPedArmour(ped)
 | 
						|
	local newArmor=math.max(0, oldArmor-amount)
 | 
						|
	if (newArmor<0) then return end
 | 
						|
	SetPedArmour(ped, newArmor)
 | 
						|
end)
 | 
						|
 | 
						|
RegisterNetEvent(Utils.eventsPrefix .. ":cumulative:increaseHealth", function(amount)
 | 
						|
	local ped=PlayerPedId()
 | 
						|
	local oldHealth=GetEntityHealth(ped)
 | 
						|
	local maxHealth=GetEntityMaxHealth(ped)
 | 
						|
	local newHealth=math.min(maxHealth, oldHealth+amount)
 | 
						|
	if (newHealth<=0) then return end
 | 
						|
	SetEntityHealth(ped, newHealth)
 | 
						|
end)
 | 
						|
 | 
						|
RegisterNetEvent(Utils.eventsPrefix .. ":cumulative:decreaseHealth", function(amount)
 | 
						|
	local ped=PlayerPedId()
 | 
						|
	local oldHealth=GetEntityHealth(ped)
 | 
						|
	local newHealth=math.max(0, oldHealth-amount)
 | 
						|
	if (newHealth<0) then return end
 | 
						|
	SetEntityHealth(ped, newHealth)
 | 
						|
end)
 | 
						|
 | 
						|
RegisterNetEvent(Utils.eventsPrefix .. ":cumulative:increaseThirst", function(amount)
 | 
						|
	if (fw == 'ESX') then
 | 
						|
		TriggerEvent('esx_status:add', 'thirst', -amount)
 | 
						|
		return
 | 
						|
	end
 | 
						|
	local pd = QBCore.Functions.GetPlayerData()
 | 
						|
	local thirst = (pd.metadata and pd.metadata.thirst) and pd.metadata.thirst or 100
 | 
						|
	local newThirst = math.max(0, math.min(100, thirst - amount)) -- Diminuisci l'idratazione
 | 
						|
	TriggerServerEvent('consumables:server:addThirst', newThirst)
 | 
						|
end)
 | 
						|
 | 
						|
RegisterNetEvent(Utils.eventsPrefix .. ":cumulative:decreaseThirst", function(amount)
 | 
						|
	if (fw == 'ESX') then
 | 
						|
		TriggerEvent('esx_status:add', 'thirst', amount)
 | 
						|
		return
 | 
						|
	end
 | 
						|
	local pd = QBCore.Functions.GetPlayerData()
 | 
						|
	local thirst = (pd.metadata and pd.metadata.thirst) and pd.metadata.thirst or 100
 | 
						|
	local newThirst = math.max(0, math.min(100, thirst + amount)) -- Aumenta l'idratazione
 | 
						|
	TriggerServerEvent('consumables:server:addThirst', newThirst)
 | 
						|
end)
 | 
						|
 | 
						|
RegisterNetEvent(Utils.eventsPrefix .. ":cumulative:increaseHunger", function(amount)
 | 
						|
	if (fw == 'ESX') then
 | 
						|
		TriggerEvent('esx_status:add', 'hunger', -amount)
 | 
						|
		return
 | 
						|
	end
 | 
						|
	local pd = QBCore.Functions.GetPlayerData()
 | 
						|
	local hunger = (pd.metadata and pd.metadata.hunger) and pd.metadata.hunger or 100
 | 
						|
	local newHunger = math.max(0, math.min(100, hunger - amount)) -- Diminuisci la sazietà
 | 
						|
	TriggerServerEvent('consumables:server:addHunger', newHunger)
 | 
						|
end)
 | 
						|
 | 
						|
RegisterNetEvent(Utils.eventsPrefix .. ":cumulative:decreaseHunger", function(amount)
 | 
						|
	if (fw == 'ESX') then
 | 
						|
		TriggerEvent('esx_status:add', 'hunger', amount)
 | 
						|
		return
 | 
						|
	end
 | 
						|
	local pd = QBCore.Functions.GetPlayerData()
 | 
						|
	local hunger = (pd.metadata and pd.metadata.hunger) and pd.metadata.hunger or 100
 | 
						|
	local newHunger = math.max(0, math.min(100, hunger + amount)) -- Aumenta la sazietà
 | 
						|
	TriggerServerEvent('consumables:server:addHunger', newHunger)
 | 
						|
end)
 | 
						|
 | 
						|
RegisterNetEvent(Utils.eventsPrefix .. ":cumulative:increaseStress", function(amount)
 | 
						|
	if (fw=='ESX') then
 | 
						|
		TriggerEvent('esx_status:add','stress',amount)
 | 
						|
		return
 | 
						|
	end
 | 
						|
 | 
						|
    TriggerServerEvent('hud:server:GainStress', amount)
 | 
						|
end)
 | 
						|
 | 
						|
RegisterNetEvent(Utils.eventsPrefix .. ":cumulative:decreaseStress", function(amount)
 | 
						|
	if (fw=='ESX') then
 | 
						|
		TriggerEvent('esx_status:add','stress',-amount)
 | 
						|
		return
 | 
						|
	end
 | 
						|
 | 
						|
    TriggerServerEvent('hud:server:RelieveStress', amount)
 | 
						|
end)
 |