Advertisement
Guest User

Untitled

a guest
Nov 11th, 2019
414
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.87 KB | None | 0 0
  1. ESX = nil
  2. local _wheel = nil
  3. local _lambo = nil
  4. local _isShowCar = false
  5. local _wheelPos = vector3(976.25, 50.78, 74.68)
  6. local Keys = {
  7.     ["ESC"] = 322, ["BACKSPACE"] = 177, ["E"] = 38, ["ENTER"] = 18, ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173
  8. }
  9. local _isRolling = false
  10.  
  11. Citizen.CreateThread(function()
  12.     while ESX == nil do
  13.         TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
  14.         Citizen.Wait(0)
  15.     end
  16.     while not ESX.IsPlayerLoaded() do
  17.         Citizen.Wait(500)
  18.     end
  19.  
  20.     if ESX.IsPlayerLoaded() then
  21.         local model = GetHashKey('vw_prop_vw_luckywheel_02a')
  22.         local carmodel = GetHashKey('lwgtr')
  23.  
  24.         Citizen.CreateThread(function()
  25.             RequestModel(model)
  26.  
  27.             while not HasModelLoaded(model) do
  28.                 Citizen.Wait(0)
  29.             end
  30.  
  31.             _wheel = CreateObject(model, 978.0117, 50.3487, 73.9561, false, false, true)
  32.             SetEntityHeading(_wheel, -30.9754)
  33.             SetModelAsNoLongerNeeded
  34.            
  35.             -- Car
  36.             RequestModel(carmodel)
  37.             while not HasModelLoaded(carmodel) do
  38.                 Citizen.Wait(0)
  39.             end
  40.  
  41.             local vehicle = CreateVehicle(carmodel, 963.79, 47.62, 75.57, 0.0, false, false)
  42.            
  43.             SetModelAsNoLongerNeeded(carmodel)
  44.            
  45.  
  46.             -- RequestCollisionAtCoord(1100.39, 220.09, -48.75)
  47.  
  48.             -- while not HasCollisionLoadedAroundEntity(vehicle) do
  49.             --     RequestCollisionAtCoord(1100.39, 220.09, -48.75)
  50.             --     Citizen.Wait(0)
  51.             -- end
  52.  
  53.             -- SetVehRadioStation(vehicle, 'OFF')
  54.             FreezeEntityPosition(vehicle, true)
  55.             local _curPos = GetEntityCoords(vehicle)
  56.             SetEntityCoords(vehicle, _curPos.x, _curPos.y, _curPos.z + 1, false, false, true, true)
  57.             _lambo = vehicle
  58.            
  59.         end)
  60.     end
  61. end)
  62.  
  63. Citizen.CreateThread(function()
  64.     while true do
  65.         if _lambo ~= nil then
  66.             local _heading = GetEntityHeading(_lambo)
  67.             local _z = _heading - 0.3
  68.             SetEntityHeading(_lambo, _z)
  69.         end
  70.         Citizen.Wait(5)
  71.     end
  72. end)
  73.  
  74. RegisterNetEvent("esx_tpnrp_luckywheel:doRoll")
  75. AddEventHandler("esx_tpnrp_luckywheel:doRoll", function(_priceIndex)
  76.     _isRolling = true
  77.     SetEntityRotation(_wheel, 0.0, 0.0, 0.0, 1, true)
  78.     Citizen.CreateThread(function()
  79.         local speedIntCnt = 1
  80.         local rollspeed = 1.0
  81.         -- local _priceIndex = math.random(1, 20)
  82.         local _winAngle = (_priceIndex - 1) * 18
  83.         local _rollAngle = _winAngle + (360 * 8)
  84.         local _midLength = (_rollAngle / 2)
  85.         local intCnt = 0
  86.         while speedIntCnt > 0 do
  87.             local retval = GetEntityRotation(_wheel, 1)
  88.             if _rollAngle > _midLength then
  89.                 speedIntCnt = speedIntCnt + 1
  90.             else
  91.                 speedIntCnt = speedIntCnt - 1
  92.                 if speedIntCnt < 0 then
  93.                     speedIntCnt = 0
  94.                    
  95.                 end
  96.             end
  97.             intCnt = intCnt + 1
  98.             rollspeed = speedIntCnt / 10
  99.             local _y = retval.y - rollspeed
  100.             _rollAngle = _rollAngle - rollspeed
  101.             -- if _rollAngle < 5.0 then
  102.             --     if _y > _winAngle then
  103.             --         _y = _winAngle
  104.             --     end
  105.             -- end
  106.             SetEntityRotation(_wheel, 0.0, _y, 0.0, 1, true)
  107.             Citizen.Wait(0)
  108.         end
  109.     end)
  110. end)
  111.  
  112. RegisterNetEvent("esx_tpnrp_luckywheel:rollFinished")
  113. AddEventHandler("esx_tpnrp_luckywheel:rollFinished", function()
  114.     _isRolling = false
  115. end)
  116.  
  117.  
  118. function doRoll()
  119.     if not _isRolling then
  120.         _isRolling = true
  121.         local playerPed = PlayerPedId()
  122.         local _lib = 'anim_casino_a@amb@casino@games@lucky7wheel@female'
  123.         if IsPedMale(playerPed) then
  124.             _lib = 'anim_casino_a@amb@casino@games@lucky7wheel@male'
  125.         end
  126.         local lib, anim = _lib, 'enter_right_to_baseidle'
  127.         ESX.Streaming.RequestAnimDict(lib, function()
  128.             local _movePos = vector3(976.25, 50.78, 74.68)
  129.             TaskGoStraightToCoord(playerPed,  _movePos.x,  _movePos.y,  _movePos.z,  1.0,  -1,  312.2,  0.0)
  130.             local _isMoved = false
  131.             while not _isMoved do
  132.                 local coords = GetEntityCoords(PlayerPedId())
  133.                 if coords.x >= (_movePos.x - 0.01) and coords.x <= (_movePos.x + 0.01) and coords.y >= (_movePos.y - 0.01) and coords.y <= (_movePos.y + 0.01) then
  134.                     _isMoved = true
  135.                 end
  136.                 Citizen.Wait(0)
  137.             end
  138.             TaskPlayAnim(playerPed, lib, anim, 8.0, -8.0, -1, 0, 0, false, false, false)
  139.             while IsEntityPlayingAnim(playerPed, lib, anim, 3) do
  140.                     Citizen.Wait(0)
  141.                     DisableAllControlActions(0)
  142.             end
  143.             TaskPlayAnim(playerPed, lib, 'enter_to_armraisedidle', 8.0, -8.0, -1, 0, 0, false, false, false)
  144.             while IsEntityPlayingAnim(playerPed, lib, 'enter_to_armraisedidle', 3) do
  145.                 Citizen.Wait(0)
  146.                 DisableAllControlActions(0)
  147.             end
  148.             TriggerServerEvent("esx_tpnrp_luckywheel:getLucky")
  149.             TaskPlayAnim(playerPed, lib, 'armraisedidle_to_spinningidle_high', 8.0, -8.0, -1, 0, 0, false, false, false)
  150.         end)
  151.     end
  152. end
  153.  
  154. -- Menu Controls
  155. Citizen.CreateThread(function()
  156.     while true do
  157.         Citizen.Wait(1)
  158.         local coords = GetEntityCoords(PlayerPedId())
  159.  
  160.         if(GetDistanceBetweenCoords(coords, _wheelPos.x, _wheelPos.y, _wheelPos.z, true) < 1.5) and not _isRolling then
  161.             ESX.ShowHelpNotification("Bấm E để thử vận may với Vòng Quay 1 lần 100,000$")
  162.             if IsControlJustReleased(0, Keys['E']) then
  163.                 doRoll()
  164.             end
  165.         end    
  166.     end
  167. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement