Trsak

Untitled

Aug 19th, 2021
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.69 KB | None | 0 0
  1. function ProcessTables()
  2.     RequestAnimDict("anim_casino_b@amb@casino@games@shared@player@")
  3.  
  4.     while true do
  5.         local Wait_Time = 1000
  6.         local playerPed = PlayerPedId()
  7.  
  8.         if not IsEntityDead(playerPed) then
  9.             for i, v in pairs(tables) do
  10.                 local cord = v.coords
  11.                 local highStakes = v.highStakes
  12.  
  13.                 if GetDistanceBetweenCoords(cord.x, cord.y, cord.z, GetEntityCoords(PlayerPedId()), true) < 3.0 then
  14.                     Wait_Time = 5
  15.  
  16.                     -- local pCoords = vector3(cord.x, cord.y, cord.z)
  17.                     local pCoords = GetEntityCoords(PlayerPedId())
  18.                     local tableObj = 0
  19.  
  20.                     for _, tableModel in each(TableModels) do
  21.                         tableObj = GetClosestObjectOfType(pCoords.x, pCoords.y, pCoords.z, 1.5, GetHashKey(tableModel))
  22.                         if DoesEntityExist(tableObj) then
  23.                             break
  24.                         end
  25.                     end
  26.  
  27.                     if DoesEntityExist(tableObj) then
  28.                         print("JSEM TUaaa", GetEntityCoords(tableObj))
  29.                         closestChair = 1
  30.                         local coords = GetWorldPositionOfEntityBone(tableObj, GetEntityBoneIndexByName(tableObj, "Chair_Base_0" .. closestChair))
  31.                         local rot = GetWorldRotationOfEntityBone(tableObj, GetEntityBoneIndexByName(tableObj, "Chair_Base_0" .. closestChair))
  32.                         dist = GetDistanceBetweenCoords(coords, GetEntityCoords(PlayerPedId()), true)
  33.  
  34.                         for i = 1, 4 do
  35.                             local coords = GetWorldPositionOfEntityBone(tableObj, GetEntityBoneIndexByName(tableObj, "Chair_Base_0" .. i))
  36.                             if GetDistanceBetweenCoords(coords, GetEntityCoords(PlayerPedId()), true) < dist then
  37.                                 dist = GetDistanceBetweenCoords(coords, GetEntityCoords(PlayerPedId()), true)
  38.                                 closestChair = i
  39.                             end
  40.                         end
  41.  
  42.                         local coords = GetWorldPositionOfEntityBone(tableObj, GetEntityBoneIndexByName(tableObj, "Chair_Base_0" .. closestChair))
  43.                         local rot = GetWorldRotationOfEntityBone(tableObj, GetEntityBoneIndexByName(tableObj, "Chair_Base_0" .. closestChair))
  44.  
  45.                         g_coords = coords
  46.                         g_rot = rot
  47.  
  48.                         local angle = rot.z - findRotation(coords.x, coords.y, pCoords.x, pCoords.y) + 90.0
  49.  
  50.                         local seatAnim = "sit_enter_"
  51.  
  52.                         if angle > 0 then
  53.                             seatAnim = "sit_enter_left"
  54.                         end
  55.                         if angle < 0 then
  56.                             seatAnim = "sit_enter_right"
  57.                         end
  58.                         if angle > seatSideAngle or angle < -seatSideAngle then
  59.                             seatAnim = seatAnim .. "_side"
  60.                         end
  61.  
  62.                         local canSit = true
  63.  
  64.                         if GetDistanceBetweenCoords(coords, GetEntityCoords(PlayerPedId()), true) < 1.5 and not IsSeatOccupied(coords, 0.5) and canSit then
  65.                             print("JSEM TU")
  66.  
  67.                             if _DEBUG == true then
  68.                                 SetTextFont(0)
  69.                                 SetTextProportional(1)
  70.                                 SetTextScale(0.0, 0.45)
  71.                                 SetTextColour(255, 255, 255, 255)
  72.                                 SetTextDropshadow(0, 0, 0, 0, 255)
  73.                                 SetTextEdge(2, 0, 0, 0, 150)
  74.                                 SetTextDropShadow()
  75.                                 SetTextOutline()
  76.                                 SetTextEntry("STRING")
  77.                                 SetTextCentre(1)
  78.                                 SetDrawOrigin(cord.x, cord.y, cord.z)
  79.                                 AddTextComponentString("table = " .. i)
  80.                                 DrawText(0.0, 0.0)
  81.                                 ClearDrawOrigin()
  82.                             end
  83.  
  84.                             if IsControlJustPressed(1, 51) then
  85.                                 local initPos = GetAnimInitialOffsetPosition("anim_casino_b@amb@casino@games@shared@player@", seatAnim, coords, rot, 0.01, 2)
  86.                                 local initRot = GetAnimInitialOffsetRotation("anim_casino_b@amb@casino@games@shared@player@", seatAnim, coords, rot, 0.01, 2)
  87.  
  88.                                 TaskGoStraightToCoord(PlayerPedId(), initPos, 1.0, 5000, initRot.z, 0.01)
  89.                                 repeat Wait(0) until GetScriptTaskStatus(PlayerPedId(), 2106541073) == 7
  90.                                 Wait(50)
  91.  
  92.                                 SetPedCurrentWeaponVisible(PlayerPedId(), 0, true, 0, 0)
  93.  
  94.                                 local scene = NetworkCreateSynchronisedScene(coords, rot, 2, true, true, 1065353216, 0, 1065353216)
  95.                                 NetworkAddPedToSynchronisedScene(PlayerPedId(), scene, "anim_casino_b@amb@casino@games@shared@player@", seatAnim, 2.0, -2.0, 13, 16, 1148846080, 0)
  96.                                 NetworkStartSynchronisedScene(scene)
  97.  
  98.                                 local scene = NetworkConvertSynchronisedSceneToSynchronizedScene(scene)
  99.                                 repeat Wait(0) until GetSynchronizedScenePhase(scene) >= 0.99 or HasAnimEventFired(PlayerPedId(), 2038294702) or HasAnimEventFired(PlayerPedId(), -1424880317)
  100.  
  101.                                 Wait(1000)
  102.  
  103.                                 idleVar = "idle_cardgames"
  104.  
  105.                                 scene = NetworkCreateSynchronisedScene(coords, rot, 2, true, true, 1065353216, 0, 1065353216)
  106.                                 NetworkAddPedToSynchronisedScene(PlayerPedId(), scene, "anim_casino_b@amb@casino@games@shared@player@", "idle_cardgames", 2.0, -2.0, 13, 16, 1148846080, 0)
  107.                                 NetworkStartSynchronisedScene(scene)
  108.  
  109.                                 repeat Wait(0) until IsEntityPlayingAnim(PlayerPedId(), "anim_casino_b@amb@casino@games@shared@player@", "idle_cardgames", 3) == 1
  110.  
  111.                                 g_seat = i
  112.  
  113.                                 leavingBlackjack = false
  114.  
  115.                                 TriggerServerEvent("BLACKJACK:PlayerSatDown", i, closestChair)
  116.  
  117.                                 local endTime = GetGameTimer() + math.floor(GetAnimDuration("anim_casino_b@amb@casino@games@shared@player@", idleVar) * 990)
  118.  
  119.                                 Citizen.CreateThread(function()
  120.                                     -- Disable pause when while in-blackjack
  121.                                     local startCount = false
  122.                                     local endlooptime = nil
  123.                                     local didonece = false
  124.                                     while true do
  125.                                         Citizen.Wait(0)
  126.                                         SetPauseMenuActive(false)
  127.  
  128.                                         if not didonece and leavingBlackjack == true then
  129.                                             didonece = true
  130.                                             startCount = true
  131.                                         end
  132.  
  133.                                         if startCount == true then
  134.                                             endlooptime = GetGameTimer() + 3000
  135.                                             startCount = false
  136.                                         end
  137.  
  138.                                         if endlooptime and GetGameTimer() >= endlooptime then
  139.                                             -- Make it so it enables 3 seconds after hitting the leave button so the pause menu doesn't show up when trying to leave
  140.                                             SetPauseMenuActive(true)
  141.                                             break
  142.                                         end
  143.                                     end
  144.                                 end)
  145.  
  146.                                 while true do
  147.                                     Wait(0)
  148.                                     if GetGameTimer() >= endTime then
  149.                                         if playerBusy == true then
  150.                                             while playerBusy == true do
  151.                                                 Wait(0)
  152.  
  153.                                                 local playerPed = PlayerPedId()
  154.  
  155.                                                 if IsEntityDead(playerPed) then
  156.                                                     TriggerServerEvent("BLACKJACK:PlayerRemove", i)
  157.                                                     ClearPedTasks(playerPed)
  158.                                                     leaveBlackjack()
  159.                                                     break
  160.                                                 end
  161.                                             end
  162.                                         end
  163.  
  164.                                         if leavingBlackjack == false then
  165.                                             idleVar = "idle_var_0" .. math.random(1, 5)
  166.  
  167.                                             local scene = NetworkCreateSynchronisedScene(coords, rot, 2, true, true, 1065353216, 0, 1065353216)
  168.                                             NetworkAddPedToSynchronisedScene(PlayerPedId(), scene, "anim_casino_b@amb@casino@games@shared@player@", idleVar, 2.0, -2.0, 13, 16, 1148846080, 0)
  169.                                             NetworkStartSynchronisedScene(scene)
  170.                                             endTime = GetGameTimer() + math.floor(GetAnimDuration("anim_casino_b@amb@casino@games@shared@player@", idleVar) * 990)
  171.                                             -- DebugPrint("idling again")
  172.                                         end
  173.                                     end
  174.  
  175.                                     -- if IsControlJustPressed(1, 51) then
  176.                                     if leavingBlackjack == true then
  177.                                         local scene = NetworkCreateSynchronisedScene(coords, rot, 2, false, false, 1065353216, 0, 1065353216)
  178.                                         NetworkAddPedToSynchronisedScene(PlayerPedId(), scene, "anim_casino_b@amb@casino@games@shared@player@", "sit_exit_left", 2.0, -2.0, 13, 16, 1148846080, 0)
  179.                                         NetworkStartSynchronisedScene(scene)
  180.                                         TriggerServerEvent("BLACKJACK:PlayerSatUp", i)
  181.                                         Wait(math.floor(GetAnimDuration("anim_casino_b@amb@casino@games@shared@player@", "sit_exit_left") * 800))
  182.                                         ClearPedTasks(PlayerPedId())
  183.                                         break
  184.                                     else
  185.                                         local playerPed = PlayerPedId()
  186.  
  187.                                         if IsEntityDead(playerPed) then
  188.                                             TriggerServerEvent("BLACKJACK:PlayerRemove", i)
  189.                                             ClearPedTasks(playerPed)
  190.                                             leaveBlackjack()
  191.                                             break
  192.                                         end
  193.                                     end
  194.  
  195.                                     -- if IsEntityPlayingAnim(PlayerPedId(), "anim_casino_b@amb@casino@games@shared@player@", idleVar, 3) ~= 1 then break end
  196.                                 end
  197.                             end
  198.                         end
  199.                     end
  200.                 end
  201.             end
  202.         end
  203.         Wait(Wait_Time)
  204.     end
  205. end
Add Comment
Please, Sign In to add comment