A little improvement
-- CONFIG --
-- How long it takes for the percentage to add one % for piss
DelayPiss = 30
-- How long it takes for the percentage to add one % for shit
DelayShit = 50
-- Enable the Debug HUD on the right of the screen allowing the user to see their piss and shit percentage
EnableDebugHUD = true
-- DO NOT TOUCH BELOW HERE --
ESX = nil
piss = 0
shit = 0
RegisterCommand("piss", function(source, args, rawCommand)
handle_piss()
end, false)
RegisterCommand("shit", function(source, args, rawCommand)
handle_shit()
end, false)
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
end
RequestAnimDict("missbigscore1switch_trevor_piss")
while not HasAnimDictLoaded("missbigscore1switch_trevor_piss") do
Citizen.Wait(100)
end
RequestAnimDict("switch@trevor@on_toilet")
while not HasAnimDictLoaded("switch@trevor@on_toilet") do
Citizen.Wait(100)
end
end)
-- Handle Piss Incrementation
Citizen.CreateThread(function()
local ped = PlayerPedId()
while true do
Citizen.Wait(DelayPiss * 1000) -- Delay in incrementation in milliseconds
if not IsEntityPlayingAnim(ped, "missbigscore1switch_trevor_piss", "piss_loop", 3) then
piss = piss + 1
end
end
end)
-- Handle Shit Incrementation
Citizen.CreateThread(function()
local ped = PlayerPedId()
while true do
Citizen.Wait(DelayShit * 2000) -- Delay in incrementation in milliseconds
if not IsEntityPlayingAnim(ped, "switch@trevor@on_toilet", "trev_on_toilet_exit", 3) then
shit = shit + 1
end
end
end)
-- Handle Notfications
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if piss == 100 then
ESX.ShowNotification("You need the toilet (Piss)")
end
if shit == 100 then
ESX.ShowNotification("You need the toilet (Shit)")
end
if piss > 119 then
ESX.ShowNotification("You have pissed yourself!")
handle_piss()
piss = 0
end
if shit > 119 then
ESX.ShowNotification("You have shit yourself!")
handle_shit()
shit = 0
end
end
end)
-- Handle HUD
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if EnableDebugHUD then
textPiss(piss)
textShit(shit)
end
end
end)
function handle_shit()
local ped = PlayerPedId()
if not IsEntityPlayingAnim(ped, "switch@trevor@on_toilet", "trev_on_toilet_exit", 3) then
TaskPlayAnim(ped, "switch@trevor@on_toilet", "trev_on_toilet_exit", 8.0, -8, -1, 49, 0, 0, 0, 0)
SetCurrentPedWeapon(ped, GetHashKey("WEAPON_UNARMED"), true)
ESX.ShowNotification("You are taking a shit!")
Citizen.Wait(8000)
while IsEntityPlayingAnim(ped, "switch@trevor@on_toilet", "trev_on_toilet_exit", 3) and shit > 0 do
Citizen.Wait(1)
if (IsControlPressed(0, 32) or IsControlPressed(0, 33) or IsControlPressed(0, 34) or IsControlPressed(0, 35)) then
ClearPedTasksImmediately(ped)
break
end
shit = shit - 0.1
end
ClearPedTasksImmediately(ped)
end
return
end
function handle_piss()
local ped = PlayerPedId()
if not IsEntityPlayingAnim(ped, "missbigscore1switch_trevor_piss", "piss_loop", 3) then
TaskPlayAnim(ped, "missbigscore1switch_trevor_piss", "piss_loop", 8.0, -8, -1, 49, 0, 0, 0, 0)
SetCurrentPedWeapon(ped, GetHashKey("WEAPON_UNARMED"), true)
ESX.ShowNotification("You are taking a piss!")
Wait(8000)
while IsEntityPlayingAnim(ped, "missbigscore1switch_trevor_piss", "piss_loop", 3) and piss > 0 do
Citizen.Wait(1)
if (IsControlPressed(0, 32) or IsControlPressed(0, 33) or IsControlPressed(0, 34) or IsControlPressed(0, 35)) then
ClearPedTasksImmediately(ped)
break
end
piss = piss - 0.1
end
ClearPedTasksImmediately(ped)
end
return
end
function textPiss(content)
SetTextFont(0)
SetTextProportional(0)
SetTextScale(0.2,0.2)
SetTextEntry("STRING")
AddTextComponentString("Debug: Bladder (Piss): " ..content.."%")
DrawText(0.84,0.62)
end
function textShit(content)
SetTextFont(0)
SetTextProportional(0)
SetTextScale(0.2,0.2)
SetTextEntry("STRING")
AddTextComponentString("Debug: Bowl (Shit): " ..content.."%")
DrawText(0.84,0.65)
end