lsd1999 Posted March 26, 2015 Share Posted March 26, 2015 How to make the switch between "drift" and "normal" when you press a button. I understand the need to use a hundred handling. Sorry, my bad English... Link to comment
TrapLord Studios™ Posted March 26, 2015 Share Posted March 26, 2015 You'd have to bind a key that would activate a handler function that would change the vehicles handling settings, which can be edited, with setVehicleHandling Link to comment
lsd1999 Posted March 26, 2015 Author Share Posted March 26, 2015 You'd have to bind a key that would activate a handler function that would change the vehicles handling settings, which can be edited, with setVehicleHandling Thank U. Can you give an example? Link to comment
xXMADEXx Posted March 26, 2015 Share Posted March 26, 2015 You'd have to bind a key that would activate a handler function that would change the vehicles handling settings, which can be edited, with setVehicleHandling Thank U. Can you give an example? Just goto the wiki page, they have examples there for every function and event. For this function: https://wiki.multitheftauto.com/wiki/SetVehicleHandling https://wiki.multitheftauto.com/wiki/Main_Page Link to comment
lsd1999 Posted March 27, 2015 Author Share Posted March 27, 2015 What am I doing wrong? function setHandling() bindKey("k", function() for i, veh in ipairs(getElementsByType("vehicle")) do if getElementModel(veh) == 451 then setVehicleHandling(veh, "mass", 1600) setVehicleHandling(veh, "turnMass", 3921.3) setVehicleHandling(veh, "dragCoeff", 1.8 ) setVehicleHandling(veh, "centerOfMass", { 0, -0.4, 0 } ) setVehicleHandling(veh, "percentSubmerged", 75) setVehicleHandling(veh, "tractionMultiplier", 0.75) setVehicleHandling(veh, "tractionLoss", 0.85) setVehicleHandling(veh, "tractionBias", 0.52) setVehicleHandling(veh, "numberOfGears", 5) setVehicleHandling(veh, "maxVelocity", 200) setVehicleHandling(veh, "engineAcceleration", 8.8 ) setVehicleHandling(veh, "engineInertia", 10) setVehicleHandling(veh, "driveType", "rwd") setVehicleHandling(veh, "engineType", "petrol") setVehicleHandling(veh, "brakeDeceleration", 10) setVehicleHandling(veh, "brakeBias", 0.53) setVehicleHandling(veh, "ABS", 0) setVehicleHandling(veh, "steeringLock", 35) setVehicleHandling(veh, "suspensionForceLevel", 1.3) setVehicleHandling(veh, "suspensionDamping", 0.12) setVehicleHandling(veh, "suspensionHighSpeedDamping", 0) setVehicleHandling(veh, "suspensionUpperLimit", 0.28 ) setVehicleHandling(veh, "suspensionLowerLimit", -0.12) setVehicleHandling(veh, "suspensionFrontRearBias", 0.38 ) setVehicleHandling(veh, "suspensionAntiDiveMultiplier", 0) setVehicleHandling(veh, "seatOffsetDistance", 0.2) setVehicleHandling(veh, "collisionDamageMultiplier", 0.24) setVehicleHandling(veh, "monetary", 25000) setVehicleHandling(veh, "modelFlags", 0x40000000) setVehicleHandling(veh, "handlingFlags", 0x10200008 ) setVehicleHandling(veh, "headLight", 0) setVehicleHandling(veh, "tailLight", 1) setVehicleHandling(veh, "animGroup", 0) end end end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), setHandling) Link to comment
JR10 Posted March 27, 2015 Share Posted March 27, 2015 You didn't specify the player to bind the key for. Perhaps loop through the players and bind it for him? Although the logic is kinda weird, why would you bind a key to change the handling of all the vehicles. function setHandling() for index, player in pairs(getElementsByType('player')) do bindKey(player, "k", function() for i, veh in ipairs(getElementsByType("vehicle")) do if getElementModel(veh) == 451 then setVehicleHandling(veh, "mass", 1600) setVehicleHandling(veh, "turnMass", 3921.3) setVehicleHandling(veh, "dragCoeff", 1.8 ) setVehicleHandling(veh, "centerOfMass", { 0, -0.4, 0 } ) setVehicleHandling(veh, "percentSubmerged", 75) setVehicleHandling(veh, "tractionMultiplier", 0.75) setVehicleHandling(veh, "tractionLoss", 0.85) setVehicleHandling(veh, "tractionBias", 0.52) setVehicleHandling(veh, "numberOfGears", 5) setVehicleHandling(veh, "maxVelocity", 200) setVehicleHandling(veh, "engineAcceleration", 8.8 ) setVehicleHandling(veh, "engineInertia", 10) setVehicleHandling(veh, "driveType", "rwd") setVehicleHandling(veh, "engineType", "petrol") setVehicleHandling(veh, "brakeDeceleration", 10) setVehicleHandling(veh, "brakeBias", 0.53) setVehicleHandling(veh, "ABS", 0) setVehicleHandling(veh, "steeringLock", 35) setVehicleHandling(veh, "suspensionForceLevel", 1.3) setVehicleHandling(veh, "suspensionDamping", 0.12) setVehicleHandling(veh, "suspensionHighSpeedDamping", 0) setVehicleHandling(veh, "suspensionUpperLimit", 0.28 ) setVehicleHandling(veh, "suspensionLowerLimit", -0.12) setVehicleHandling(veh, "suspensionFrontRearBias", 0.38 ) setVehicleHandling(veh, "suspensionAntiDiveMultiplier", 0) setVehicleHandling(veh, "seatOffsetDistance", 0.2) setVehicleHandling(veh, "collisionDamageMultiplier", 0.24) setVehicleHandling(veh, "monetary", 25000) setVehicleHandling(veh, "modelFlags", 0x40000000) setVehicleHandling(veh, "handlingFlags", 0x10200008 ) setVehicleHandling(veh, "headLight", 0) setVehicleHandling(veh, "tailLight", 1) setVehicleHandling(veh, "animGroup", 0) end end end end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), setHandling) Now make one onPlayerJoin as well. Link to comment
lsd1999 Posted March 27, 2015 Author Share Posted March 27, 2015 [2015-03-23 16:01:47] ERROR: Loading script failed: Drift\server.lua:41: ')' expected (to close '(' at line 2) near 'addEventHandler' What is the error? Link to comment
TrapLord Studios™ Posted March 27, 2015 Share Posted March 27, 2015 You forgot to place a end bracket to close the Event Handler. Link to comment
lsd1999 Posted March 27, 2015 Author Share Posted March 27, 2015 if you is not difficult, you can select where you want to insert the bracket Link to comment
Ryancit2 Posted March 28, 2015 Share Posted March 28, 2015 There, try this: function setHandling() for index, player in pairs(getElementsByType('player') do bindKey(player, "k", function() for i, veh in ipairs(getElementsByType("vehicle") do if getElementModel(veh) == 451 then setVehicleHandling(veh, "mass", 1600) setVehicleHandling(veh, "turnMass", 3921.3) setVehicleHandling(veh, "dragCoeff", 1.8 ) setVehicleHandling(veh, "centerOfMass", { 0, -0.4, 0 } ) setVehicleHandling(veh, "percentSubmerged", 75) setVehicleHandling(veh, "tractionMultiplier", 0.75) setVehicleHandling(veh, "tractionLoss", 0.85) setVehicleHandling(veh, "tractionBias", 0.52) setVehicleHandling(veh, "numberOfGears", 5) setVehicleHandling(veh, "maxVelocity", 200) setVehicleHandling(veh, "engineAcceleration", 8.8 ) setVehicleHandling(veh, "engineInertia", 10) setVehicleHandling(veh, "driveType", "rwd") setVehicleHandling(veh, "engineType", "petrol") setVehicleHandling(veh, "brakeDeceleration", 10) setVehicleHandling(veh, "brakeBias", 0.53) setVehicleHandling(veh, "ABS", 0) setVehicleHandling(veh, "steeringLock", 35) setVehicleHandling(veh, "suspensionForceLevel", 1.3) setVehicleHandling(veh, "suspensionDamping", 0.12) setVehicleHandling(veh, "suspensionHighSpeedDamping", 0) setVehicleHandling(veh, "suspensionUpperLimit", 0.28 ) setVehicleHandling(veh, "suspensionLowerLimit", -0.12) setVehicleHandling(veh, "suspensionFrontRearBias", 0.38 ) setVehicleHandling(veh, "suspensionAntiDiveMultiplier", 0) setVehicleHandling(veh, "seatOffsetDistance", 0.2) setVehicleHandling(veh, "collisionDamageMultiplier", 0.24) setVehicleHandling(veh, "monetary", 25000) setVehicleHandling(veh, "modelFlags", 0x40000000) setVehicleHandling(veh, "handlingFlags", 0x10200008 ) setVehicleHandling(veh, "headLight", 0) setVehicleHandling(veh, "tailLight", 1) setVehicleHandling(veh, "animGroup", 0) end end end end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), setHandling) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now