GithubHelp home page GithubHelp logo

stress-system-by-utku's Introduction

--[[
	Max stress is 1.000.000, same as hunger and thirst. Same working mehcanism as hunger-thirst.
	//
	Maksimum stress 1.000.000, açlık ve susuzluk ile aynı mantıkta çalışıyor.
]]

--[[ INSTALL GUIDE
esx_status is a dependency
Create a file in your resources folder and name it stress_utk
place client.lua, __resource.lua, server.lua logs.txt inside stress_utk
place start stress_utk under esx_status in your server.cfg
]]
-- If you want to make /heal command also reset stress then you need to replace these lines in esx_basicneeds:
AddEventHandler('esx_basicneeds:resetStatus', function()
	TriggerEvent('esx_status:set', 'hunger', 500000)
	TriggerEvent('esx_status:set', 'thirst', 500000)
end)
--with these:
AddEventHandler('esx_basicneeds:resetStatus', function()
	TriggerEvent('esx_status:set', 'hunger', 500000)
	TriggerEvent('esx_status:set', 'thirst', 500000)
	TriggerEvent('esx_status:set', 'stress', 10)
end)
-------------------------------------------------------
--And these:
RegisterNetEvent('esx_basicneeds:healPlayer')
AddEventHandler('esx_basicneeds:healPlayer', function()
	-- restore hunger & thirst
	TriggerEvent('esx_status:set', 'hunger', 1000000)
	TriggerEvent('esx_status:set', 'thirst', 1000000)
	-- restore hp
	local playerPed = PlayerPedId()
	SetEntityHealth(playerPed, GetEntityMaxHealth(playerPed))
end)
-- with these:
RegisterNetEvent('esx_basicneeds:healPlayer')
AddEventHandler('esx_basicneeds:healPlayer', function()
	-- restore hunger & thirst
	TriggerEvent('esx_status:set', 'hunger', 1000000)
	TriggerEvent('esx_status:set', 'thirst', 1000000)
	TriggerEvent('esx_status:set', 'stress', 10)
	-- restore hp
	local playerPed = PlayerPedId()
	SetEntityHealth(playerPed, GetEntityMaxHealth(playerPed))
end)
-------------------------------------------------------
-- ADDING AND REMOVING STRESS FROM OTHER RESOURCES

-- CLIENT SIDE USING EXPORTS:

exports['stress_utk']:AddStress('instant', 100000) -- Adds 100.000 (%10) stress instantly

exports['stress_utk']:AddStress('slow', 100000, 5) -- Adds 100.000 (%10) stress gradually in 5 seconds

exports['stress_utk']:RemoveStress('instant', 100000) -- Removes 100.000 (%10) stress instantly

exports['stress_utk']:RemoveStress('slow', 100000, 5) -- Removes 100.000 (%10) stress gradually in 5 seconds

-- EXAMPLE THREAD

Citizen.CreateThread(function()
    while true do -- döngü // loop
        local test = IsPedShooting(ped) -- kontrol etmek istediğiniz nativeler // native you want to check (natives: https://runtime.fivem.net/doc/natives/)
        if test then -- eğer native true dönerse alttaki olaylar yaşanacak // if the native returns true below action will happen
            TriggerServerEvent("stress:add", 500000) -- stres ekleme // adding stress
        else -- eğer native false dönerse bir şey yapmayıp döngü devam edecek // while the native returns false do nothing and keep the loop
            Citizen.Wait(1) -- nativeyi ne kadar sık kontrol etmek istediğinizi buraya yazın ms olarak (genelde 1000 altı olmalı) // how often you want to check the native in ms (should generally be smaller then 1000)
        end
    end
end)

-- AYRICA esx_basicneeds/server.lua 'DA İTEM KULLANIMINDA STRESS ETKİSİ ÖRNEĞİ VARDIR --

-- ALSO THERE IS AN EXAMPLE FOR ADDING OR REMOVING STRESS ON ITEM USAGE IN esx_basicneeds/server.lua --

stress-system-by-utku's People

Contributors

utkuali avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.