Advertisement
Guest User

client.lua

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