|
| 1 | + |
| 2 | +local x, y = guiGetScreenSize ( ) |
| 3 | +local sx = guiGetScreenSize() |
| 4 | +local Corner = 0 |
| 5 | +local CornerPlus = 1 |
| 6 | +local voz = 1 |
| 7 | +local carTable = |
| 8 | + { |
| 9 | + [550] = {["steeringLock"] = 52,}, |
| 10 | + } |
| 11 | + |
| 12 | +local setControls = function () |
| 13 | + local theVeh = getPedOccupiedVehicle(localPlayer) |
| 14 | + if not theVeh then return end |
| 15 | + local data = getElementData(theVeh,"steeringLock") or 0 |
| 16 | + local _,__,Z1 = getVehicleComponentRotation( theVeh,"wheel_lf_dummy") |
| 17 | + local _,__,Z2 = getVehicleComponentRotation( theVeh,"wheel_rf_dummy") |
| 18 | + local _,__ = nil,nil |
| 19 | + Z1,Z2 = math.ceil(Z1)-180,360-(Z2) |
| 20 | + if Z1 > 1 then Z2 = Z2-360 end if math.ceil(Z1) == 1 then Z1 = 0 end if math.ceil(Z2) == 360 or Z2 == 359 then Z2 = 0 end |
| 21 | + local loc = 0.01 |
| 22 | + local proc = 10 |
| 23 | + local num_1 = Corner -- Это 100% |
| 24 | + local arip = (num_1/(data*10)*9.81) |
| 25 | + arip = tonumber(string.format("%.2f", arip)) |
| 26 | + |
| 27 | + s1 = false |
| 28 | + s2 = false |
| 29 | + |
| 30 | + if tonumber(arip) < 0 then |
| 31 | + setAnalogControlState('vehicle_left',(-arip)) |
| 32 | + |
| 33 | + if microControl == 1 then |
| 34 | + s1 = false |
| 35 | + s2 = true |
| 36 | + end |
| 37 | + |
| 38 | + if microControl == 2 then |
| 39 | + s1 = true |
| 40 | + s2 = false |
| 41 | + end |
| 42 | + |
| 43 | + elseif tonumber(arip) > 0 then |
| 44 | + setAnalogControlState('vehicle_right',(arip)) |
| 45 | + |
| 46 | + if microControl == 1 then |
| 47 | + s1 = true |
| 48 | + s2 = false |
| 49 | + end |
| 50 | + |
| 51 | + if microControl == 2 then |
| 52 | + s1 = false |
| 53 | + s2 = true |
| 54 | + end |
| 55 | + |
| 56 | + end |
| 57 | + toggleControl ("vehicle_left" , s1 ) |
| 58 | + toggleControl ("vehicle_right" , s2 ) |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | +if debugMode == false then return end |
| 63 | + |
| 64 | +dxDrawRectangle(25,y/6,300,250,tocolor(0,0,0,155)) |
| 65 | +dxDrawText ("Левое колесо:"..math.ceil(Z1),60,y/5.4, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 2, 2, "default" ) |
| 66 | +dxDrawText ("Правое колесо:"..math.ceil(Z2),60,y/4.5, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 2, 2, "default" ) |
| 67 | + |
| 68 | + dxDrawRectangle(175,y/4.7,-Z1*2,15,tocolor(0,255,0,155)) |
| 69 | + dxDrawRectangle(175,y/4,Z2*2,15,tocolor(255,0,0,155)) |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | + dxDrawText ("Аналоговое зн: "..arip, 60,y/3.0, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 2, 2, "default" ) |
| 75 | + dxDrawText ( "Желаемый угол "..Corner, 60,y/3.5, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 2,2, "default" ) |
| 76 | +end |
| 77 | +addEventHandler('onClientPreRender',root,setControls) |
| 78 | + |
| 79 | + |
| 80 | +local function drawSpeed() |
| 81 | + local veh = getPedOccupiedVehicle (getLocalPlayer()) |
| 82 | + if not veh then return end |
| 83 | + local speedkmh = getElementSpeed(veh, 2) |
| 84 | + local roundedSpeedkmh = math.floor(speedkmh) == speedkmh and speedkmh or string.format(speedkmh, "%.1f") |
| 85 | + local roundedSpeedkmh = tonumber(roundedSpeedkmh) |
| 86 | + dxDrawText(math.ceil(roundedSpeedkmh), sx - dxGetTextWidth(math.ceil(roundedSpeedkmh)), 0) |
| 87 | + if math.ceil(roundedSpeedkmh) == 0 or math.ceil(roundedSpeedkmh) == 1 or math.ceil(roundedSpeedkmh) == 2 then return end |
| 88 | +if roundedSpeedkmh <= 35 then speedReturnWh = 0.2 end |
| 89 | + |
| 90 | + |
| 91 | + if Corner < 0 then -- лево |
| 92 | + Corner = Corner+speedReturnWh |
| 93 | + end |
| 94 | + if Corner > 0 then -- право |
| 95 | + Corner = Corner-speedReturnWh |
| 96 | + end |
| 97 | +Corner = tonumber(string.format("%.3f", Corner)) |
| 98 | + |
| 99 | +end |
| 100 | +addEventHandler("onClientRender", getRootElement(), drawSpeed) |
| 101 | + |
| 102 | + |
| 103 | +function getDriftAngle(vehicle) |
| 104 | + if vehicle.velocity.length < 0.12 then |
| 105 | + return 0 |
| 106 | + end |
| 107 | + |
| 108 | + local direction = vehicle.matrix.forward |
| 109 | + local velocity = vehicle.velocity.normalized |
| 110 | + |
| 111 | + local dot = direction.x * velocity.x + direction.y * velocity.y |
| 112 | + local det = direction.x * velocity.y - direction.y * velocity.x |
| 113 | + |
| 114 | + local angle = math.deg(math.atan2(det, dot)) |
| 115 | + if math.abs(angle) > 160 then |
| 116 | + return 0 |
| 117 | + end |
| 118 | + if angle < 0 then |
| 119 | + dir = "left" |
| 120 | + elseif angle > 0 then |
| 121 | + dir = "right" |
| 122 | + end |
| 123 | + return angle, dir |
| 124 | +end |
| 125 | + |
| 126 | + |
| 127 | +addEventHandler("onClientVehicleEnter", getRootElement(), |
| 128 | + function(thePlayer, seat) |
| 129 | + local veh = getPedOccupiedVehicle (getLocalPlayer()) |
| 130 | + for i,v in pairs (carTable) do |
| 131 | + if not veh then return end |
| 132 | + if i == getElementModel(veh) then |
| 133 | + for handling, value in pairs (v) do |
| 134 | + setElementData(veh,handling,value) |
| 135 | + triggerServerEvent ( "stTheBVal", resourceRoot, veh,value) |
| 136 | + print("Угол выворота установлен на :"..getElementData(veh,handling)) |
| 137 | + |
| 138 | + end |
| 139 | + end |
| 140 | + end |
| 141 | + end) |
| 142 | + |
| 143 | +local key = function() |
| 144 | + if getKeyState("a") and getKeyState('d') then return end |
| 145 | + local veh = getPedOccupiedVehicle (getLocalPlayer()) |
| 146 | + if not veh then return end |
| 147 | + local data = getElementData(veh,"steeringLock") or nil |
| 148 | + if getKeyState("lshift") then dxDrawText ("Множитель X2", x/4,y/2.02, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 1,1, "default" ) mnz = 1 else mnz = 0 end |
| 149 | + |
| 150 | + if getKeyState("a") then |
| 151 | + if data == nil then return end |
| 152 | + if tonumber((data-data-data) ) > Corner then return end |
| 153 | + Corner = Corner - CornerPlus-mnz |
| 154 | + end |
| 155 | + if getKeyState("d") then |
| 156 | + if data == nil then return end |
| 157 | + if tonumber(data) < Corner then return end |
| 158 | + Corner = Corner + CornerPlus+mnz |
| 159 | + end |
| 160 | +end |
| 161 | +addEventHandler('onClientRender',root,key) |
| 162 | + |
| 163 | + |
| 164 | +function getElementSpeed(theElement, unit) |
| 165 | + local vehicle = getPedOccupiedVehicle(getLocalPlayer()) |
| 166 | + if not vehicle then return end |
| 167 | + assert(isElement(theElement), "Чет наебнулось аргумент - 1 @ getElementSpeed (нихуя не получил от - " .. type(theElement) .. ")") |
| 168 | + local elementType = getElementType(theElement) |
| 169 | + assert(elementType == "player" or elementType == "ped" or elementType == "object" or elementType == "vehicle" or elementType == "projectile", "Invalid element type @ getElementSpeed (player/ped/object/vehicle/projectile expected, got " .. elementType .. ")") |
| 170 | + assert((unit == nil or type(unit) == "string" or type(unit) == "number") and (unit == nil or (tonumber(unit) and (tonumber(unit) == 0 or tonumber(unit) == 1 or tonumber(unit) == 2)) or unit == "m/s" or unit == "km/h" or unit == "mph"), "Bad argument 2 @ getElementSpeed (invalid speed unit)") |
| 171 | + unit = unit == nil and 0 or ((not tonumber(unit)) and unit or tonumber(unit)) |
| 172 | + local mult = (unit == 0 or unit == "m/s") and 50 or ((unit == 1 or unit == "km/h") and 180 or 111.84681456) |
| 173 | + return (Vector3(getElementVelocity(theElement)) * mult).length |
| 174 | +end |
0 commit comments