Skip to content

Commit

Permalink
refactor: major rebuild for kc-unicorn
Browse files Browse the repository at this point in the history
- Updated the resource export method regarding the ESX Framework
- Performed code formatting and cleaning work, removing the version check part
- fixed the problem: SCRIPT ERROR: Execution of native 00000000faa3d236 in script host failed: Tried to access invalid entity: 133121
  • Loading branch information
bitpredator committed Dec 3, 2024
1 parent 0d5e29c commit 688b1c5
Show file tree
Hide file tree
Showing 7 changed files with 891 additions and 1,023 deletions.
118 changes: 54 additions & 64 deletions server-data/resources/[esx_addons]/kc-unicorn/client/loop.lua
Original file line number Diff line number Diff line change
@@ -1,80 +1,70 @@
-- Check player and his coords
Citizen.CreateThread(function()
while true do
while true do
Cache.Player = PlayerPedId()
Cache.PlyCoo = GetEntityCoords(Cache.Player)

Cache.Player = PlayerPedId()
Cache.PlyCoo = GetEntityCoords(Cache.Player)


if Cache.inuniPoly then
Citizen.Wait(1)
else
Citizen.Wait(1500)
end
end
if Cache.inuniPoly then
Citizen.Wait(1)
else
Citizen.Wait(1500)
end
end
end)

-- Get which seats are taken for lapdance
Citizen.CreateThread(function()

while true do

if Cache.inlapPoly then
Citizen.Wait(300)
TriggerServerEvent('kc-unicorn:GetPlayerSeated')
else
Citizen.Wait(1000)
end
end

while true do
if Cache.inlapPoly then
Citizen.Wait(300)
TriggerServerEvent("kc-unicorn:GetPlayerSeated")
else
Citizen.Wait(1000)
end
end
end)

--
--
Citizen.CreateThread(function()
while true do
while Cache.InLapdance do
DisableControlAction(2, 0, true)
DisableControlAction(2, 24, true)
DisableControlAction(2, 257, true)
DisableControlAction(2, 25, true)
DisableControlAction(2, 263, true)
DisableControlAction(2, 32, true)
DisableControlAction(2, 34, true)
DisableControlAction(2, 8, true)
DisableControlAction(2, 9, true)
Citizen.Wait(0)
end

while true do

while Cache.InLapdance do
DisableControlAction(2, 0, true)
DisableControlAction(2, 24, true)
DisableControlAction(2, 257, true)
DisableControlAction(2, 25, true)
DisableControlAction(2, 263, true)
DisableControlAction(2, 32, true)
DisableControlAction(2, 34, true)
DisableControlAction(2, 8, true)
DisableControlAction(2, 9, true)
Citizen.Wait(0)
end
while Cache.InLean do
DisableControlAction(2, 0, true)
Citizen.Wait(0)
end

while Cache.InLean do
DisableControlAction(2, 0, true)
Citizen.Wait(0)
end

Citizen.Wait(1000)
end
Citizen.Wait(1000)
end
end)

--
Citizen.CreateThread(function()
while true do
while Cache.InLapdance do
Citizen.Wait(400)
if GetEntityHealth(Cache.SpawnPed) <= 0 or IsPedRagdoll(Cache.SpawnPed) or IsPedFleeing(Cache.SpawnPed) then
FreezeEntityPosition(Cache.SpawnPed, false)
DrawText2D(Loc("lapStopped"))
Cache.InLapdance = false
Cache.lapStop = true
Citizen.Wait(1000)
Cache.InCooldown = false
Citizen.Wait(10000)
DeleteEntity(Cache.SpawnPed)
end
end

while true do

while Cache.InLapdance do
Citizen.Wait(400)
if GetEntityHealth(Cache.SpawnPed) <= 0 or IsPedRagdoll(Cache.SpawnPed) or IsPedFleeing(Cache.SpawnPed) then
FreezeEntityPosition(Cache.SpawnPed, false)
DrawText2D(Loc('lapStopped'))
Cache.InLapdance = false
Cache.lapStop = true
Citizen.Wait(1000)
Cache.InCooldown = false
Citizen.Wait(10000)
DeleteEntity(Cache.SpawnPed)
end
end

Citizen.Wait(1000)
end
end)
Citizen.Wait(1000)
end
end)
Loading

0 comments on commit 688b1c5

Please sign in to comment.