Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2019
5,930
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.58 KB | None | 0 0
  1. -- demonstration: https://gfycat.com/fairdisloyalafricanfisheagle
  2.  
  3. local function DrawLabelText(x, y, size, text)
  4.   SetTextFont(4)
  5.   SetTextCentre(0)
  6.   SetTextProportional(1)
  7.   SetTextScale(0.0, size)
  8.   SetTextColour(255, 255, 255, 200)
  9.   SetTextDropShadow(0, 0, 0, 0,255)
  10.   SetTextEdge(2, 0, 0, 0, 255)
  11.   SetTextDropShadow()
  12.   SetTextOutline()
  13.   SetTextEntry("STRING")
  14.   AddTextComponentString(text)
  15.   DrawText(x, y)
  16. end
  17.  
  18. -- ignore that
  19. local function GetVehicleWheelieState(vehicle)
  20.   return Citizen.InvokeNative(GetHashKey("GET_VEHICLE_WHEELIE_STATE") & 0xFFFFFFFF, vehicle)
  21. end
  22.  
  23. -- ignore that
  24. local function SetVehicleWheelieState(vehicle, state)
  25.   return Citizen.InvokeNative(GetHashKey("SET_VEHICLE_WHEELIE_STATE") & 0xFFFFFFFF, vehicle, state)
  26. end
  27.  
  28. local wheeliemodes = {
  29.   [0] = "Only musclecars",
  30.   [1] = "All vehicles",
  31.   [2] = "Always enabled",
  32.   [3] = "Always disabled"
  33. }
  34.  
  35. local wheeeliestates = {
  36.   [0] = "~b~Unknown~w~",
  37.   [1] = "~b~Not wheeling~w~",
  38.   [65] = "~y~Ready to wheelie~w~",
  39.   [129] = "~r~They see me rollin~w~"
  40. }
  41.  
  42. Citizen.CreateThread(function()
  43.   local mode = 0
  44.  
  45.   while true do
  46.     Wait(1)
  47.  
  48.     local veh = GetVehiclePedIsIn(PlayerPedId(), false)
  49.     if veh ~= 0 then
  50.       local state = GetVehicleWheelieState(veh)
  51.  
  52.       -- draw debug info
  53.       local statetext = wheeeliestates[state] or "wtf"
  54.       local modetext = wheeliemodes[mode] or "wtf"
  55.  
  56.       DrawLabelText(0.02, 0.505, 0.6, "~c~WHEELIE~w~")
  57.       DrawLabelText(0.032, 0.54, 0.45, "State: " .. statetext .. "~c~ (" .. tostring(state) .. ")")
  58.       DrawLabelText(0.032, 0.57, 0.45, "Mode: ~p~" .. modetext .. "~c~ (" .. mode .. ")")
  59.  
  60.       -- apply overrides
  61.       if mode == 1 or mode == 2 then
  62.         -- fixme
  63.         if mode == 2 or (IsControlPressed(0, 76) and IsControlPressed(0, 71)) then -- space + w
  64.           SetVehicleWheelieState(veh, 129)
  65.         end
  66.  
  67.         -- some non-muscle vehicle can have not enough engine power to do wheelie
  68.         -- so probably you will need to add torque/power multiplier
  69.         if state == 129 and GetVehicleClass(veh) ~= 4 then
  70.           --SetVehicleEngineTorqueMultiplier(veh, 1.5)
  71.         end
  72.       elseif mode == 3 then
  73.         SetVehicleWheelieState(veh, 1)
  74.       end
  75.  
  76.       -- modes switch hotkeys
  77.       if IsControlPressed(0, 19) then -- alt
  78.         if IsControlJustPressed(0, 174) then -- arrow left
  79.           mode = (mode - 1 < 0) and 3 or mode - 1
  80.         end
  81.  
  82.         if IsControlJustPressed(0, 175) then -- arrow right
  83.           mode = (mode + 1 > 3) and 0 or mode + 1
  84.         end
  85.       end
  86.     end
  87.   end
  88. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement