├── README.md ├── client.lua ├── config.lua └── fxmanifest.lua /README.md: -------------------------------------------------------------------------------- 1 | # QB-ManualTransmission [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)] 2 | 3 | :Usefull information:
4 | - do /manual before entering vehicle to toggle between automatic and manual
5 | - do /manualmode to switch between arcade or realistic
6 | - Realistic mode vehicle will stall if you come to an dead stop in gear or try to pull off in high gear
7 | - Use UP and Down Arrow to shift gear.
8 | 9 | 10 | :CREDITS:
11 | - All credit goes to [HugoSimoes12345] who made the original script
12 | - Original Url: https://github.com/HugoSimoes12345/HRSGears 13 | 14 | 15 | -------------------------------------------------------------------------------- /client.lua: -------------------------------------------------------------------------------- 1 | local vehicle = nil 2 | local numgears = nil 3 | local topspeedGTA = nil 4 | local topspeedms = nil 5 | local acc = nil 6 | local hash = nil 7 | local selectedgear = 0 8 | local hbrake = nil 9 | 10 | local manualon = false 11 | 12 | local incar = false 13 | 14 | local currspeedlimit = nil 15 | local ready = false 16 | local realistic = false 17 | 18 | RegisterCommand("manual", function() 19 | if vehicle == nil then 20 | if manualon == false then 21 | manualon = true 22 | TriggerEvent('QBCore:Notify', 'Manual Transmission Actived', 'success') 23 | else 24 | manualon = false 25 | TriggerEvent('QBCore:Notify', 'Manual Transmission Disactived', 'error') 26 | end 27 | end 28 | end) 29 | 30 | RegisterCommand("manualmode", function() 31 | if vehicle == nil then 32 | if manualon == false then 33 | 34 | else 35 | if realistic == true then 36 | realistic = false 37 | TriggerEvent('QBCore:Notify', 'Beginers Driving mode Enabled', 'info') 38 | else 39 | realistic = true 40 | TriggerEvent('QBCore:Notify', 'Realistic Driving Mode Enabled', 'info') 41 | end 42 | end 43 | end 44 | end) 45 | 46 | Citizen.CreateThread(function() 47 | while true do 48 | Citizen.Wait(100) 49 | 50 | local ped = PlayerPedId() 51 | local newveh = GetVehiclePedIsIn(ped,false) 52 | local class = GetVehicleClass(newveh) 53 | 54 | if newveh == vehicle then 55 | 56 | elseif newveh == 0 and vehicle ~= nil then 57 | resetvehicle() 58 | else 59 | if GetPedInVehicleSeat(newveh,-1) == ped then 60 | if class ~= 13 and class ~= 14 and class ~= 15 and class ~= 16 and class ~= 21 then 61 | vehicle = newveh 62 | hash = GetEntityModel(newveh) 63 | 64 | 65 | if GetVehicleMod(vehicle,13) < 0 then 66 | numgears = GetVehicleHandlingInt(newveh, "CHandlingData", "nInitialDriveGears") 67 | else 68 | numgears = GetVehicleHandlingInt(newveh, "CHandlingData", "nInitialDriveGears") + 1 69 | end 70 | 71 | 72 | 73 | hbrake = GetVehicleHandlingFloat(newveh, "CHandlingData", "fHandBrakeForce") 74 | 75 | topspeedGTA = GetVehicleHandlingFloat(newveh, "CHandlingData", "fInitialDriveMaxFlatVel") 76 | topspeedms = (topspeedGTA * 1.32)/3.6 77 | 78 | acc = GetVehicleHandlingFloat(newveh, "CHandlingData", "fInitialDriveForce") 79 | --SetVehicleMaxSpeed(newveh,topspeedms) 80 | selectedgear = 0 81 | Citizen.Wait(50) 82 | ready = true 83 | end 84 | end 85 | end 86 | 87 | end 88 | end) 89 | 90 | function resetvehicle() 91 | SetVehicleHandlingFloat(vehicle, "CHandlingData", "fInitialDriveForce", acc) 92 | SetVehicleHandlingFloat(vehicle, "CHandlingData", "fInitialDriveMaxFlatVel",topspeedGTA) 93 | SetVehicleHandlingFloat(vehicle, "CHandlingData", "fHandBrakeForce", hbrake) 94 | SetVehicleHighGear(vehicle, numgears) 95 | ModifyVehicleTopSpeed(vehicle,1) 96 | --SetVehicleMaxSpeed(vehicle,topspeedms) 97 | SetVehicleHandbrake(vehicle, false) 98 | 99 | vehicle = nil 100 | numgears = nil 101 | topspeedGTA = nil 102 | topspeedms = nil 103 | acc = nil 104 | hash = nil 105 | hbrake = nil 106 | selectedgear = 0 107 | currspeedlimit = nil 108 | ready = false 109 | end 110 | 111 | Citizen.CreateThread(function() 112 | while true do 113 | Citizen.Wait(0) 114 | if manualon == true and vehicle ~= nil then 115 | DisableControlAction(0, 80, true) 116 | DisableControlAction(0, 21, true) 117 | end 118 | end 119 | 120 | end) 121 | 122 | 123 | Citizen.CreateThread(function() 124 | while true do 125 | Citizen.Wait(0) 126 | 127 | if manualon == true and vehicle ~= nil then 128 | 129 | if vehicle ~= nil then 130 | 131 | 132 | 133 | -- Shift up and down 134 | if ready == true then 135 | if IsDisabledControlJustPressed(0, 172) then 136 | if selectedgear <= numgears - 1 then 137 | DisableControlAction(0, 71, true) 138 | Wait(300) 139 | selectedgear = selectedgear + 1 140 | DisableControlAction(0, 71, false) 141 | SimulateGears() 142 | end 143 | elseif IsDisabledControlJustPressed(0, 173) then 144 | if selectedgear > -1 then 145 | 146 | DisableControlAction(0, 71, true) 147 | Wait(300) 148 | selectedgear = selectedgear - 1 149 | DisableControlAction(0, 71, false) 150 | SimulateGears() 151 | end 152 | end 153 | end 154 | end 155 | 156 | end 157 | 158 | end 159 | end) 160 | 161 | 162 | 163 | function SimulateGears() 164 | 165 | local engineup = GetVehicleMod(vehicle,11) 166 | 167 | if selectedgear > 0 then 168 | 169 | local ratio 170 | if Config.vehicles[hash] ~= nil then 171 | if selectedgear ~= 0 and selectedgear ~= nil then 172 | if numgears ~= nil and selectedgear ~= nil then 173 | ratio = Config.vehicles[hash][numgears][selectedgear] * (1/0.9) 174 | else 175 | ratio = Config.gears[numgears][selectedgear] * (1/0.9) 176 | end 177 | end 178 | 179 | else 180 | if selectedgear ~= 0 and selectedgear ~= nil then 181 | if numgears ~= nil and selectedgear ~= nil then 182 | ratio = Config.gears[numgears][selectedgear] * (1/0.9) 183 | else 184 | 185 | end 186 | 187 | end 188 | end 189 | 190 | if ratio ~= nil then 191 | 192 | SetVehicleHighGear(vehicle,1) 193 | newacc = ratio * acc 194 | newtopspeedGTA = topspeedGTA / ratio 195 | newtopspeedms = topspeedms / ratio 196 | 197 | --if GetEntitySpeed(vehicle) > newtopspeedms then 198 | --selectedgear = selectedgear + 1 199 | --else 200 | 201 | SetVehicleHandbrake(vehicle, false) 202 | SetVehicleHandlingFloat(vehicle, "CHandlingData", "fInitialDriveForce", newacc) 203 | SetVehicleHandlingFloat(vehicle, "CHandlingData", "fInitialDriveMaxFlatVel", newtopspeedGTA) 204 | SetVehicleHandlingFloat(vehicle, "CHandlingData", "fHandBrakeForce", hbrake) 205 | ModifyVehicleTopSpeed(vehicle,1) 206 | --SetVehicleMaxSpeed(vehicle,newtopspeedms) 207 | currspeedlimit = newtopspeedms 208 | --end 209 | 210 | end 211 | elseif selectedgear == 0 then 212 | --SetVehicleHandlingFloat(vehicle, "CHandlingData", "fInitialDriveMaxFlatVel", 0.0) 213 | elseif selectedgear == -1 then 214 | 215 | --if GetEntitySpeedVector(vehicle,true).y > 0.1 then 216 | --selectedgear = selectedgear + 1 217 | --else 218 | SetVehicleHandbrake(vehicle, false) 219 | SetVehicleHighGear(vehicle,numgears) 220 | SetVehicleHandlingFloat(vehicle, "CHandlingData", "fInitialDriveForce", acc) 221 | SetVehicleHandlingFloat(vehicle, "CHandlingData", "fInitialDriveMaxFlatVel", topspeedGTA) 222 | SetVehicleHandlingFloat(vehicle, "CHandlingData", "fHandBrakeForce", hbrake) 223 | ModifyVehicleTopSpeed(vehicle,1) 224 | 225 | --SetVehicleMaxSpeed(vehicle,topspeedms) 226 | --end 227 | 228 | end 229 | SetVehicleMod(vehicle,11,engineup,false) 230 | 231 | end 232 | 233 | Citizen.CreateThread(function() 234 | while true do 235 | Citizen.Wait(0) 236 | if manualon == true and vehicle ~= nil then 237 | if selectedgear == -1 then 238 | if GetVehicleCurrentGear(vehicle) == 1 then 239 | DisableControlAction(0, 71, true) 240 | end 241 | elseif selectedgear > 0 then 242 | if GetEntitySpeedVector(vehicle,true).y < 0.0 then 243 | DisableControlAction(0, 72, true) 244 | end 245 | elseif selectedgear == 0 then 246 | SetVehicleHandbrake(vehicle, true) 247 | if IsControlPressed(0, 76) == false then 248 | SetVehicleHandlingFloat(vehicle, "CHandlingData", "fHandBrakeForce", 0.0) 249 | else 250 | SetVehicleHandlingFloat(vehicle, "CHandlingData", "fHandBrakeForce", hbrake) 251 | end 252 | end 253 | else 254 | Citizen.Wait(100) 255 | end 256 | end 257 | end) 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | local disable = false 266 | 267 | Citizen.CreateThread(function() 268 | while true do 269 | Citizen.Wait(0) 270 | if realistic == true then 271 | if manualon == true and vehicle ~= nil then 272 | if selectedgear > 1 then 273 | if IsControlPressed(0,71) then 274 | local speed = GetEntitySpeed(vehicle) 275 | local minspeed = currspeedlimit / 7 276 | 277 | if speed < minspeed then 278 | if GetVehicleCurrentRpm(vehicle) < 0.4 then 279 | disable = true 280 | end 281 | end 282 | end 283 | end 284 | else 285 | Citizen.Wait(100) 286 | end 287 | else 288 | Citizen.Wait(100) 289 | end 290 | end 291 | end) 292 | 293 | 294 | 295 | 296 | 297 | Citizen.CreateThread(function() 298 | while true do 299 | 300 | Citizen.Wait(0) 301 | if disable == true then 302 | SetVehicleEngineOn(vehicle,false,true,false) 303 | Citizen.Wait(1000) 304 | 305 | disable = false 306 | end 307 | 308 | end 309 | end) 310 | 311 | Citizen.CreateThread(function() 312 | while true do 313 | 314 | Citizen.Wait(0) 315 | if vehicle ~= nil and selectedgear ~= 0 then 316 | local speed = GetEntitySpeed(vehicle) 317 | 318 | if currspeedlimit ~= nil then 319 | 320 | if speed >= currspeedlimit then 321 | 322 | if Config.enginebrake == true then 323 | if speed / currspeedlimit > 1.1 then 324 | --print('dead') 325 | local hhhh = speed / currspeedlimit 326 | SetVehicleCurrentRpm(vehicle,hhhh) 327 | SetVehicleCheatPowerIncrease(vehicle,-100.0) 328 | --SetVehicleBurnout(vehicle,true) 329 | else 330 | --SetVehicleBurnout(vehicle,false) 331 | SetVehicleCheatPowerIncrease(vehicle,0.0) 332 | end 333 | else 334 | SetVehicleCheatPowerIncrease(vehicle,0.0) 335 | end 336 | 337 | 338 | --SetVehicleHandbrake(vehicle, true) 339 | --if IsControlPressed(0, 76) == false then 340 | --SetVehicleHandlingFloat(vehicle, "CHandlingData", "fHandBrakeForce", 0.0) 341 | -- else 342 | --SetVehicleHandlingFloat(vehicle, "CHandlingData", "fHandBrakeForce", hbrake) 343 | --end 344 | 345 | 346 | else 347 | --SetVehicleHandbrake(vehicle, false) 348 | --if IsControlPressed(0, 76) == false then 349 | 350 | --else 351 | --SetVehicleHandbrake(vehicle, true) 352 | --SetVehicleHandlingFloat(vehicle, "CHandlingData", "fHandBrakeForce", hbrake) 353 | --end 354 | 355 | end 356 | 357 | else 358 | 359 | if speed >= topspeedms then 360 | SetVehicleCheatPowerIncrease(vehicle,0.0) 361 | --SetVehicleHandbrake(vehicle, true) 362 | --if IsControlPressed(0, 76) == false then 363 | --SetVehicleHandlingFloat(vehicle, "CHandlingData", "fHandBrakeForce", 0.0) 364 | --else 365 | --SetVehicleHandlingFloat(vehicle, "CHandlingData", "fHandBrakeForce", hbrake) 366 | --end 367 | 368 | 369 | else 370 | --SetVehicleHandbrake(vehicle, false) 371 | --if IsControlPressed(0, 76) == false then 372 | 373 | --else 374 | --SetVehicleHandbrake(vehicle, true) 375 | --SetVehicleHandlingFloat(vehicle, "CHandlingData", "fHandBrakeForce", hbrake) 376 | --end 377 | 378 | end 379 | 380 | 381 | end 382 | 383 | 384 | 385 | 386 | 387 | end 388 | 389 | end 390 | end) 391 | 392 | 393 | 394 | 395 | 396 | ---------------debug 397 | 398 | Citizen.CreateThread(function() 399 | 400 | Citizen.Wait(100) 401 | 402 | if Config.gearhud == 1 then 403 | Citizen.CreateThread(function() 404 | while true do 405 | Citizen.Wait(0) 406 | if manualon == true and vehicle ~= nil then 407 | 408 | SetTextFont(0) 409 | SetTextProportional(1) 410 | SetTextScale(0.0, 0.3) 411 | SetTextColour(128, 128, 128, 255) 412 | SetTextDropshadow(0, 0, 0, 0, 255) 413 | SetTextEdge(1, 0, 0, 0, 255) 414 | SetTextDropShadow() 415 | SetTextOutline() 416 | SetTextEntry("STRING") 417 | 418 | AddTextComponentString("~r~Gear: ~w~"..getinfo(selectedgear)) 419 | 420 | DrawText(0.015, 0.78) 421 | else 422 | Citizen.Wait(100) 423 | end 424 | end 425 | end) 426 | elseif Config.gearhud == 2 then 427 | Citizen.CreateThread(function() 428 | while true do 429 | Citizen.Wait(0) 430 | if manualon == true and vehicle ~= nil then 431 | 432 | SetTextFont(0) 433 | SetTextProportional(1) 434 | SetTextScale(0.0, 0.3) 435 | SetTextColour(128, 128, 128, 255) 436 | SetTextDropshadow(0, 0, 0, 0, 255) 437 | SetTextEdge(1, 0, 0, 0, 255) 438 | SetTextDropShadow() 439 | SetTextOutline() 440 | SetTextEntry("STRING") 441 | 442 | AddTextComponentString("~r~Gear: ~w~"..getinfo(selectedgear).." ~r~Km/h: ~w~"..round((GetEntitySpeed(vehicle)*3.6),0).." ~r~RPM: ~w~"..round(GetVehicleCurrentRpm(vehicle),2)) 443 | 444 | DrawText(0.015, 0.78) 445 | else 446 | Citizen.Wait(100) 447 | end 448 | end 449 | end) 450 | end 451 | 452 | end) 453 | 454 | 455 | 456 | 457 | 458 | 459 | function getinfo(gea) 460 | if gea == 0 then 461 | return "N" 462 | elseif gea == -1 then 463 | return "R" 464 | else 465 | return gea 466 | end 467 | end 468 | 469 | function round(value, numDecimalPlaces) 470 | if numDecimalPlaces then 471 | local power = 10^numDecimalPlaces 472 | return math.floor((value * power) + 0.5) / (power) 473 | else 474 | return math.floor(value + 0.5) 475 | end 476 | end 477 | 478 | -------------------------------------------------------------------------------- /config.lua: -------------------------------------------------------------------------------- 1 | Config = {} 2 | 3 | ------------------ the last gear allways need to be 0.90!!!!!-------------------------------- 4 | ------------------ gear ratios from 1 to 6 gears vehicle are native GTA V gear ratios and i create the other ------- 5 | ------------------ in config.vehicles you can add more gear ratios for specified vehicles --- 6 | ------------------ gear up = shift / controller A , gear down = r / controller B ------------ 7 | ------------------ Lscustom transmission upgrade adds another Gear to the vehicle ---------- 8 | 9 | Config.gears = { 10 | [1] = {0.90},--1 11 | [2] = {3.33, 0.90},--2 12 | [3] = {3.33, 1.57, 0.90},--3 13 | [4] = {3.33, 1.83, 1.22, 0.90},--4 14 | [5] = {3.33, 1.92, 1.36, 1.05, 0.90},--5 15 | [6] = {3.33, 1.95, 1.39, 1.09, 0.95, 0.90},--6 16 | [7] = {4.00, 2.34, 1.67, 1.31, 1.14, 1.08, 0.90},--7 17 | [8] = {5.31, 3.11, 2.22, 1.74, 1.51, 1.43, 1.20, 0.90},--8 18 | [9] = {7.70, 4.51, 3.22, 2.52, 2.20, 2.08, 1.73, 1.31, 0.90}--9 19 | } 20 | 21 | Config.vehicles = { 22 | [GetHashKey('omnis')] = { 23 | [5] = {3.885, 2.312, 1.51848, 1.0688, 0.90},--5 Audi 4 trans 24 | [6] = {3.33,2.5, 2.0, 1.633, 1.089, 0.90},--6 2008 Subaru Impreza WRC2008 (S14) trans 25 | }, 26 | -- [GetHashKey('audquattros')] = { 27 | -- [5] = {3.885, 2.312, 1.51848, 1.0688, 0.90},--5 Audi 4 trans 28 | -- [6] = {3.33,2.5, 2.0, 1.633, 1.089, 0.90},--6 2008 Subaru Impreza WRC2008 (S14) trans 29 | -- }, 30 | -- [GetHashKey('futo')] = { 31 | -- [5] = {3.33, 1.92, 1.36, 1.05, 0.90},--5 32 | -- [6] = {3.33, 1.95, 1.39, 1.09, 0.95, 0.90},--6 33 | -- }, 34 | -- [GetHashKey('m3e36')] = { 35 | -- [6] = {4.585, 2.72, 1.81, 1.333, 1.084, 0.90},--6 m3e36 trans 36 | -- [7] = {4.00, 2.34, 1.67, 1.31, 1.14, 1.08, 0.90},--7 37 | -- }, 38 | -- [GetHashKey('nero')] = { 39 | 40 | -- [7] = {4.205, 2.523364, 1.892523, 1.4509, 1.17757, 0.988, 0.90},--7 41 | -- [8] = {5.31, 3.11, 2.22, 1.74, 1.51, 1.43, 1.20, 0.90},--8 42 | -- }, 43 | -- [GetHashKey('gauntlet4')] = { 44 | 45 | 46 | -- [8] = {6.36, 4.24, 2.8416, 2.249, 1.733, 1.349, 1.132, 0.90},--8 47 | -- [9] = {7.70, 4.51, 3.22, 2.52, 2.20, 2.08, 1.73, 1.31, 0.90}--9 48 | -- }, 49 | 50 | 51 | } 52 | 53 | 54 | Config.enginebrake = true -- brakes the car if you downshift the wrong way 55 | 56 | 57 | Config.gearhud = 1 -- if 1 - show gear / if 2 show gear and km/h and Rpm from 0 to 1 / if 0 disable hud 58 | 59 | -------------------------------------------------------------------------------- /fxmanifest.lua: -------------------------------------------------------------------------------- 1 | fx_version 'adamant' 2 | games {'gta5'} 3 | version '1.0' 4 | 5 | 6 | client_scripts { 7 | "client.lua", 8 | "config.lua", 9 | 10 | } 11 | 12 | 13 | --------------------------------------------------------------------------------