Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ProcessTables()
- RequestAnimDict("anim_casino_b@amb@casino@games@shared@player@")
- while true do
- local Wait_Time = 1000
- local playerPed = PlayerPedId()
- if not IsEntityDead(playerPed) then
- for i, v in pairs(tables) do
- local cord = v.coords
- local highStakes = v.highStakes
- if GetDistanceBetweenCoords(cord.x, cord.y, cord.z, GetEntityCoords(PlayerPedId()), true) < 3.0 then
- Wait_Time = 5
- -- local pCoords = vector3(cord.x, cord.y, cord.z)
- local pCoords = GetEntityCoords(PlayerPedId())
- local tableObj = 0
- for _, tableModel in each(TableModels) do
- tableObj = GetClosestObjectOfType(pCoords.x, pCoords.y, pCoords.z, 1.5, GetHashKey(tableModel))
- if DoesEntityExist(tableObj) then
- break
- end
- end
- if DoesEntityExist(tableObj) then
- print("JSEM TUaaa", GetEntityCoords(tableObj))
- closestChair = 1
- local coords = GetWorldPositionOfEntityBone(tableObj, GetEntityBoneIndexByName(tableObj, "Chair_Base_0" .. closestChair))
- local rot = GetWorldRotationOfEntityBone(tableObj, GetEntityBoneIndexByName(tableObj, "Chair_Base_0" .. closestChair))
- dist = GetDistanceBetweenCoords(coords, GetEntityCoords(PlayerPedId()), true)
- for i = 1, 4 do
- local coords = GetWorldPositionOfEntityBone(tableObj, GetEntityBoneIndexByName(tableObj, "Chair_Base_0" .. i))
- if GetDistanceBetweenCoords(coords, GetEntityCoords(PlayerPedId()), true) < dist then
- dist = GetDistanceBetweenCoords(coords, GetEntityCoords(PlayerPedId()), true)
- closestChair = i
- end
- end
- local coords = GetWorldPositionOfEntityBone(tableObj, GetEntityBoneIndexByName(tableObj, "Chair_Base_0" .. closestChair))
- local rot = GetWorldRotationOfEntityBone(tableObj, GetEntityBoneIndexByName(tableObj, "Chair_Base_0" .. closestChair))
- g_coords = coords
- g_rot = rot
- local angle = rot.z - findRotation(coords.x, coords.y, pCoords.x, pCoords.y) + 90.0
- local seatAnim = "sit_enter_"
- if angle > 0 then
- seatAnim = "sit_enter_left"
- end
- if angle < 0 then
- seatAnim = "sit_enter_right"
- end
- if angle > seatSideAngle or angle < -seatSideAngle then
- seatAnim = seatAnim .. "_side"
- end
- local canSit = true
- if GetDistanceBetweenCoords(coords, GetEntityCoords(PlayerPedId()), true) < 1.5 and not IsSeatOccupied(coords, 0.5) and canSit then
- print("JSEM TU")
- if _DEBUG == true then
- SetTextFont(0)
- SetTextProportional(1)
- SetTextScale(0.0, 0.45)
- SetTextColour(255, 255, 255, 255)
- SetTextDropshadow(0, 0, 0, 0, 255)
- SetTextEdge(2, 0, 0, 0, 150)
- SetTextDropShadow()
- SetTextOutline()
- SetTextEntry("STRING")
- SetTextCentre(1)
- SetDrawOrigin(cord.x, cord.y, cord.z)
- AddTextComponentString("table = " .. i)
- DrawText(0.0, 0.0)
- ClearDrawOrigin()
- end
- if IsControlJustPressed(1, 51) then
- local initPos = GetAnimInitialOffsetPosition("anim_casino_b@amb@casino@games@shared@player@", seatAnim, coords, rot, 0.01, 2)
- local initRot = GetAnimInitialOffsetRotation("anim_casino_b@amb@casino@games@shared@player@", seatAnim, coords, rot, 0.01, 2)
- TaskGoStraightToCoord(PlayerPedId(), initPos, 1.0, 5000, initRot.z, 0.01)
- repeat Wait(0) until GetScriptTaskStatus(PlayerPedId(), 2106541073) == 7
- Wait(50)
- SetPedCurrentWeaponVisible(PlayerPedId(), 0, true, 0, 0)
- local scene = NetworkCreateSynchronisedScene(coords, rot, 2, true, true, 1065353216, 0, 1065353216)
- NetworkAddPedToSynchronisedScene(PlayerPedId(), scene, "anim_casino_b@amb@casino@games@shared@player@", seatAnim, 2.0, -2.0, 13, 16, 1148846080, 0)
- NetworkStartSynchronisedScene(scene)
- local scene = NetworkConvertSynchronisedSceneToSynchronizedScene(scene)
- repeat Wait(0) until GetSynchronizedScenePhase(scene) >= 0.99 or HasAnimEventFired(PlayerPedId(), 2038294702) or HasAnimEventFired(PlayerPedId(), -1424880317)
- Wait(1000)
- idleVar = "idle_cardgames"
- scene = NetworkCreateSynchronisedScene(coords, rot, 2, true, true, 1065353216, 0, 1065353216)
- NetworkAddPedToSynchronisedScene(PlayerPedId(), scene, "anim_casino_b@amb@casino@games@shared@player@", "idle_cardgames", 2.0, -2.0, 13, 16, 1148846080, 0)
- NetworkStartSynchronisedScene(scene)
- repeat Wait(0) until IsEntityPlayingAnim(PlayerPedId(), "anim_casino_b@amb@casino@games@shared@player@", "idle_cardgames", 3) == 1
- g_seat = i
- leavingBlackjack = false
- TriggerServerEvent("BLACKJACK:PlayerSatDown", i, closestChair)
- local endTime = GetGameTimer() + math.floor(GetAnimDuration("anim_casino_b@amb@casino@games@shared@player@", idleVar) * 990)
- Citizen.CreateThread(function()
- -- Disable pause when while in-blackjack
- local startCount = false
- local endlooptime = nil
- local didonece = false
- while true do
- Citizen.Wait(0)
- SetPauseMenuActive(false)
- if not didonece and leavingBlackjack == true then
- didonece = true
- startCount = true
- end
- if startCount == true then
- endlooptime = GetGameTimer() + 3000
- startCount = false
- end
- if endlooptime and GetGameTimer() >= endlooptime then
- -- Make it so it enables 3 seconds after hitting the leave button so the pause menu doesn't show up when trying to leave
- SetPauseMenuActive(true)
- break
- end
- end
- end)
- while true do
- Wait(0)
- if GetGameTimer() >= endTime then
- if playerBusy == true then
- while playerBusy == true do
- Wait(0)
- local playerPed = PlayerPedId()
- if IsEntityDead(playerPed) then
- TriggerServerEvent("BLACKJACK:PlayerRemove", i)
- ClearPedTasks(playerPed)
- leaveBlackjack()
- break
- end
- end
- end
- if leavingBlackjack == false then
- idleVar = "idle_var_0" .. math.random(1, 5)
- local scene = NetworkCreateSynchronisedScene(coords, rot, 2, true, true, 1065353216, 0, 1065353216)
- NetworkAddPedToSynchronisedScene(PlayerPedId(), scene, "anim_casino_b@amb@casino@games@shared@player@", idleVar, 2.0, -2.0, 13, 16, 1148846080, 0)
- NetworkStartSynchronisedScene(scene)
- endTime = GetGameTimer() + math.floor(GetAnimDuration("anim_casino_b@amb@casino@games@shared@player@", idleVar) * 990)
- -- DebugPrint("idling again")
- end
- end
- -- if IsControlJustPressed(1, 51) then
- if leavingBlackjack == true then
- local scene = NetworkCreateSynchronisedScene(coords, rot, 2, false, false, 1065353216, 0, 1065353216)
- NetworkAddPedToSynchronisedScene(PlayerPedId(), scene, "anim_casino_b@amb@casino@games@shared@player@", "sit_exit_left", 2.0, -2.0, 13, 16, 1148846080, 0)
- NetworkStartSynchronisedScene(scene)
- TriggerServerEvent("BLACKJACK:PlayerSatUp", i)
- Wait(math.floor(GetAnimDuration("anim_casino_b@amb@casino@games@shared@player@", "sit_exit_left") * 800))
- ClearPedTasks(PlayerPedId())
- break
- else
- local playerPed = PlayerPedId()
- if IsEntityDead(playerPed) then
- TriggerServerEvent("BLACKJACK:PlayerRemove", i)
- ClearPedTasks(playerPed)
- leaveBlackjack()
- break
- end
- end
- -- if IsEntityPlayingAnim(PlayerPedId(), "anim_casino_b@amb@casino@games@shared@player@", idleVar, 3) ~= 1 then break end
- end
- end
- end
- end
- end
- end
- end
- Wait(Wait_Time)
- end
- end
Add Comment
Please, Sign In to add comment